Skip to content

Commit f3774f8

Browse files
committed
Replaced -disable-copy-prop with multi-var.
Replaced the -disable-copy-propagation flag with -enable-copy-propagation=false where the latter is a new multi-var -enable-copy-propagation= which can take one of three values: - true - requested-passes-only - false
1 parent dab3f61 commit f3774f8

13 files changed

+150
-54
lines changed

include/swift/Option/FrontendOptions.td

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -215,8 +215,10 @@ def dependency_scan_cache_remarks : Flag<["-"], "Rdependency-scan-cache">,
215215
def enable_copy_propagation : Flag<["-"], "enable-copy-propagation">,
216216
HelpText<"Run SIL copy propagation with lexical lifetimes to shorten object "
217217
"lifetimes while preserving variable lifetimes.">;
218-
def disable_copy_propagation : Flag<["-"], "disable-copy-propagation">,
219-
HelpText<"Don't run SIL copy propagation to preserve object lifetime.">;
218+
def copy_propagation_state_EQ :
219+
Joined<["-"], "enable-copy-propagation=">,
220+
HelpText<"Whether to enable copy propagation">,
221+
MetaVarName<"true|requested-passes-only|false">;
220222

221223
def enable_infer_public_concurrent_value : Flag<["-"], "enable-infer-public-sendable">,
222224
HelpText<"Enable inference of Sendable conformances for public structs and enums">;

lib/Frontend/CompilerInvocation.cpp

