Skip to content

Commit dab3f61

Browse files
committed
Base LexicalLifetimes dflt on SILOpts::CopyProp.
Previously, the default value for SILOptions::LexicalLifetimes was based on a copy propagation behavior (which can then be overridden by the flags for lexical lifetimems) only when the copy propagation was explicitly specified. Instead, set base the default value for this option (SILOptions::LexicalLifetimes) on the effective copy propagation behavior (i.e. SILOptions::CopyPropagation) regardless of whether an explicit behavior has been specified. Doing so will ensure that the desired behavior occurs as the default behavior for copy-propagation changes, but for now this change is NFC.
1 parent 019a75d commit dab3f61

File tree

2 files changed

+13
-7
lines changed

2 files changed

+13
-7
lines changed

lib/Frontend/CompilerInvocation.cpp

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1514,13 +1514,14 @@ static bool ParseSILArgs(SILOptions &Opts, ArgList &Args,
15141514
return true;
15151515
}
15161516

1517-
// -enable-copy-propagation implies -enable-lexical-lifetimes unless
1518-
// otherwise specified.
1519-
if (Args.hasArg(OPT_enable_copy_propagation))
1517+
// Unless overridden below, enabling copy propagation means enabling lexical
1518+
// lifetimes.
1519+
if (Opts.CopyPropagation == CopyPropagationOption::On)
15201520
Opts.LexicalLifetimes = LexicalLifetimesOption::On;
15211521

1522-
// -disable-copy-propagation implies -enable-lexical-lifetimes=false
1523-
if (Args.hasArg(OPT_disable_copy_propagation))
1522+
// Unless overridden below, disable copy propagation means disabling lexical
1523+
// lifetimes.
1524+
if (Opts.CopyPropagation == CopyPropagationOption::Off)
15241525
Opts.LexicalLifetimes = LexicalLifetimesOption::DiagnosticMarkersOnly;
15251526

15261527
// If move-only is enabled, always enable lexical lifetime as well. Move-only

tools/sil-opt/SILOpt.cpp

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -537,9 +537,14 @@ int main(int argc, char **argv) {
537537
SILOpts.CopyPropagation = CopyPropagationOption::RequestedPassesOnly;
538538
}
539539

540-
if (EnableCopyPropagation)
540+
// Unless overridden below, enabling copy propagation means enabling lexical
541+
// lifetimes.
542+
if (SILOpts.CopyPropagation == CopyPropagationOption::On)
541543
SILOpts.LexicalLifetimes = LexicalLifetimesOption::On;
542-
if (DisableCopyPropagation)
544+
545+
// Unless overridden below, disable copy propagation means disabling lexical
546+
// lifetimes.
547+
if (SILOpts.CopyPropagation == CopyPropagationOption::Off)
543548
SILOpts.LexicalLifetimes = LexicalLifetimesOption::DiagnosticMarkersOnly;
544549

545550
// Enable lexical lifetimes if it is set or if experimental move only is

0 commit comments

Comments
 (0)