[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:
Michael Gottesman
2021-11-15 12:58:07 -08:00
parent d0cc5757b9
commit 72eb5e2eec
12 changed files with 101 additions and 32 deletions

View File

@@ -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);