mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
[move-operator] Specify if LexicalLifetimes is enabled using an enum instead of a bool.
The reason why I am doing this is that we are going to be enabling lexical lifetimes early in the pipeline so that I can use it for the move operator's diagnostics. To make it easy for passes to know whether or not they should support lexical lifetimes, I included a query on SILOptions called supportsLexicalLifetimes. This will return true if the pass (given the passed in option) should insert the lexical lifetime flag. This ensures that passes that run in both pipelines (e.x.: AllocBoxToStack) know whether or not to set the lexical lifetime flag without having to locally reason about it. This is just chopping off layers of a larger patch I am upstreaming. NOTE: This is technically NFC since it leaves the default alone of not inserting lexical lifetimes at all.
This commit is contained in:
@@ -908,6 +908,22 @@ inline llvm::raw_ostream &operator<<(llvm::raw_ostream &OS, const SILModule &M){
|
||||
return OS;
|
||||
}
|
||||
|
||||
inline bool SILOptions::supportsLexicalLifetimes(const SILModule &mod) const {
|
||||
switch (mod.getStage()) {
|
||||
case SILStage::Raw:
|
||||
// In Raw SIL, we support lexical lifetimes as long as lexical lifetimes is
|
||||
// not turned off all the way.
|
||||
return LexicalLifetimes != LexicalLifetimesOption::Off;
|
||||
case SILStage::Canonical:
|
||||
// In Canonical SIL, we only support lexical lifetimes when in experimental
|
||||
// late mode.
|
||||
return LexicalLifetimes == LexicalLifetimesOption::ExperimentalLate;
|
||||
case SILStage::Lowered:
|
||||
// We do not support OSSA in Lowered SIL, so this is always false.
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/// Print a simple description of a SILModule for the request evaluator.
|
||||
void simple_display(llvm::raw_ostream &out, const SILModule *M);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user