Skip to content

Commit 9091c25

Browse files
authored
Merge pull request #15518 from gottesmm/pr-427eb030e4c19656fe3cd88e226898db29a4076f
Replace -enable-guaranteed-normal-arguments with -disable-guaranteed-…
2 parents def71e0 + 0bc86e0 commit 9091c25

11 files changed

+34
-21
lines changed

cmake/modules/AddSwift.cmake

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -333,8 +333,8 @@ function(_add_variant_swift_compile_flags
333333
list(APPEND result "-D" "INTERNAL_CHECKS_ENABLED")
334334
endif()
335335

336-
if (SWIFT_ENABLE_GUARANTEED_NORMAL_ARGUMENTS)
337-
list(APPEND result "-Xfrontend" "-enable-guaranteed-normal-arguments")
336+
if (NOT SWIFT_ENABLE_GUARANTEED_NORMAL_ARGUMENTS)
337+
list(APPEND result "-Xfrontend" "-disable-guaranteed-normal-arguments")
338338
endif()
339339

340340
if(SWIFT_ENABLE_RUNTIME_FUNCTION_COUNTERS)

include/swift/Option/FrontendOptions.td

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -264,8 +264,8 @@ def pch_disable_validation : Flag<["-"], "pch-disable-validation">,
264264
def enable_sil_ownership : Flag<["-"], "enable-sil-ownership">,
265265
HelpText<"Enable the SIL Ownership Model">;
266266

267-
def enable_guaranteed_normal_arguments : Flag<["-"], "enable-guaranteed-normal-arguments">,
268-
HelpText<"If set to true, all normal parameters (except to inits/setters) will be passed at +0">;
267+
def disable_guaranteed_normal_arguments : Flag<["-"], "disable-guaranteed-normal-arguments">,
268+
HelpText<"If set to true, all normal parameters (except to inits/setters) will be passed at +1">;
269269

270270
def disable_mandatory_semantic_arc_opts : Flag<["-"], "disable-mandatory-semantic-arc-opts">,
271271
HelpText<"Disable the mandatory semantic arc optimizer">;

lib/Frontend/CompilerInvocation.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -673,8 +673,8 @@ static bool ParseSILArgs(SILOptions &Opts, ArgList &Args,
673673
Opts.EnableMandatorySemanticARCOpts |=
674674
!Args.hasArg(OPT_disable_mandatory_semantic_arc_opts);
675675
Opts.EnableLargeLoadableTypes |= Args.hasArg(OPT_enable_large_loadable_types);
676-
Opts.EnableGuaranteedNormalArguments |=
677-
Args.hasArg(OPT_enable_guaranteed_normal_arguments);
676+
Opts.EnableGuaranteedNormalArguments &=
677+
!Args.hasArg(OPT_disable_guaranteed_normal_arguments);
678678

679679
if (const Arg *A = Args.getLastArg(OPT_save_optimization_record_path))
680680
Opts.OptRecordFile = A->getValue();
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
// RUN: %target-swift-frontend -disable-guaranteed-normal-arguments -module-name Swift -emit-silgen %s
2+
3+
class Klass {}
4+
5+
// CHECK-LABEL: sil hidden @$S4main3fooyyAA5KlassCF : $@convention(thin) (@owned Klass) -> () {
6+
func foo(_ k: Klass) {}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
// RUN: %target-swift-frontend -module-name Swift -emit-silgen %s
2+
3+
class Klass {}
4+
5+
// CHECK-LABEL: sil hidden @$S4main3fooyyAA5KlassCF : $@convention(thin) (@guaranteed Klass) -> () {
6+
func foo(_ k: Klass) {}
7+

test/SILGen/guaranteed_normal_args.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11

2-
// RUN: %target-swift-frontend -parse-as-library -module-name Swift -parse-stdlib -emit-silgen -enable-sil-ownership -enable-guaranteed-normal-arguments %s | %FileCheck %s
2+
// RUN: %target-swift-frontend -parse-as-library -module-name Swift -parse-stdlib -emit-silgen -enable-sil-ownership %s | %FileCheck %s
33

44
// This test checks specific codegen related to normal arguments being passed at
55
// +0. Eventually, it should be merged into normal SILGen tests.

test/SILGen/guaranteed_normal_args_curry_thunks.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// RUN: %target-swift-frontend -parse-as-library -module-name Swift -parse-stdlib -emit-silgen -enable-sil-ownership -enable-guaranteed-normal-arguments %s | %FileCheck %s
1+
// RUN: %target-swift-frontend -parse-as-library -module-name Swift -parse-stdlib -emit-silgen -enable-sil-ownership %s | %FileCheck %s
22

33
// This test checks specific codegen related to converting curry thunks to
44
// canonical representations when we are emitting guaranteed normal

test/SILGen/owned.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// RUN: %target-swift-frontend -Xllvm -sil-full-demangle -emit-silgen %s -disable-objc-attr-requires-foundation-module -enable-sil-ownership -enable-guaranteed-normal-arguments | %FileCheck %s
1+
// RUN: %target-swift-frontend -Xllvm -sil-full-demangle -emit-silgen %s -disable-objc-attr-requires-foundation-module -enable-sil-ownership | %FileCheck %s
22

33
// see shared.swift for thunks/conversions between __shared and __owned.
44

test/sil-opt/guaranteed-normal-args-negative.sil

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// RUN: %empty-directory(%t)
2-
// RUN: %target-swift-frontend %S/Inputs/guaranteed-normal-args.swift -o %t/TestModule.swiftmodule -emit-module -module-name TestModule
3-
// RUN: not --crash %target-sil-opt %s -I=%t -enable-guaranteed-normal-arguments
2+
// RUN: %target-swift-frontend %S/Inputs/guaranteed-normal-args.swift -o %t/TestModule.swiftmodule -emit-module -disable-guaranteed-normal-arguments -module-name TestModule
3+
// RUN: not --crash %target-sil-opt %s -disable-guaranteed-normal-arguments -I=%t
44

55
// This is a negative test
66

@@ -14,4 +14,4 @@ bb0(%0 : $Foo):
1414
destroy_value %0 : $Foo
1515
%9999 = tuple()
1616
return %9999 : $()
17-
}
17+
}