Lines changed: 36 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1455,6 +1455,42 @@ static bool ParseSILArgs(SILOptions &Opts, ArgList &Args,
14551455
// -Ounchecked might also set removal of runtime asserts (cond_fail).
14561456
Opts.RemoveRuntimeAsserts |= Args.hasArg(OPT_RemoveRuntimeAsserts);
14571457

1458+
Optional<CopyPropagationOption> specifiedCopyPropagationOption;
1459+
if (Arg *A = Args.getLastArg(OPT_copy_propagation_state_EQ)) {
1460+
specifiedCopyPropagationOption =
1461+
llvm::StringSwitch<Optional<CopyPropagationOption>>(A->getValue())
1462+
.Case("true", CopyPropagationOption::On)
1463+
.Case("false", CopyPropagationOption::Off)
1464+
.Case("requested-passes-only",
1465+
CopyPropagationOption::RequestedPassesOnly)
1466+
.Default(None);
1467+
}
1468+
if (Args.hasArg(OPT_enable_copy_propagation)) {
1469+
if (specifiedCopyPropagationOption) {
1470+
if (*specifiedCopyPropagationOption == CopyPropagationOption::Off) {
1471+
// Error if copy propagation has been set to ::Off via the meta-var form
1472+
// and enabled via the flag.
1473+
Diags.diagnose(SourceLoc(), diag::error_invalid_arg_combination,
1474+
"enable-copy-propagation",
1475+
"enable-copy-propagation=false");
1476+
return true;
1477+
} else if (*specifiedCopyPropagationOption ==
1478+
CopyPropagationOption::RequestedPassesOnly) {
1479+
// Error if copy propagation has been set to ::RequestedPassesOnly via
1480+
// the meta-var form and enabled via the flag.
1481+
Diags.diagnose(SourceLoc(), diag::error_invalid_arg_combination,
1482+
"enable-copy-propagation",
1483+
"enable-copy-propagation=requested-passes-only");
1484+
return true;
1485+
}
1486+
} else {
1487+
specifiedCopyPropagationOption = CopyPropagationOption::On;
1488+
}
1489+
}
1490+
if (specifiedCopyPropagationOption) {
1491+
Opts.CopyPropagation = *specifiedCopyPropagationOption;
1492+
}
1493+
14581494
Optional<bool> enableLexicalBorrowScopesFlag;
14591495
if (Arg *A = Args.getLastArg(OPT_enable_lexical_borrow_scopes)) {
14601496
enableLexicalBorrowScopesFlag =
@@ -1544,24 +1580,6 @@ static bool ParseSILArgs(SILOptions &Opts, ArgList &Args,
15441580
}
15451581
}
15461582

1547-
if (Args.hasArg(OPT_enable_copy_propagation) &&
1548-
Args.hasArg(OPT_disable_copy_propagation)) {
1549-
// Error if copy propagation is enabled and copy propagation is disabled.
1550-
Diags.diagnose(SourceLoc(), diag::error_invalid_arg_combination,
1551-
"enable-copy-propagation", "disable-copy-propagation");
1552-
return true;
1553-
} else if (Args.hasArg(OPT_enable_copy_propagation) &&
1554-
!Args.hasArg(OPT_disable_copy_propagation)) {
1555-
Opts.CopyPropagation = CopyPropagationOption::On;
1556-
} else if (!Args.hasArg(OPT_enable_copy_propagation) &&
1557-
Args.hasArg(OPT_disable_copy_propagation)) {
1558-
Opts.CopyPropagation = CopyPropagationOption::Off;
1559-
} else /*if (!Args.hasArg(OPT_enable_copy_propagation) &&
1560-
!Args.hasArg(OPT_disable_copy_propagation))*/
1561-
{
1562-
Opts.CopyPropagation = CopyPropagationOption::RequestedPassesOnly;
1563-
}
1564-
15651583
Opts.EnableARCOptimizations &= !Args.hasArg(OPT_disable_arc_opts);
15661584
Opts.EnableOSSAModules |= Args.hasArg(OPT_enable_ossa_modules);
15671585
Opts.EnableOSSAOptimizations &= !Args.hasArg(OPT_disable_ossa_opts);

test/DebugInfo/if-branchlocations.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// RUN: %target-swift-frontend %s -emit-sil -disable-copy-propagation -emit-verbose-sil -g -o - | %FileCheck %s --check-prefixes=CHECK,CHECK-NCP
1+
// RUN: %target-swift-frontend %s -emit-sil -enable-copy-propagation=false -emit-verbose-sil -g -o - | %FileCheck %s --check-prefixes=CHECK,CHECK-NCP
22
// RUN: %target-swift-frontend %s -emit-sil -enable-copy-propagation -enable-lexical-borrow-scopes=false -emit-verbose-sil -g -o - | %FileCheck %s --check-prefixes=CHECK,CHECK-CP
33

44
class NSURL {}

test/DebugInfo/linetable-do.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// RUN: %target-swift-frontend -Xllvm -sil-full-demangle %s -emit-ir -g -o - | %FileCheck %s
2-
// RUN: %target-swift-frontend -Xllvm -sil-full-demangle -disable-copy-propagation %s -emit-sil -emit-verbose-sil -g -o - | %FileCheck --check-prefixes=CHECK-SIL,CHECK-NCP %s
2+
// RUN: %target-swift-frontend -Xllvm -sil-full-demangle -enable-copy-propagation=false %s -emit-sil -emit-verbose-sil -g -o - | %FileCheck --check-prefixes=CHECK-SIL,CHECK-NCP %s
33
// RUN: %target-swift-frontend -Xllvm -sil-full-demangle -enable-copy-propagation -enable-lexical-borrow-scopes=false %s -emit-sil -emit-verbose-sil -g -o - | %FileCheck --check-prefixes=CHECK-SIL,CHECK-CP %s
44
import StdlibUnittest
55

test/SILOptimizer/closure_lifetime_fixup.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
// RUN: %empty-directory(%t)
22
// RUN: %target-swift-frontend %S/../Inputs/resilient_struct.swift -enable-library-evolution -emit-module -emit-module-path %t/resilient_struct.swiftmodule
33
// RUN: %target-swift-frontend %S/../Inputs/resilient_enum.swift -I %t -enable-library-evolution -emit-module -emit-module-path %t/resilient_enum.swiftmodule
4-
// RUN: %target-swift-frontend %s -sil-verify-all -emit-sil -disable-copy-propagation -I %t -o - | %FileCheck %s
4+
// RUN: %target-swift-frontend %s -sil-verify-all -emit-sil -enable-copy-propagation=false -I %t -o - | %FileCheck %s
55

6-
// Using -disable-copy-propagation to pattern match against older SIL
6+
// Using -enable-copy-propagation=false to pattern match against older SIL
77
// output. At least until -enable-copy-propagation has been around
88
// long enough in the same form to be worth rewriting CHECK lines.
99

test/SILOptimizer/closure_lifetime_fixup_concurrency.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// RUN: %empty-directory(%t)
2-
// RUN: %target-swift-frontend %s -sil-verify-all -disable-availability-checking -emit-sil -disable-copy-propagation -I %t -o - | %FileCheck %s
2+
// RUN: %target-swift-frontend %s -sil-verify-all -disable-availability-checking -emit-sil -enable-copy-propagation=false -I %t -o - | %FileCheck %s
33
// REQUIRES: concurrency
44

55
// CHECK-LABEL: sil @$s34closure_lifetime_fixup_concurrency12testAsyncLetyS2SYaF : $@convention(thin) @async (@guaranteed String) -> @owned String {

test/SILOptimizer/closure_lifetime_fixup_objc.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
// RUN: %target-swift-frontend %s -sil-verify-all -emit-sil -disable-copy-propagation -o - -I %S/Inputs/usr/include | %FileCheck %s
1+
// RUN: %target-swift-frontend %s -sil-verify-all -emit-sil -enable-copy-propagation=false -o - -I %S/Inputs/usr/include | %FileCheck %s
22
// REQUIRES: objc_interop
33

4-
// Using -disable-copy-propagation to pattern match against older SIL
4+
// Using -enable-copy-propagation=false to pattern match against older SIL
55
// output. At least until -enable-copy-propagation has been around
66
// long enough in the same form to be worth rewriting CHECK lines.
77

test/SILOptimizer/definite-init-convert-to-escape.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
// RUN: %target-swift-frontend -module-name A -verify -emit-sil -import-objc-header %S/Inputs/Closure.h -disable-copy-propagation -disable-objc-attr-requires-foundation-module %s | %FileCheck %s
2-
// RUN: %target-swift-frontend -module-name A -verify -emit-sil -import-objc-header %S/Inputs/Closure.h -disable-copy-propagation -disable-objc-attr-requires-foundation-module -Xllvm -sil-disable-convert-escape-to-noescape-switch-peephole %s | %FileCheck %s --check-prefix=NOPEEPHOLE
1+
// RUN: %target-swift-frontend -module-name A -verify -emit-sil -import-objc-header %S/Inputs/Closure.h -enable-copy-propagation=false -disable-objc-attr-requires-foundation-module %s | %FileCheck %s
2+
// RUN: %target-swift-frontend -module-name A -verify -emit-sil -import-objc-header %S/Inputs/Closure.h -enable-copy-propagation=false -disable-objc-attr-requires-foundation-module -Xllvm -sil-disable-convert-escape-to-noescape-switch-peephole %s | %FileCheck %s --check-prefix=NOPEEPHOLE
33
//
4-
// Using -disable-copy-propagation to pattern match against older SIL
4+
// Using -enable-copy-propagation=false to pattern match against older SIL
55
// output. At least until -enable-copy-propagation has been around
66
// long enough in the same form to be worth rewriting CHECK lines.
77

test/SILOptimizer/definite_init_failable_initializers.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
// RUN: %target-swift-frontend -emit-sil -disable-copy-propagation %s | %FileCheck %s
1+
// RUN: %target-swift-frontend -emit-sil -enable-copy-propagation=false %s | %FileCheck %s
22

3-
// Using -disable-copy-propagation to pattern match against older SIL
3+
// Using -enable-copy-propagation=false to pattern match against older SIL
44
// output. At least until -enable-copy-propagation has been around
55
// long enough in the same form to be worth rewriting CHECK lines.
66

test/SILOptimizer/definite_init_failable_initializers_objc.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
// RUN: %target-swift-frontend -emit-sil -disable-copy-propagation -disable-objc-attr-requires-foundation-module %s | %FileCheck %s
1+
// RUN: %target-swift-frontend -emit-sil -enable-copy-propagation=false -disable-objc-attr-requires-foundation-module %s | %FileCheck %s
22

3-
// Using -disable-copy-propagation to pattern match against older SIL
3+
// Using -enable-copy-propagation=false to pattern match against older SIL
44
// output. At least until -enable-copy-propagation has been around
55
// long enough in the same form to be worth rewriting CHECK lines.
66

0 commit comments

Comments
 (0)