[SILOpt] Added flag to disable destroy hoisting.

It is on by default.  The default changes with the value of the
CopyPropagation setting.  But it can still be overridden.
This commit is contained in:
Nate Chandler
2022-04-05 15:25:08 -07:00
parent cd4bc88443
commit 11e5c97f45
5 changed files with 140 additions and 3 deletions

View File

@@ -1553,6 +1553,15 @@ static bool ParseSILArgs(SILOptions &Opts, ArgList &Args,
// -Ounchecked might also set removal of runtime asserts (cond_fail).
Opts.RemoveRuntimeAsserts |= Args.hasArg(OPT_RemoveRuntimeAsserts);
Optional<DestroyHoistingOption> specifiedDestroyHoistingOption;
if (Arg *A = Args.getLastArg(OPT_enable_destroy_hoisting)) {
specifiedDestroyHoistingOption =
llvm::StringSwitch<Optional<DestroyHoistingOption>>(A->getValue())
.Case("true", DestroyHoistingOption::On)
.Case("false", DestroyHoistingOption::Off)
.Default(None);
}
Optional<CopyPropagationOption> specifiedCopyPropagationOption;
if (Arg *A = Args.getLastArg(OPT_copy_propagation_state_EQ)) {
specifiedCopyPropagationOption =
@@ -1654,13 +1663,17 @@ static bool ParseSILArgs(SILOptions &Opts, ArgList &Args,
// Unless overridden below, enabling copy propagation means enabling lexical
// lifetimes.
if (Opts.CopyPropagation == CopyPropagationOption::On)
if (Opts.CopyPropagation == CopyPropagationOption::On) {
Opts.LexicalLifetimes = LexicalLifetimesOption::On;
Opts.DestroyHoisting = DestroyHoistingOption::On;
}
// Unless overridden below, disable copy propagation means disabling lexical
// lifetimes.
if (Opts.CopyPropagation == CopyPropagationOption::Off)
if (Opts.CopyPropagation == CopyPropagationOption::Off) {
Opts.LexicalLifetimes = LexicalLifetimesOption::DiagnosticMarkersOnly;
Opts.DestroyHoisting = DestroyHoistingOption::Off;
}
// If move-only is enabled, always enable lexical lifetime as well. Move-only
// depends on lexical lifetimes.
@@ -1681,6 +1694,8 @@ static bool ParseSILArgs(SILOptions &Opts, ArgList &Args,
Opts.LexicalLifetimes = LexicalLifetimesOption::Off;
}
}
if (specifiedDestroyHoistingOption)
Opts.DestroyHoisting = *specifiedDestroyHoistingOption;
Opts.EnableARCOptimizations &= !Args.hasArg(OPT_disable_arc_opts);
Opts.EnableOSSAModules |= Args.hasArg(OPT_enable_ossa_modules);