Skip to content

Commit e881e2a

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 5db2bf5 commit e881e2a

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
@@ -1522,13 +1522,14 @@ static bool ParseSILArgs(SILOptions &Opts, ArgList &Args,
15221522
return true;
15231523
}
15241524

1525-
// -enable-copy-propagation implies -enable-lexical-lifetimes unless
1526-
// otherwise specified.
1527-
if (Args.hasArg(OPT_enable_copy_propagation))
1525+
// Unless overridden below, enabling copy propagation means enabling lexical
1526+
// lifetimes.
1527+
if (Opts.CopyPropagation == CopyPropagationOption::On)
15281528
Opts.LexicalLifetimes = LexicalLifetimesOption::On;
15291529

1530-
// -disable-copy-propagation implies -enable-lexical-lifetimes=false
1531-
if (Args.hasArg(OPT_disable_copy_propagation))
1530+
// Unless overridden below, disable copy propagation means disabling lexical
1531+
// lifetimes.
1532+
if (Opts.CopyPropagation == CopyPropagationOption::Off)
15321533
Opts.LexicalLifetimes = LexicalLifetimesOption::DiagnosticMarkersOnly;
15331534

15341535
// 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)