test/sil-opt/guaranteed-normal-args-positive.sil

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// RUN: %empty-directory(%t)
2-
// RUN: %target-swift-frontend %S/Inputs/guaranteed-normal-args.swift -o %t/TestModule.swiftmodule -emit-module -module-name TestModule -enable-guaranteed-normal-arguments
3-
// RUN: %target-sil-opt %s -I=%t -enable-guaranteed-normal-arguments
2+
// RUN: %target-swift-frontend %S/Inputs/guaranteed-normal-args.swift -o %t/TestModule.swiftmodule -emit-module -module-name TestModule
3+
// RUN: %target-sil-opt %s -I=%t
44

55
// This is a positive test
66

@@ -14,4 +14,4 @@ bb0(%0 : $Foo):
1414
destroy_value %0 : $Foo
1515
%9999 = tuple()
1616
return %9999 : $()
17-
}
17+
}

tools/sil-opt/SILOpt.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -200,10 +200,11 @@ AssumeUnqualifiedOwnershipWhenParsing(
200200
"assume-parsing-unqualified-ownership-sil", llvm::cl::Hidden, llvm::cl::init(false),
201201
llvm::cl::desc("Assume all parsed functions have unqualified ownership"));
202202

203-
static llvm::cl::opt<bool>
204-
EnableGuaranteedNormalArguments(
205-
"enable-guaranteed-normal-arguments", llvm::cl::Hidden, llvm::cl::init(false),
206-
llvm::cl::desc("Assume that the input module was compiled with -enable-guaranteed-normal-arguments enabled"));
203+
static llvm::cl::opt<bool> DisableGuaranteedNormalArguments(
204+
"disable-guaranteed-normal-arguments", llvm::cl::Hidden,
205+
llvm::cl::init(false),
206+
llvm::cl::desc("Assume that the input module was compiled with "
207+
"-disable-guaranteed-normal-arguments enabled"));
207208

208209
/// Regular expression corresponding to the value given in one of the
209210
/// -pass-remarks* command line flags. Passes whose name matches this regexp
@@ -326,8 +327,7 @@ int main(int argc, char **argv) {
326327
SILOpts.EnableSILOwnership = EnableSILOwnershipOpt;
327328
SILOpts.AssumeUnqualifiedOwnershipWhenParsing =
328329
AssumeUnqualifiedOwnershipWhenParsing;
329-
SILOpts.EnableGuaranteedNormalArguments |=
330-
EnableGuaranteedNormalArguments;
330+
SILOpts.EnableGuaranteedNormalArguments &= !DisableGuaranteedNormalArguments;
331331

332332
SILOpts.VerifyExclusivity = VerifyExclusivity;
333333
if (EnforceExclusivity.getNumOccurrences() != 0) {

0 commit comments

Comments
 (0)