mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
Merge pull request #40555 from nate-chandler/copy_propagation/rename-disabled-flags
Clarified copy-prop/lexical-lifetime flags.
This commit is contained in:
@@ -215,8 +215,10 @@ def dependency_scan_cache_remarks : Flag<["-"], "Rdependency-scan-cache">,
|
||||
def enable_copy_propagation : Flag<["-"], "enable-copy-propagation">,
|
||||
HelpText<"Run SIL copy propagation with lexical lifetimes to shorten object "
|
||||
"lifetimes while preserving variable lifetimes.">;
|
||||
def disable_copy_propagation : Flag<["-"], "disable-copy-propagation">,
|
||||
HelpText<"Don't run SIL copy propagation to preserve object lifetime.">;
|
||||
def copy_propagation_state_EQ :
|
||||
Joined<["-"], "enable-copy-propagation=">,
|
||||
HelpText<"Whether to enable copy propagation">,
|
||||
MetaVarName<"true|requested-passes-only|false">;
|
||||
|
||||
def enable_infer_public_concurrent_value : Flag<["-"], "enable-infer-public-sendable">,
|
||||
HelpText<"Enable inference of Sendable conformances for public structs and enums">;
|
||||
|
||||
@@ -1466,6 +1466,42 @@ static bool ParseSILArgs(SILOptions &Opts, ArgList &Args,
|
||||
// -Ounchecked might also set removal of runtime asserts (cond_fail).
|
||||
Opts.RemoveRuntimeAsserts |= Args.hasArg(OPT_RemoveRuntimeAsserts);
|
||||
|
||||
Optional<CopyPropagationOption> specifiedCopyPropagationOption;
|
||||
if (Arg *A = Args.getLastArg(OPT_copy_propagation_state_EQ)) {
|
||||
specifiedCopyPropagationOption =
|
||||
llvm::StringSwitch<Optional<CopyPropagationOption>>(A->getValue())
|
||||
.Case("true", CopyPropagationOption::On)
|
||||
.Case("false", CopyPropagationOption::Off)
|
||||
.Case("requested-passes-only",
|
||||
CopyPropagationOption::RequestedPassesOnly)
|
||||
.Default(None);
|
||||
}
|
||||
if (Args.hasArg(OPT_enable_copy_propagation)) {
|
||||
if (specifiedCopyPropagationOption) {
|
||||
if (*specifiedCopyPropagationOption == CopyPropagationOption::Off) {
|
||||
// Error if copy propagation has been set to ::Off via the meta-var form
|
||||
// and enabled via the flag.
|
||||
Diags.diagnose(SourceLoc(), diag::error_invalid_arg_combination,
|
||||
"enable-copy-propagation",
|
||||
"enable-copy-propagation=false");
|
||||
return true;
|
||||
} else if (*specifiedCopyPropagationOption ==
|
||||
CopyPropagationOption::RequestedPassesOnly) {
|
||||
// Error if copy propagation has been set to ::RequestedPassesOnly via
|
||||
// the meta-var form and enabled via the flag.
|
||||
Diags.diagnose(SourceLoc(), diag::error_invalid_arg_combination,
|
||||
"enable-copy-propagation",
|
||||
"enable-copy-propagation=requested-passes-only");
|
||||
return true;
|
||||
}
|
||||
} else {
|
||||
specifiedCopyPropagationOption = CopyPropagationOption::On;
|
||||
}
|
||||
}
|
||||
if (specifiedCopyPropagationOption) {
|
||||
Opts.CopyPropagation = *specifiedCopyPropagationOption;
|
||||
}
|
||||
|
||||
Optional<bool> enableLexicalBorrowScopesFlag;
|
||||
if (Arg *A = Args.getLastArg(OPT_enable_lexical_borrow_scopes)) {
|
||||
enableLexicalBorrowScopesFlag =
|
||||
@@ -1525,13 +1561,14 @@ static bool ParseSILArgs(SILOptions &Opts, ArgList &Args,
|
||||
return true;
|
||||
}
|
||||
|
||||
// -enable-copy-propagation implies -enable-lexical-lifetimes unless
|
||||
// otherwise specified.
|
||||
if (Args.hasArg(OPT_enable_copy_propagation))
|
||||
// Unless overridden below, enabling copy propagation means enabling lexical
|
||||
// lifetimes.
|
||||
if (Opts.CopyPropagation == CopyPropagationOption::On)
|
||||
Opts.LexicalLifetimes = LexicalLifetimesOption::On;
|
||||
|
||||
// -disable-copy-propagation implies -enable-lexical-lifetimes=false
|
||||
if (Args.hasArg(OPT_disable_copy_propagation))
|
||||
// Unless overridden below, disable copy propagation means disabling lexical
|
||||
// lifetimes.
|
||||
if (Opts.CopyPropagation == CopyPropagationOption::Off)
|
||||
Opts.LexicalLifetimes = LexicalLifetimesOption::DiagnosticMarkersOnly;
|
||||
|
||||
// If move-only is enabled, always enable lexical lifetime as well. Move-only
|
||||
@@ -1554,24 +1591,6 @@ static bool ParseSILArgs(SILOptions &Opts, ArgList &Args,
|
||||
}
|
||||
}
|
||||
|
||||
if (Args.hasArg(OPT_enable_copy_propagation) &&
|
||||
Args.hasArg(OPT_disable_copy_propagation)) {
|
||||
// Error if copy propagation is enabled and copy propagation is disabled.
|
||||
Diags.diagnose(SourceLoc(), diag::error_invalid_arg_combination,
|
||||
"enable-copy-propagation", "disable-copy-propagation");
|
||||
return true;
|
||||
} else if (Args.hasArg(OPT_enable_copy_propagation) &&
|
||||
!Args.hasArg(OPT_disable_copy_propagation)) {
|
||||
Opts.CopyPropagation = CopyPropagationOption::On;
|
||||
} else if (!Args.hasArg(OPT_enable_copy_propagation) &&
|
||||
Args.hasArg(OPT_disable_copy_propagation)) {
|
||||
Opts.CopyPropagation = CopyPropagationOption::Off;
|
||||
} else /*if (!Args.hasArg(OPT_enable_copy_propagation) &&
|
||||
!Args.hasArg(OPT_disable_copy_propagation))*/
|
||||
{
|
||||
Opts.CopyPropagation = CopyPropagationOption::RequestedPassesOnly;
|
||||
}
|
||||
|
||||
Opts.EnableARCOptimizations &= !Args.hasArg(OPT_disable_arc_opts);
|
||||
Opts.EnableOSSAModules |= Args.hasArg(OPT_enable_ossa_modules);
|
||||
Opts.EnableOSSAOptimizations &= !Args.hasArg(OPT_disable_ossa_opts);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
// RUN: %empty-directory(%t)
|
||||
// RUN: %target-swift-frontend -emit-module-path %t/Test.swiftmodule -emit-sil -o /dev/null -module-name Test %s -sdk "" -import-objc-header %S/Inputs/serialization-sil.h
|
||||
// RUN: %target-swift-frontend -enable-copy-propagation=requested-passes-only -enable-lexical-lifetimes=false -emit-module-path %t/Test.swiftmodule -emit-sil -o /dev/null -module-name Test %s -sdk "" -import-objc-header %S/Inputs/serialization-sil.h
|
||||
// RUN: %target-sil-func-extractor %t/Test.swiftmodule -sil-print-debuginfo -func='$s4Test16testPartialApplyyySoAA_pF' -o - | %FileCheck %s
|
||||
|
||||
// REQUIRES: objc_interop
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
// RUN: %target-swift-frontend %s -emit-ir -g -o - | %FileCheck %s
|
||||
// RUN: %target-swift-frontend %s -emit-sil -g -o - | %FileCheck -check-prefix=CHECK-SIL %s
|
||||
// RUN: %target-swift-frontend -enable-copy-propagation=requested-passes-only -enable-lexical-lifetimes=false %s -emit-ir -g -o - | %FileCheck %s
|
||||
// RUN: %target-swift-frontend -enable-copy-propagation=requested-passes-only -enable-lexical-lifetimes=false %s -emit-sil -g -o - | %FileCheck -check-prefix=CHECK-SIL %s
|
||||
import StdlibUnittest
|
||||
|
||||
// Test that debug info for local variables is preserved by the
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// RUN: %target-swift-frontend %s -emit-sil -disable-copy-propagation -emit-verbose-sil -g -o - | %FileCheck %s --check-prefixes=CHECK,CHECK-NCP
|
||||
// RUN: %target-swift-frontend %s -emit-sil -enable-copy-propagation=false -emit-verbose-sil -g -o - | %FileCheck %s --check-prefixes=CHECK,CHECK-NCP
|
||||
// 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
|
||||
|
||||
class NSURL {}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
// RUN: %target-swift-frontend -Xllvm -sil-full-demangle %s -emit-ir -g -o - | %FileCheck %s
|
||||
// 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
|
||||
// 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
|
||||
// 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
|
||||
import StdlibUnittest
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// RUN: %target-swift-frontend -g -emit-ir %s -o %t.ll
|
||||
// RUN: %target-swift-frontend -enable-copy-propagation=requested-passes-only -enable-lexical-lifetimes=false -g -emit-ir %s -o %t.ll
|
||||
|
||||
// REQUIRES: objc_interop
|
||||
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
// RUN: %empty-directory(%t)
|
||||
// RUN: %target-swift-frontend %s -O -sil-based-debuginfo -Xllvm -sil-print-debuginfo -emit-ir -o %t/out.ir
|
||||
// RUN: %target-swift-frontend -enable-copy-propagation=requested-passes-only -enable-lexical-lifetimes=false %s -O -sil-based-debuginfo -Xllvm -sil-print-debuginfo -emit-ir -o %t/out.ir
|
||||
// RUN: %FileCheck %s < %t/out.ir
|
||||
// RUN: %FileCheck %s --check-prefix=CHECK_OUT_SIL < %t/out.ir.sil_dbg_0.sil
|
||||
|
||||
// Second test: check that we don't crash with multi-threaded IRGen
|
||||
// RUN: %target-swift-frontend -c %s %S/Inputs/testclass.swift -wmo -O -num-threads 1 -sil-based-debuginfo -o %t/sil_based_dbg.o -o %t/testclass.o
|
||||
// RUN: %target-swift-frontend -enable-copy-propagation=requested-passes-only -enable-lexical-lifetimes=false -c %s %S/Inputs/testclass.swift -wmo -O -num-threads 1 -sil-based-debuginfo -o %t/sil_based_dbg.o -o %t/testclass.o
|
||||
|
||||
// CHECK: !DIFile(filename: "{{.+}}sil_based_dbg.swift", directory: "{{.+}}")
|
||||
// CHECK: [[F:![0-9]+]] = !DIFile(filename: "{{.+}}out.ir.sil_dbg_0.sil",
|
||||
@@ -19,10 +19,10 @@ public func testit() {
|
||||
// in sil-based-dbg mode.
|
||||
// To create something like `alloc_stack ..., (name "foo", loc ..., scope 0)...`
|
||||
// as our testing input, we're only running SROA over the input swift code.
|
||||
// RUN: %target-swift-frontend %s -disable-debugger-shadow-copies -emit-sil -g -o %t/stage1.sil
|
||||
// RUN: %target-sil-opt -sil-print-debuginfo -access-marker-elim -sroa %t/stage1.sil -o %t/stage2.sil
|
||||
// RUN: %target-swift-frontend -enable-copy-propagation=requested-passes-only -enable-lexical-lifetimes=false %s -disable-debugger-shadow-copies -emit-sil -g -o %t/stage1.sil
|
||||
// RUN: %target-sil-opt -enable-copy-propagation=requested-passes-only -enable-lexical-lifetimes=false -sil-print-debuginfo -access-marker-elim -sroa %t/stage1.sil -o %t/stage2.sil
|
||||
// The verification shouldn't fail
|
||||
// RUN: %target-swift-frontend %t/stage2.sil -sil-verify-all -sil-based-debuginfo -g -emit-sil -o %t/out.sil
|
||||
// RUN: %target-swift-frontend -enable-copy-propagation=requested-passes-only -enable-lexical-lifetimes=false %t/stage2.sil -sil-verify-all -sil-based-debuginfo -g -emit-sil -o %t/out.sil
|
||||
// RUN: %FileCheck %s --check-prefix=CHECK_DBG_SCOPE < %t/out.sil
|
||||
struct TheStruct {
|
||||
var the_member : Int
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
|
||||
// RUN: %target-swift-emit-sil -parse-stdlib %s | %FileCheck %s
|
||||
// RUN: %target-swift-emit-silgen -parse-stdlib %s | %FileCheck %s -check-prefix=SILGEN
|
||||
// RUN: %target-swift-emit-ir -parse-stdlib %s
|
||||
// RUN: %target-swift-emit-sil -enable-copy-propagation=requested-passes-only -enable-lexical-lifetimes=false -parse-stdlib %s | %FileCheck %s
|
||||
// RUN: %target-swift-emit-silgen -enable-copy-propagation=requested-passes-only -enable-lexical-lifetimes=false -parse-stdlib %s | %FileCheck %s -check-prefix=SILGEN
|
||||
// RUN: %target-swift-emit-ir -enable-copy-propagation=requested-passes-only -enable-lexical-lifetimes=false -parse-stdlib %s
|
||||
|
||||
// This test includes some calls to transparent stdlib functions.
|
||||
// We pattern match for the absence of access markers in the inlined code.
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
// RUN: %target-swift-emit-silgen -module-name moveonly -parse-stdlib %s -disable-access-control -disable-objc-attr-requires-foundation-module -enable-experimental-move-only | %FileCheck %s
|
||||
// RUN: %target-swift-emit-sil -module-name moveonly -parse-stdlib %s -disable-access-control -disable-objc-attr-requires-foundation-module -enable-experimental-move-only | %FileCheck -check-prefix=CHECK-SIL %s
|
||||
// RUN: %target-swift-emit-sil -module-name moveonly -parse-stdlib %s -disable-access-control -disable-objc-attr-requires-foundation-module -O -Xllvm -sil-disable-pass=FunctionSignatureOpts -enable-experimental-move-only | %FileCheck -check-prefix=CHECK-SIL-OPT %s
|
||||
// RUN: %target-swift-emit-silgen -enable-copy-propagation=requested-passes-only -module-name moveonly -parse-stdlib %s -disable-access-control -disable-objc-attr-requires-foundation-module -enable-experimental-move-only | %FileCheck %s
|
||||
// RUN: %target-swift-emit-sil -enable-copy-propagation=requested-passes-only -module-name moveonly -parse-stdlib %s -disable-access-control -disable-objc-attr-requires-foundation-module -enable-experimental-move-only | %FileCheck -check-prefix=CHECK-SIL %s
|
||||
// RUN: %target-swift-emit-sil -enable-copy-propagation=requested-passes-only -module-name moveonly -parse-stdlib %s -disable-access-control -disable-objc-attr-requires-foundation-module -O -Xllvm -sil-disable-pass=FunctionSignatureOpts -enable-experimental-move-only | %FileCheck -check-prefix=CHECK-SIL-OPT %s
|
||||
|
||||
import Swift
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// RUN: %target-swift-frontend -swift-version 5 -emit-sil -primary-file %s -Xllvm -sil-print-after=OSLogOptimization -o /dev/null 2>&1 | %FileCheck %s --check-prefix=CHECK --check-prefix=CHECK-%target-ptrsize
|
||||
// RUN: %target-swift-frontend -enable-copy-propagation=requested-passes-only -enable-lexical-lifetimes=false -swift-version 5 -emit-sil -primary-file %s -Xllvm -sil-print-after=OSLogOptimization -o /dev/null 2>&1 | %FileCheck %s --check-prefix=CHECK --check-prefix=CHECK-%target-ptrsize
|
||||
//
|
||||
// REQUIRES: VENDOR=apple
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// RUN: %target-swift-frontend -module-name access_enforcement_noescape -enforce-exclusivity=checked -Onone -emit-sil -swift-version 4 -parse-as-library %s | %FileCheck %s
|
||||
// RUN: %target-swift-frontend -enable-copy-propagation=requested-passes-only -enable-lexical-lifetimes=false -module-name access_enforcement_noescape -enforce-exclusivity=checked -Onone -emit-sil -swift-version 4 -parse-as-library %s | %FileCheck %s
|
||||
|
||||
// This tests SILGen and AccessEnforcementSelection as a single set of tests.
|
||||
// (Some static/dynamic enforcement selection is done in SILGen, and some is
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// RUN: %target-swift-frontend -module-name access_marker_mandatory -parse-as-library -Xllvm -sil-full-demangle -emit-sil -Onone -enforce-exclusivity=checked %s | %FileCheck %s
|
||||
// RUN: %target-swift-frontend -enable-copy-propagation=requested-passes-only -enable-lexical-lifetimes=false -module-name access_marker_mandatory -parse-as-library -Xllvm -sil-full-demangle -emit-sil -Onone -enforce-exclusivity=checked %s | %FileCheck %s
|
||||
|
||||
public struct S {
|
||||
var i: Int
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// RUN: %target-sil-opt -sil-print-debuginfo -enable-sil-verify-all %s -allocbox-to-stack -enable-lexical-borrow-scopes=false | %FileCheck %s
|
||||
// RUN: %target-sil-opt -sil-print-debuginfo -enable-sil-verify-all %s -allocbox-to-stack -enable-copy-propagation=requested-passes-only -enable-lexical-borrow-scopes=false | %FileCheck %s
|
||||
|
||||
sil_stage raw
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// RUN: %target-sil-opt -enable-sil-verify-all %s -allocbox-to-stack -enable-lexical-borrow-scopes=false | %FileCheck %s
|
||||
// RUN: %target-sil-opt -enable-sil-verify-all %s -allocbox-to-stack -enable-copy-propagation=requested-passes-only -enable-lexical-borrow-scopes=false | %FileCheck %s
|
||||
|
||||
sil_stage raw
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// RUN: %target-sil-opt %s -allocbox-to-stack -sil-deadfuncelim | %FileCheck %s
|
||||
// RUN: %target-sil-opt -enable-copy-propagation=requested-passes-only -enable-lexical-lifetimes=false %s -allocbox-to-stack -sil-deadfuncelim | %FileCheck %s
|
||||
|
||||
sil_stage canonical
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// RUN: %target-swift-frontend -emit-sil %s -O | %FileCheck %s
|
||||
// RUN: %target-swift-frontend -enable-copy-propagation=requested-passes-only -enable-lexical-lifetimes=false -emit-sil %s -O | %FileCheck %s
|
||||
|
||||
|
||||
@_optimize(none)
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// RUN: %target-sil-opt %s -allocbox-to-stack -sil-deadfuncelim | %FileCheck %s
|
||||
// RUN: %target-sil-opt -enable-copy-propagation=requested-passes-only -enable-lexical-lifetimes=false %s -allocbox-to-stack -sil-deadfuncelim | %FileCheck %s
|
||||
|
||||
sil_stage canonical
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// RUN: %target-swift-frontend -emit-sil %s -verify -Osize -o /dev/null -module-name main
|
||||
// RUN: %target-swift-frontend -enable-copy-propagation=requested-passes-only -enable-lexical-borrow-scopes=false -emit-sil %s -verify -Osize -o /dev/null -module-name main
|
||||
//
|
||||
// NOTE: We only emit opt-remarks with -Osize,-O today! -O does drop way more
|
||||
// stuff though, so we test with -Osize.
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// RUN: %target-swiftc_driver -O -Rpass-missed=sil-assembly-vision-remark-gen -Xllvm -sil-disable-pass=FunctionSignatureOpts -emit-sil %s -o /dev/null -Xfrontend -verify
|
||||
// RUN: %target-swiftc_driver -O -Rpass-missed=sil-assembly-vision-remark-gen -Xfrontend -enable-copy-propagation=requested-passes-only -Xfrontend -enable-lexical-lifetimes=false -Xllvm -sil-disable-pass=FunctionSignatureOpts -emit-sil %s -o /dev/null -Xfrontend -verify
|
||||
|
||||
// REQUIRES: optimized_stdlib
|
||||
// REQUIRES: swift_stdlib_no_asserts
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
// RUN: %empty-directory(%t)
|
||||
// RUN: %target-swift-frontend %S/../Inputs/resilient_struct.swift -enable-library-evolution -emit-module -emit-module-path %t/resilient_struct.swiftmodule
|
||||
// RUN: %target-swift-frontend %S/../Inputs/resilient_enum.swift -I %t -enable-library-evolution -emit-module -emit-module-path %t/resilient_enum.swiftmodule
|
||||
// RUN: %target-swift-frontend %s -sil-verify-all -emit-sil -disable-copy-propagation -I %t -o - | %FileCheck %s
|
||||
// RUN: %target-swift-frontend %s -sil-verify-all -emit-sil -enable-copy-propagation=false -I %t -o - | %FileCheck %s
|
||||
|
||||
// Using -disable-copy-propagation to pattern match against older SIL
|
||||
// Using -enable-copy-propagation=false to pattern match against older SIL
|
||||
// output. At least until -enable-copy-propagation has been around
|
||||
// long enough in the same form to be worth rewriting CHECK lines.
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
// RUN: %empty-directory(%t)
|
||||
// RUN: %target-swift-frontend %s -sil-verify-all -disable-availability-checking -emit-sil -disable-copy-propagation -I %t -o - | %FileCheck %s
|
||||
// RUN: %target-swift-frontend %s -sil-verify-all -disable-availability-checking -emit-sil -enable-copy-propagation=false -I %t -o - | %FileCheck %s
|
||||
// REQUIRES: concurrency
|
||||
|
||||
// CHECK-LABEL: sil @$s34closure_lifetime_fixup_concurrency12testAsyncLetyS2SYaF : $@convention(thin) @async (@guaranteed String) -> @owned String {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
// RUN: %target-swift-frontend %s -sil-verify-all -emit-sil -disable-copy-propagation -o - -I %S/Inputs/usr/include | %FileCheck %s
|
||||
// RUN: %target-swift-frontend %s -sil-verify-all -emit-sil -enable-copy-propagation=false -o - -I %S/Inputs/usr/include | %FileCheck %s
|
||||
// REQUIRES: objc_interop
|
||||
|
||||
// Using -disable-copy-propagation to pattern match against older SIL
|
||||
// Using -enable-copy-propagation=false to pattern match against older SIL
|
||||
// output. At least until -enable-copy-propagation has been around
|
||||
// long enough in the same form to be worth rewriting CHECK lines.
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
// 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
|
||||
// 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
|
||||
// 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
|
||||
// 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
|
||||
//
|
||||
// Using -disable-copy-propagation to pattern match against older SIL
|
||||
// Using -enable-copy-propagation=false to pattern match against older SIL
|
||||
// output. At least until -enable-copy-propagation has been around
|
||||
// long enough in the same form to be worth rewriting CHECK lines.
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// RUN: %target-swift-frontend -emit-sil -primary-file %s -o /dev/null -verify
|
||||
// RUN: %target-swift-frontend -enable-copy-propagation=requested-passes-only -emit-sil -primary-file %s -o /dev/null -verify
|
||||
|
||||
import Swift
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
// RUN: %target-swift-frontend -emit-sil -disable-copy-propagation %s | %FileCheck %s
|
||||
// RUN: %target-swift-frontend -emit-sil -enable-copy-propagation=false %s | %FileCheck %s
|
||||
|
||||
// Using -disable-copy-propagation to pattern match against older SIL
|
||||
// Using -enable-copy-propagation=false to pattern match against older SIL
|
||||
// output. At least until -enable-copy-propagation has been around
|
||||
// long enough in the same form to be worth rewriting CHECK lines.
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
// RUN: %target-swift-frontend -emit-sil -disable-copy-propagation -disable-objc-attr-requires-foundation-module %s | %FileCheck %s
|
||||
// RUN: %target-swift-frontend -emit-sil -enable-copy-propagation=false -disable-objc-attr-requires-foundation-module %s | %FileCheck %s
|
||||
|
||||
// Using -disable-copy-propagation to pattern match against older SIL
|
||||
// Using -enable-copy-propagation=false to pattern match against older SIL
|
||||
// output. At least until -enable-copy-propagation has been around
|
||||
// long enough in the same form to be worth rewriting CHECK lines.
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
// RUN: %target-swift-frontend(mock-sdk: %clang-importer-sdk) -I %S/../IDE/Inputs/custom-modules %s -emit-sil -disable-copy-propagation | %FileCheck %s
|
||||
// RUN: %target-swift-frontend(mock-sdk: %clang-importer-sdk) -I %S/../IDE/Inputs/custom-modules %s -emit-sil -enable-copy-propagation=false | %FileCheck %s
|
||||
|
||||
// Using -disable-copy-propagation to pattern match against older SIL
|
||||
// Using -enable-copy-propagation=false to pattern match against older SIL
|
||||
// output. At least until -enable-copy-propagation has been around
|
||||
// long enough in the same form to be worth rewriting CHECK lines.
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// RUN: %target-swift-frontend -emit-sil %s -swift-version 5 -verify | %FileCheck %s
|
||||
// RUN: %target-swift-frontend -enable-copy-propagation=requested-passes-only -enable-lexical-lifetimes=false -emit-sil %s -swift-version 5 -verify | %FileCheck %s
|
||||
|
||||
// Ensure that convenience initializers on concrete types can
|
||||
// delegate to factory initializers defined in protocol
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
// RUN: %target-swift-frontend -emit-sil -disable-copy-propagation %s | %FileCheck %s
|
||||
// RUN: %target-swift-frontend -emit-sil -enable-copy-propagation=false %s | %FileCheck %s
|
||||
|
||||
// Using -disable-copy-propagation to pattern match against older SIL
|
||||
// Using -enable-copy-propagation=false to pattern match against older SIL
|
||||
// output. At least until -enable-copy-propagation has been around
|
||||
// long enough in the same form to be worth rewriting CHECK lines.
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// RUN: %target-swift-frontend -emit-sil %s | %FileCheck %s
|
||||
// RUN: %target-swift-frontend -enable-copy-propagation=requested-passes-only -enable-lexical-lifetimes=false -emit-sil %s | %FileCheck %s
|
||||
|
||||
enum ValueEnum {
|
||||
case a(String)
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// RUN: %target-sil-opt -sil-lexical-lifetime-eliminator %s -enable-sil-verify-all | %FileCheck %s
|
||||
// RUN: %target-sil-opt -enable-copy-propagation=requested-passes-only -enable-lexical-lifetimes=false -sil-lexical-lifetime-eliminator %s -enable-sil-verify-all | %FileCheck %s
|
||||
|
||||
sil_stage raw
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
// RUN: %target-sil-opt -enable-objc-interop -enforce-exclusivity=none -enable-sil-verify-all %s -sil-combine | %FileCheck %s
|
||||
// RUN: %target-sil-opt -enable-objc-interop -enforce-exclusivity=none -enable-sil-verify-all %s -sil-combine -generic-specializer | %FileCheck %s --check-prefix=CHECK_FORWARDING_OWNERSHIP_KIND
|
||||
// RUN: %target-sil-opt -enable-copy-propagation=requested-passes-only -enable-objc-interop -enforce-exclusivity=none -enable-sil-verify-all %s -sil-combine | %FileCheck %s
|
||||
// RUN: %target-sil-opt -enable-copy-propagation=requested-passes-only -enable-objc-interop -enforce-exclusivity=none -enable-sil-verify-all %s -sil-combine -generic-specializer | %FileCheck %s --check-prefix=CHECK_FORWARDING_OWNERSHIP_KIND
|
||||
//
|
||||
// FIXME: check copy-propagation output instead once it is the default mode
|
||||
// RUN: %target-sil-opt -enable-objc-interop -enforce-exclusivity=none -enable-sil-verify-all %s -sil-combine -enable-copy-propagation -enable-lexical-lifetimes=false | %FileCheck %s --check-prefix=CHECK_COPYPROP
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// RUN: %target-sil-opt -enable-sil-verify-all %s -sil-combine -remove-runtime-asserts | %FileCheck %s
|
||||
// RUN: %target-sil-opt -enable-copy-propagation=requested-passes-only -enable-sil-verify-all %s -sil-combine -remove-runtime-asserts | %FileCheck %s
|
||||
|
||||
sil_stage canonical
|
||||
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
// RUN: %empty-directory(%t)
|
||||
// RUN: %target-swift-frontend -disable-availability-checking %S/Inputs/specialize_opaque_type_archetypes_2.swift -module-name External -emit-module -emit-module-path %t/External.swiftmodule
|
||||
// RUN: %target-swift-frontend -disable-availability-checking %S/Inputs/specialize_opaque_type_archetypes_3.swift -enable-library-evolution -module-name External2 -emit-module -emit-module-path %t/External2.swiftmodule
|
||||
// RUN: %target-swift-frontend -disable-availability-checking %S/Inputs/specialize_opaque_type_archetypes_4.swift -I %t -enable-library-evolution -module-name External3 -emit-module -emit-module-path %t/External3.swiftmodule
|
||||
// RUN: %target-swift-frontend -disable-availability-checking %S/Inputs/specialize_opaque_type_archetypes_3.swift -I %t -enable-library-evolution -module-name External2 -Osize -emit-module -o - | %target-sil-opt -module-name External2 | %FileCheck --check-prefix=RESILIENT %s
|
||||
// RUN: %target-swift-frontend -disable-availability-checking -I %t -module-name A -enforce-exclusivity=checked -Osize -emit-sil -sil-verify-all %s | %FileCheck %s --check-prefix=CHECK --check-prefix=CHECK-%target-ptrsize
|
||||
// RUN: %target-swift-frontend -disable-availability-checking -I %t -module-name A -enforce-exclusivity=checked -enable-library-evolution -Osize -emit-sil -sil-verify-all %s | %FileCheck %s --check-prefix=CHECK --check-prefix=CHECK-%target-ptrsize
|
||||
// RUN: %target-swift-frontend -enable-copy-propagation=requested-passes-only -enable-lexical-lifetimes=false -disable-availability-checking %S/Inputs/specialize_opaque_type_archetypes_2.swift -module-name External -emit-module -emit-module-path %t/External.swiftmodule
|
||||
// RUN: %target-swift-frontend -enable-copy-propagation=requested-passes-only -enable-lexical-lifetimes=false -disable-availability-checking %S/Inputs/specialize_opaque_type_archetypes_3.swift -enable-library-evolution -module-name External2 -emit-module -emit-module-path %t/External2.swiftmodule
|
||||
// RUN: %target-swift-frontend -enable-copy-propagation=requested-passes-only -enable-lexical-lifetimes=false -disable-availability-checking %S/Inputs/specialize_opaque_type_archetypes_4.swift -I %t -enable-library-evolution -module-name External3 -emit-module -emit-module-path %t/External3.swiftmodule
|
||||
// RUN: %target-swift-frontend -enable-copy-propagation=requested-passes-only -enable-lexical-lifetimes=false -disable-availability-checking %S/Inputs/specialize_opaque_type_archetypes_3.swift -I %t -enable-library-evolution -module-name External2 -Osize -emit-module -o - | %target-sil-opt -module-name External2 | %FileCheck --check-prefix=RESILIENT %s
|
||||
// RUN: %target-swift-frontend -enable-copy-propagation=requested-passes-only -enable-lexical-lifetimes=false -disable-availability-checking -I %t -module-name A -enforce-exclusivity=checked -Osize -emit-sil -sil-verify-all %s | %FileCheck %s --check-prefix=CHECK --check-prefix=CHECK-%target-ptrsize
|
||||
// RUN: %target-swift-frontend -enable-copy-propagation=requested-passes-only -enable-lexical-lifetimes=false -disable-availability-checking -I %t -module-name A -enforce-exclusivity=checked -enable-library-evolution -Osize -emit-sil -sil-verify-all %s | %FileCheck %s --check-prefix=CHECK --check-prefix=CHECK-%target-ptrsize
|
||||
|
||||
|
||||
import External
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// RUN: %target-swift-frontend -sdk %S/Inputs -O -emit-sil -I %S/Inputs -enable-source-import -primary-file %s | %FileCheck %s
|
||||
// RUN: %target-swift-frontend -enable-copy-propagation=requested-passes-only -enable-lexical-lifetimes=false -sdk %S/Inputs -O -emit-sil -I %S/Inputs -enable-source-import -primary-file %s | %FileCheck %s
|
||||
|
||||
import gizmo
|
||||
|
||||
|
||||
@@ -58,6 +58,18 @@ enum class OptGroup {
|
||||
Lowering
|
||||
};
|
||||
|
||||
Optional<bool> toOptionalBool(llvm::cl::boolOrDefault defaultable) {
|
||||
switch (defaultable) {
|
||||
case llvm::cl::BOU_TRUE:
|
||||
return true;
|
||||
case llvm::cl::BOU_FALSE:
|
||||
return false;
|
||||
case llvm::cl::BOU_UNSET:
|
||||
return None;
|
||||
}
|
||||
llvm_unreachable("Bad case for llvm::cl::boolOrDefault!");
|
||||
}
|
||||
|
||||
} // end anonymous namespace
|
||||
|
||||
static llvm::cl::opt<std::string>
|
||||
@@ -105,19 +117,19 @@ static llvm::cl::opt<bool>
|
||||
EnableExperimentalConcurrency("enable-experimental-concurrency",
|
||||
llvm::cl::desc("Enable experimental concurrency model."));
|
||||
|
||||
static llvm::cl::opt<bool> EnableLexicalLifetimes(
|
||||
"enable-lexical-lifetimes", llvm::cl::init(false),
|
||||
static llvm::cl::opt<llvm::cl::boolOrDefault> EnableLexicalLifetimes(
|
||||
"enable-lexical-lifetimes", llvm::cl::init(llvm::cl::BOU_UNSET),
|
||||
llvm::cl::desc("Enable lexical lifetimes. Mutually exclusive with "
|
||||
"enable-lexical-borrow-scopes and "
|
||||
"disable-lexical-lifetimes."));
|
||||
|
||||
static llvm::cl::opt<bool>
|
||||
static llvm::cl::opt<llvm::cl::boolOrDefault>
|
||||
EnableLexicalBorrowScopes("enable-lexical-borrow-scopes",
|
||||
llvm::cl::init(true),
|
||||
llvm::cl::init(llvm::cl::BOU_UNSET),
|
||||
llvm::cl::desc("Enable lexical borrow scopes."));
|
||||
|
||||
static llvm::cl::opt<bool>
|
||||
EnableExperimentalMoveOnly("enable-experimental-move-only",
|
||||
static llvm::cl::opt<llvm::cl::boolOrDefault> EnableExperimentalMoveOnly(
|
||||
"enable-experimental-move-only", llvm::cl::init(llvm::cl::BOU_UNSET),
|
||||
llvm::cl::desc("Enable experimental distributed actors."));
|
||||
|
||||
static llvm::cl::opt<bool>
|
||||
@@ -138,13 +150,97 @@ static llvm::cl::opt<bool> EnableOSSAModules(
|
||||
"this is disabled we do not serialize in OSSA "
|
||||
"form when optimizing."));
|
||||
|
||||
static llvm::cl::opt<bool>
|
||||
EnableCopyPropagation("enable-copy-propagation", llvm::cl::init(false),
|
||||
llvm::cl::desc("Enable the copy propagation pass."));
|
||||
namespace llvm {
|
||||
|
||||
static llvm::cl::opt<bool> DisableCopyPropagation(
|
||||
"disable-copy-propagation", llvm::cl::init(false),
|
||||
llvm::cl::desc("Disable the copy propagation pass."));
|
||||
inline raw_ostream &operator<<(raw_ostream &os,
|
||||
const Optional<CopyPropagationOption> option) {
|
||||
if (option) {
|
||||
switch (*option) {
|
||||
case CopyPropagationOption::Off:
|
||||
os << "off";
|
||||
break;
|
||||
case CopyPropagationOption::RequestedPassesOnly:
|
||||
os << "requested-passes-only";
|
||||
break;
|
||||
case CopyPropagationOption::On:
|
||||
os << "on";
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
os << "<none>";
|
||||
}
|
||||
return os;
|
||||
}
|
||||
|
||||
namespace cl {
|
||||
template <>
|
||||
class parser<::Optional<CopyPropagationOption>>
|
||||
: public basic_parser<::Optional<CopyPropagationOption>> {
|
||||
public:
|
||||
parser(Option &O) : basic_parser<::Optional<CopyPropagationOption>>(O) {}
|
||||
|
||||
// parse - Return true on error.
|
||||
bool parse(Option &O, StringRef ArgName, StringRef Arg,
|
||||
::Optional<CopyPropagationOption> &Value) {
|
||||
if (Arg == "" || Arg == "true" || Arg == "TRUE" || Arg == "True" ||
|
||||
Arg == "1") {
|
||||
Value = CopyPropagationOption::On;
|
||||
return false;
|
||||
}
|
||||
if (Arg == "false" || Arg == "FALSE" || Arg == "False" || Arg == "0") {
|
||||
Value = CopyPropagationOption::Off;
|
||||
return false;
|
||||
}
|
||||
if (Arg == "requested-passes-only" || Arg == "REQUESTED-PASSES-ONLY" ||
|
||||
Arg == "Requested-Passes-Only") {
|
||||
Value = CopyPropagationOption::RequestedPassesOnly;
|
||||
return false;
|
||||
}
|
||||
|
||||
return O.error("'" + Arg +
|
||||
"' is invalid for CopyPropagationOption! Try true, false, "
|
||||
"or requested-passes-only.");
|
||||
}
|
||||
|
||||
void initialize() {}
|
||||
|
||||
enum ValueExpected getValueExpectedFlagDefault() const {
|
||||
return ValueOptional;
|
||||
}
|
||||
|
||||
StringRef getValueName() const override { return "CopyPropagationOption"; }
|
||||
|
||||
// Instantiate the macro PRINT_OPT_DIFF of llvm_project's CommandLine.cpp at
|
||||
// ::Optional<CopyPropagationOption>.
|
||||
void printOptionDiff(const Option &O, ::Optional<CopyPropagationOption> V,
|
||||
OptionValue<::Optional<CopyPropagationOption>> D,
|
||||
size_t GlobalWidth) const {
|
||||
size_t MaxOptWidth = 8;
|
||||
printOptionName(O, GlobalWidth);
|
||||
std::string Str;
|
||||
{
|
||||
raw_string_ostream SS(Str);
|
||||
SS << V;
|
||||
}
|
||||
outs() << "= " << Str;
|
||||
size_t NumSpaces = MaxOptWidth > Str.size() ? MaxOptWidth - Str.size() : 0;
|
||||
outs().indent(NumSpaces) << " (default:";
|
||||
if (D.hasValue())
|
||||
outs() << D.getValue();
|
||||
else
|
||||
outs() << "*no default*";
|
||||
outs() << ")\n";
|
||||
}
|
||||
};
|
||||
} // end namespace cl
|
||||
} // end namespace llvm
|
||||
|
||||
static llvm::cl::opt<Optional<CopyPropagationOption>, /*ExternalStorage*/ false,
|
||||
llvm::cl::parser<Optional<CopyPropagationOption>>>
|
||||
CopyPropagationState(
|
||||
"enable-copy-propagation",
|
||||
llvm::cl::desc("Whether to run the copy propagation pass: "
|
||||
"'true', 'false', or 'requested-passes-only'."));
|
||||
|
||||
namespace {
|
||||
enum class EnforceExclusivityMode {
|
||||
@@ -455,8 +551,11 @@ int main(int argc, char **argv) {
|
||||
EnableExperimentalConcurrency;
|
||||
Invocation.getLangOptions().EnableExperimentalDistributed =
|
||||
EnableExperimentalDistributed;
|
||||
Optional<bool> enableExperimentalMoveOnly =
|
||||
toOptionalBool(EnableExperimentalMoveOnly);
|
||||
if (enableExperimentalMoveOnly)
|
||||
Invocation.getLangOptions().EnableExperimentalMoveOnly =
|
||||
EnableExperimentalMoveOnly;
|
||||
*enableExperimentalMoveOnly;
|
||||
|
||||
Invocation.getLangOptions().EnableObjCInterop =
|
||||
EnableObjCInterop ? true :
|
||||
@@ -542,29 +641,33 @@ int main(int argc, char **argv) {
|
||||
SILOpts.IgnoreAlwaysInline = IgnoreAlwaysInline;
|
||||
SILOpts.EnableOSSAModules = EnableOSSAModules;
|
||||
|
||||
if (EnableCopyPropagation && DisableCopyPropagation) {
|
||||
fprintf(stderr, "Error! Cannot specify both -enable-copy-propagation "
|
||||
"and -disable-copy-propagation.");
|
||||
exit(-1);
|
||||
} else if (EnableCopyPropagation && !DisableCopyPropagation) {
|
||||
SILOpts.CopyPropagation = CopyPropagationOption::On;
|
||||
} else if (!EnableCopyPropagation && DisableCopyPropagation) {
|
||||
SILOpts.CopyPropagation = CopyPropagationOption::Off;
|
||||
} else /*if (!EnableCopyPropagation && !DisableCopyPropagation)*/ {
|
||||
SILOpts.CopyPropagation = CopyPropagationOption::RequestedPassesOnly;
|
||||
if (CopyPropagationState) {
|
||||
SILOpts.CopyPropagation = *CopyPropagationState;
|
||||
}
|
||||
|
||||
if (EnableCopyPropagation)
|
||||
// Unless overridden below, enabling copy propagation means enabling lexical
|
||||
// lifetimes.
|
||||
if (SILOpts.CopyPropagation == CopyPropagationOption::On)
|
||||
SILOpts.LexicalLifetimes = LexicalLifetimesOption::On;
|
||||
if (DisableCopyPropagation)
|
||||
|
||||
// Unless overridden below, disable copy propagation means disabling lexical
|
||||
// lifetimes.
|
||||
if (SILOpts.CopyPropagation == CopyPropagationOption::Off)
|
||||
SILOpts.LexicalLifetimes = LexicalLifetimesOption::DiagnosticMarkersOnly;
|
||||
|
||||
Optional<bool> enableLexicalLifetimes =
|
||||
toOptionalBool(EnableLexicalLifetimes);
|
||||
Optional<bool> enableLexicalBorrowScopes =
|
||||
toOptionalBool(EnableLexicalBorrowScopes);
|
||||
|
||||
// Enable lexical lifetimes if it is set or if experimental move only is
|
||||
// enabled. This is because move only depends on lexical lifetimes being
|
||||
// enabled and it saved some typing ; ).
|
||||
bool enableLexicalLifetimes =
|
||||
EnableLexicalLifetimes | EnableExperimentalMoveOnly;
|
||||
if (enableLexicalLifetimes && !EnableLexicalBorrowScopes) {
|
||||
bool specifiedLexicalLifetimesEnabled =
|
||||
enableExperimentalMoveOnly && *enableExperimentalMoveOnly &&
|
||||
enableLexicalLifetimes && *enableLexicalLifetimes;
|
||||
if (specifiedLexicalLifetimesEnabled && enableLexicalBorrowScopes &&
|
||||
!*enableLexicalBorrowScopes) {
|
||||
fprintf(
|
||||
stderr,
|
||||
"Error! Cannot specify both -enable-lexical-borrow-scopes=false and "
|
||||
@@ -572,9 +675,14 @@ int main(int argc, char **argv) {
|
||||
exit(-1);
|
||||
}
|
||||
if (enableLexicalLifetimes)
|
||||
SILOpts.LexicalLifetimes = LexicalLifetimesOption::On;
|
||||
if (!EnableLexicalBorrowScopes)
|
||||
SILOpts.LexicalLifetimes = LexicalLifetimesOption::Off;
|
||||
SILOpts.LexicalLifetimes =
|
||||
*enableLexicalLifetimes ? LexicalLifetimesOption::On
|
||||
: LexicalLifetimesOption::DiagnosticMarkersOnly;
|
||||
if (enableLexicalBorrowScopes)
|
||||
SILOpts.LexicalLifetimes =
|
||||
*enableLexicalBorrowScopes
|
||||
? LexicalLifetimesOption::DiagnosticMarkersOnly
|
||||
: LexicalLifetimesOption::Off;
|
||||
|
||||
if (OptModeFlag == OptimizationMode::NotSet) {
|
||||
if (OptimizationGroup == OptGroup::Diagnostics)
|
||||
|
||||
Reference in New Issue
Block a user