Skip to content

Commit 97d0756

Browse files
committed
Merge pull request #1295 from rudkx/assert-config
Minor clean-up of -assert-config option handling.
2 parents 73df70e + bd30572 commit 97d0756

File tree

6 files changed

+21
-20
lines changed

6 files changed

+21
-20
lines changed

docs/SIL.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4392,7 +4392,7 @@ The compiler flag that influences the value of the ``assert_configuration``
43924392
function application is the optimization flag: at ``-Onone` the application will
43934393
be replaced by ``Debug`` at higher optimization levels the instruction will be
43944394
replaced by ``Release``. Optionally, the value to use for replacement can be
4395-
specified with the ``-AssertConf`` flag which overwrites the value selected by
4395+
specified with the ``-assert-config`` flag which overwrites the value selected by
43964396
the optimization flag (possible values are ``Debug``, ``Release``,
43974397
``DisableReplacement``).
43984398

include/swift/AST/SILOptions.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -75,9 +75,9 @@ class SILOptions {
7575
enum AssertConfiguration: unsigned {
7676
// Used by standard library code to distinguish between a debug and release
7777
// build.
78-
Debug = 0, // Enables all asserts.
79-
Release = 1, // Disables asserts.
80-
Fast = 2, // Disables asserts, library precondition, and runtime checks.
78+
Debug = 0, // Enables all asserts.
79+
Release = 1, // Disables asserts.
80+
Unchecked = 2, // Disables asserts, preconditions, and runtime checks.
8181

8282
// Leave the assert_configuration instruction around.
8383
DisableReplacement = UINT_MAX

include/swift/Option/Options.td

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -290,7 +290,7 @@ def gline_tables_only : Flag<["-"], "gline-tables-only">,
290290
def AssertConfig : Separate<["-"], "assert-config">,
291291
Flags<[FrontendOption]>,
292292
HelpText<"Specify the assert_configuration replacement. "
293-
"Possible values are Debug, Release, Replacement.">;
293+
"Possible values are Debug, Release, Unchecked, DisableReplacement.">;
294294

295295
// File types
296296

lib/Frontend/CompilerInvocation.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -988,7 +988,7 @@ static bool ParseSILArgs(SILOptions &Opts, ArgList &Args,
988988
Opts.Optimization = SILOptions::SILOptMode::OptimizeUnchecked;
989989
// Removal of cond_fail (overflow on binary operations).
990990
Opts.RemoveRuntimeAsserts = true;
991-
Opts.AssertConfig = SILOptions::Fast;
991+
Opts.AssertConfig = SILOptions::Unchecked;
992992
} else if (A->getOption().matches(OPT_Oplayground)) {
993993
// For now -Oplayground is equivalent to -Onone.
994994
IRGenOpts.Optimize = false;
@@ -1009,8 +1009,8 @@ static bool ParseSILArgs(SILOptions &Opts, ArgList &Args,
10091009
Opts.AssertConfig = SILOptions::Debug;
10101010
} else if (Configuration == "Release") {
10111011
Opts.AssertConfig = SILOptions::Release;
1012-
} else if (Configuration == "Fast") {
1013-
Opts.AssertConfig = SILOptions::Fast;
1012+
} else if (Configuration == "Unchecked") {
1013+
Opts.AssertConfig = SILOptions::Unchecked;
10141014
} else {
10151015
Diags.diagnose(SourceLoc(), diag::error_invalid_arg_value,
10161016
A->getAsString(Args), A->getValue());

test/Driver/options.swift

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -39,20 +39,17 @@
3939
// RUN: %swift_driver -assert-config Debug -### | FileCheck -check-prefix=ASSERTCONFIG %s
4040
// ASSERTCONFIG: -assert-config Debug
4141

42-
// RUN: %swiftc_driver -assert-config Debug -### %s | FileCheck -check-prefix=ASSERTCONFIG2 %s
43-
// ASSERTCONFIG2: -assert-config Debug
42+
// RUN: %swiftc_driver -assert-config Release -### %s | FileCheck -check-prefix=ASSERTCONFIG_RELEASE %s
43+
// RUN: %swift_driver -assert-config Release -### %s | FileCheck -check-prefix=ASSERTCONFIG_RELEASE %s
44+
// ASSERTCONFIG_RELEASE: -assert-config Release
4445

45-
// RUN: %swiftc_driver -assert-config Release -### %s | FileCheck -check-prefix=ASSERTCONFIG3 %s
46-
// ASSERTCONFIG3: -assert-config Release
46+
// RUN: %swiftc_driver -assert-config Unchecked -### %s | FileCheck -check-prefix=ASSERTCONFIG_UNCHECKED %s
47+
// RUN: %swift_driver -assert-config Unchecked -### %s | FileCheck -check-prefix=ASSERTCONFIG_UNCHECKED %s
48+
// ASSERTCONFIG_UNCHECKED: -assert-config Unchecked
4749

48-
// RUN: %swiftc_driver -assert-config Release -### %s | FileCheck -check-prefix=ASSERTCONFIG4 %s
49-
// ASSERTCONFIG4: -assert-config Release
50-
51-
// RUN: %swiftc_driver -assert-config DisableReplacement -### %s | FileCheck -check-prefix=ASSERTCONFIG5 %s
52-
// ASSERTCONFIG5: -assert-config DisableReplacement
53-
54-
// RUN: %swiftc_driver -assert-config DisableReplacement -### %s | FileCheck -check-prefix=ASSERTCONFIG6 %s
55-
// ASSERTCONFIG6: -assert-config DisableReplacement
50+
// RUN: %swiftc_driver -assert-config DisableReplacement -### %s | FileCheck -check-prefix=ASSERTCONFIG_DISABLEREPLACEMENT %s
51+
// RUN: %swift_driver -assert-config DisableReplacement -### %s | FileCheck -check-prefix=ASSERTCONFIG_DISABLEREPLACEMENT %s
52+
// ASSERTCONFIG_DISABLEREPLACEMENT: -assert-config DisableReplacement
5653

5754
// RUN: not %swiftc_driver -import-objc-header fake.h -import-underlying-module -c %s 2>&1 | FileCheck -check-prefix=FRAMEWORK_BRIDGING_HEADER %s
5855
// FRAMEWORK_BRIDGING_HEADER: error: using bridging headers with framework targets is unsupported

test/IRGen/assert_conf_default.sil

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
// RUN: %target-swift-frontend -assert-config DisableReplacement -emit-ir %s | FileCheck %s --check-prefix=DISABLED
22
// RUN: %target-swift-frontend -assert-config Release -emit-ir %s | FileCheck %s --check-prefix=RELEASE
33
// RUN: %target-swift-frontend -assert-config Debug -emit-ir %s | FileCheck %s --check-prefix=DEBUG
4+
// RUN: %target-swift-frontend -assert-config Unchecked -emit-ir %s | FileCheck %s --check-prefix=UNCHECKED
45

56
import Builtin
67

@@ -17,3 +18,6 @@ sil @remove_assert_configuration : $@convention(thin) () -> Builtin.Int32 {
1718

1819
// RELEASE-LABEL: @remove_assert_configuration
1920
// RELEASE: ret i32 1
21+
22+
// UNCHECKED-LABEL: @remove_assert_configuration
23+
// UNCHECKED: ret i32 2

0 commit comments

Comments
 (0)