mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
Add support for -Oplayground and add some sanity tests for it.
Right now this is just like -Onone. We will add further optimizations as needed. <rdar://problem/19328293> Swift SVN r25377
This commit is contained in:
@@ -247,6 +247,10 @@ def O : Flag<["-"], "O">, Group<O_Group>, Flags<[FrontendOption]>,
|
|||||||
def Ounchecked : Flag<["-"], "Ounchecked">, Group<O_Group>,
|
def Ounchecked : Flag<["-"], "Ounchecked">, Group<O_Group>,
|
||||||
Flags<[FrontendOption]>,
|
Flags<[FrontendOption]>,
|
||||||
HelpText<"Compile with optimizations and remove runtime safety checks">;
|
HelpText<"Compile with optimizations and remove runtime safety checks">;
|
||||||
|
def Oplayground : Flag<["-"], "Oplayground">, Group<O_Group>,
|
||||||
|
Flags<[FrontendOption]>,
|
||||||
|
HelpText<"Compile with optimizations appropriate for a playground">;
|
||||||
|
|
||||||
|
|
||||||
// Debug info options
|
// Debug info options
|
||||||
|
|
||||||
|
|||||||
@@ -785,6 +785,9 @@ static bool ParseSILArgs(SILOptions &Opts, ArgList &Args,
|
|||||||
// Removal of cond_fail (overflow on binary operations).
|
// Removal of cond_fail (overflow on binary operations).
|
||||||
Opts.RemoveRuntimeAsserts = true;
|
Opts.RemoveRuntimeAsserts = true;
|
||||||
Opts.AssertConfig = SILOptions::Fast;
|
Opts.AssertConfig = SILOptions::Fast;
|
||||||
|
} else if (A->getOption().matches(OPT_Oplayground)) {
|
||||||
|
// For now -Oplayground is equivalent to -Onone.
|
||||||
|
IRGenOpts.Optimize = false;
|
||||||
} else {
|
} else {
|
||||||
assert(A->getOption().matches(OPT_O));
|
assert(A->getOption().matches(OPT_O));
|
||||||
IRGenOpts.Optimize = true;
|
IRGenOpts.Optimize = true;
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
// RUN: %target-swift-frontend -module-name OptimizationOptions -disable-func-sig-opts -Onone -emit-sil -primary-file %s 2>&1 | FileCheck %s --check-prefix=DEBUG
|
// RUN: %target-swift-frontend -module-name OptimizationOptions -disable-func-sig-opts -Onone -emit-sil -primary-file %s 2>&1 | FileCheck %s --check-prefix=DEBUG
|
||||||
// RUN: %target-swift-frontend -module-name OptimizationOptions -disable-func-sig-opts -O -emit-sil -primary-file %s 2>&1 | FileCheck %s --check-prefix=RELEASE
|
// RUN: %target-swift-frontend -module-name OptimizationOptions -disable-func-sig-opts -O -emit-sil -primary-file %s 2>&1 | FileCheck %s --check-prefix=RELEASE
|
||||||
// RUN: %target-swift-frontend -module-name OptimizationOptions -disable-func-sig-opts -Ounchecked -emit-sil -primary-file %s 2>&1 | FileCheck %s --check-prefix=UNCHECKED
|
// RUN: %target-swift-frontend -module-name OptimizationOptions -disable-func-sig-opts -Ounchecked -emit-sil -primary-file %s 2>&1 | FileCheck %s --check-prefix=UNCHECKED
|
||||||
|
// RUN: %target-swift-frontend -module-name OptimizationOptions -disable-func-sig-opts -Oplayground -emit-sil -primary-file %s 2>&1 | FileCheck %s --check-prefix=PLAYGROUND
|
||||||
|
|
||||||
// REQUIRES: optimized_stdlib
|
// REQUIRES: optimized_stdlib
|
||||||
// REQUIRES: swift_stdlib_asserts
|
// REQUIRES: swift_stdlib_asserts
|
||||||
@@ -34,6 +35,12 @@ func test_partial_safety_check(x: Int, y: Int) -> Int {
|
|||||||
// DEBUG: "assertion failed"
|
// DEBUG: "assertion failed"
|
||||||
// DEBUG: cond_fail
|
// DEBUG: cond_fail
|
||||||
|
|
||||||
|
// In playground mode keep user asserts and runtime checks.
|
||||||
|
// PLAYGROUND-LABEL: _TF19OptimizationOptions11test_assertfT_FT1xSi1ySi_Si
|
||||||
|
// PLAYGROUND: "x smaller than y"
|
||||||
|
// PLAYGROUND: "assertion failed"
|
||||||
|
// PLAYGROUND: cond_fail
|
||||||
|
|
||||||
// In release mode remove user asserts and keep runtime checks.
|
// In release mode remove user asserts and keep runtime checks.
|
||||||
// RELEASE-LABEL: _TF19OptimizationOptions11test_assertfT_FT1xSi1ySi_Si
|
// RELEASE-LABEL: _TF19OptimizationOptions11test_assertfT_FT1xSi1ySi_Si
|
||||||
// RELEASE-NOT: "x smaller than y"
|
// RELEASE-NOT: "x smaller than y"
|
||||||
@@ -54,6 +61,13 @@ func test_partial_safety_check(x: Int, y: Int) -> Int {
|
|||||||
// DEBUG: apply %[[FATAL_ERROR]]{{.*}} @noreturn
|
// DEBUG: apply %[[FATAL_ERROR]]{{.*}} @noreturn
|
||||||
// DEBUG: unreachable
|
// DEBUG: unreachable
|
||||||
|
|
||||||
|
// In playground mode keep verbose fatal errors.
|
||||||
|
// PLAYGROUND-LABEL: _TF19OptimizationOptions10test_fatalFTSiSi_Si
|
||||||
|
// PLAYGROUND-DAG: "Human nature ..."
|
||||||
|
// PLAYGROUND-DAG: %[[FATAL_ERROR:.+]] = function_ref @_TFSs18_fatalErrorMessageFTVSs12StaticStringS_S_Su_T_
|
||||||
|
// PLAYGROUND: apply %[[FATAL_ERROR]]{{.*}} @noreturn
|
||||||
|
// PLAYGROUND: unreachable
|
||||||
|
|
||||||
// In release mode keep succinct fatal errors (trap).
|
// In release mode keep succinct fatal errors (trap).
|
||||||
// RELEASE-LABEL: _TF19OptimizationOptions10test_fatalFTSiSi_Si
|
// RELEASE-LABEL: _TF19OptimizationOptions10test_fatalFTSiSi_Si
|
||||||
// RELEASE-NOT: "Human nature ..."
|
// RELEASE-NOT: "Human nature ..."
|
||||||
@@ -78,6 +92,14 @@ func test_partial_safety_check(x: Int, y: Int) -> Int {
|
|||||||
// DEBUG: unreachable
|
// DEBUG: unreachable
|
||||||
// DEBUG: return
|
// DEBUG: return
|
||||||
|
|
||||||
|
// In playground mode keep verbose library precondition checks.
|
||||||
|
// PLAYGROUND-LABEL: _TF19OptimizationOptions23test_precondition_checkFTSiSi_Si
|
||||||
|
// PLAYGROUND-DAG: "fatal error"
|
||||||
|
// PLAYGROUND-DAG: %[[FATAL_ERROR:.+]] = function_ref @_TFSs18_fatalErrorMessageFTVSs12StaticStringS_S_Su_T_
|
||||||
|
// PLAYGROUND: apply %[[FATAL_ERROR]]{{.*}} @noreturn
|
||||||
|
// PLAYGROUND: unreachable
|
||||||
|
// PLAYGROUND: return
|
||||||
|
|
||||||
// In release mode keep succinct library precondition checks (trap).
|
// In release mode keep succinct library precondition checks (trap).
|
||||||
// RELEASE-LABEL: _TF19OptimizationOptions23test_precondition_checkFTSiSi_Si
|
// RELEASE-LABEL: _TF19OptimizationOptions23test_precondition_checkFTSiSi_Si
|
||||||
// RELEASE-NOT: "fatal error"
|
// RELEASE-NOT: "fatal error"
|
||||||
@@ -101,6 +123,13 @@ func test_partial_safety_check(x: Int, y: Int) -> Int {
|
|||||||
// DEBUG: apply %[[FATAL_ERROR]]{{.*}} @noreturn
|
// DEBUG: apply %[[FATAL_ERROR]]{{.*}} @noreturn
|
||||||
// DEBUG: unreachable
|
// DEBUG: unreachable
|
||||||
|
|
||||||
|
// In playground mode keep verbose partial safety checks.
|
||||||
|
// PLAYGROUND-LABEL: _TF19OptimizationOptions25test_partial_safety_checkFTSiSi_Si
|
||||||
|
// PLAYGROUND-DAG: "fatal error"
|
||||||
|
// PLAYGROUND-DAG: %[[FATAL_ERROR:.+]] = function_ref @_TFSs18_fatalErrorMessageFTVSs12StaticStringS_S_Su_T_
|
||||||
|
// PLAYGROUND: apply %[[FATAL_ERROR]]{{.*}} @noreturn
|
||||||
|
// PLAYGROUND: unreachable
|
||||||
|
|
||||||
// In release mode remove partial safety checks.
|
// In release mode remove partial safety checks.
|
||||||
// RELEASE-LABEL: _TF19OptimizationOptions25test_partial_safety_checkFTSiSi_Si
|
// RELEASE-LABEL: _TF19OptimizationOptions25test_partial_safety_checkFTSiSi_Si
|
||||||
// RELEASE-NOT: "fatal error"
|
// RELEASE-NOT: "fatal error"
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
// RUN: %target-swift-frontend -module-name OptimizationOptions -disable-func-sig-opts -Onone -emit-sil -primary-file %s 2>&1 | FileCheck %s --check-prefix=DEBUG
|
// RUN: %target-swift-frontend -module-name OptimizationOptions -disable-func-sig-opts -Onone -emit-sil -primary-file %s 2>&1 | FileCheck %s --check-prefix=DEBUG
|
||||||
// RUN: %target-swift-frontend -module-name OptimizationOptions -disable-func-sig-opts -O -emit-sil -primary-file %s 2>&1 | FileCheck %s --check-prefix=RELEASE
|
// RUN: %target-swift-frontend -module-name OptimizationOptions -disable-func-sig-opts -O -emit-sil -primary-file %s 2>&1 | FileCheck %s --check-prefix=RELEASE
|
||||||
// RUN: %target-swift-frontend -module-name OptimizationOptions -disable-func-sig-opts -Ounchecked -emit-sil -primary-file %s 2>&1 | FileCheck %s --check-prefix=UNCHECKED
|
// RUN: %target-swift-frontend -module-name OptimizationOptions -disable-func-sig-opts -Ounchecked -emit-sil -primary-file %s 2>&1 | FileCheck %s --check-prefix=UNCHECKED
|
||||||
|
// RUN: %target-swift-frontend -module-name OptimizationOptions -disable-func-sig-opts -Oplayground -emit-sil -primary-file %s 2>&1 | FileCheck %s --check-prefix=PLAYGROUND
|
||||||
|
|
||||||
// REQUIRES: optimized_stdlib
|
// REQUIRES: optimized_stdlib
|
||||||
// REQUIRES: swift_stdlib_asserts
|
// REQUIRES: swift_stdlib_asserts
|
||||||
@@ -34,6 +35,12 @@ func test_partial_safety_check(x: Int, y: Int) -> Int {
|
|||||||
// DEBUG: "assertion failed"
|
// DEBUG: "assertion failed"
|
||||||
// DEBUG: cond_fail
|
// DEBUG: cond_fail
|
||||||
|
|
||||||
|
// In playground mode keep user asserts and runtime checks.
|
||||||
|
// PLAYGROUND-LABEL: _TF19OptimizationOptions11test_assertfT_FT1xSi1ySi_Si
|
||||||
|
// PLAYGROUND: "x smaller than y"
|
||||||
|
// PLAYGROUND: "assertion failed"
|
||||||
|
// PLAYGROUND: cond_fail
|
||||||
|
|
||||||
// In release mode remove user asserts and keep runtime checks.
|
// In release mode remove user asserts and keep runtime checks.
|
||||||
// RELEASE-LABEL: _TF19OptimizationOptions11test_assertfT_FT1xSi1ySi_Si
|
// RELEASE-LABEL: _TF19OptimizationOptions11test_assertfT_FT1xSi1ySi_Si
|
||||||
// RELEASE-NOT: "x smaller than y"
|
// RELEASE-NOT: "x smaller than y"
|
||||||
@@ -54,6 +61,13 @@ func test_partial_safety_check(x: Int, y: Int) -> Int {
|
|||||||
// DEBUG: apply %[[FATAL_ERROR]]{{.*}} @noreturn
|
// DEBUG: apply %[[FATAL_ERROR]]{{.*}} @noreturn
|
||||||
// DEBUG: unreachable
|
// DEBUG: unreachable
|
||||||
|
|
||||||
|
// In playground mode keep verbose fatal errors.
|
||||||
|
// PLAYGROUND-LABEL: _TF19OptimizationOptions10test_fatalFTSiSi_Si
|
||||||
|
// PLAYGROUND-DAG: "Human nature ..."
|
||||||
|
// PLAYGROUND-DAG: %[[FATAL_ERROR:.+]] = function_ref @_TTOS_nndd__TFSs18_fatalErrorMessageFTVSs12StaticStringS_S_Su_T_
|
||||||
|
// PLAYGROUND: apply %[[FATAL_ERROR]]{{.*}} @noreturn
|
||||||
|
// PLAYGROUND: unreachable
|
||||||
|
|
||||||
// In release mode keep succinct fatal errors (trap).
|
// In release mode keep succinct fatal errors (trap).
|
||||||
// RELEASE-LABEL: _TF19OptimizationOptions10test_fatalFTSiSi_Si
|
// RELEASE-LABEL: _TF19OptimizationOptions10test_fatalFTSiSi_Si
|
||||||
// RELEASE-NOT: "Human nature ..."
|
// RELEASE-NOT: "Human nature ..."
|
||||||
@@ -78,6 +92,14 @@ func test_partial_safety_check(x: Int, y: Int) -> Int {
|
|||||||
// DEBUG: unreachable
|
// DEBUG: unreachable
|
||||||
// DEBUG: return
|
// DEBUG: return
|
||||||
|
|
||||||
|
// In playground mode keep verbose library precondition checks.
|
||||||
|
// PLAYGROUND-LABEL: _TF19OptimizationOptions23test_precondition_checkFTSiSi_Si
|
||||||
|
// PLAYGROUND-DAG: "fatal error"
|
||||||
|
// PLAYGROUND-DAG: %[[FATAL_ERROR:.+]] = function_ref @_TTOS_nndd__TFSs18_fatalErrorMessageFTVSs12StaticStringS_S_Su_T_
|
||||||
|
// PLAYGROUND: apply %[[FATAL_ERROR]]{{.*}} @noreturn
|
||||||
|
// PLAYGROUND: unreachable
|
||||||
|
// PLAYGROUND: return
|
||||||
|
|
||||||
// In release mode keep succinct library precondition checks (trap).
|
// In release mode keep succinct library precondition checks (trap).
|
||||||
// RELEASE-LABEL: _TF19OptimizationOptions23test_precondition_checkFTSiSi_Si
|
// RELEASE-LABEL: _TF19OptimizationOptions23test_precondition_checkFTSiSi_Si
|
||||||
// RELEASE-NOT: "fatal error"
|
// RELEASE-NOT: "fatal error"
|
||||||
@@ -101,6 +123,13 @@ func test_partial_safety_check(x: Int, y: Int) -> Int {
|
|||||||
// DEBUG: apply %[[FATAL_ERROR]]{{.*}} @noreturn
|
// DEBUG: apply %[[FATAL_ERROR]]{{.*}} @noreturn
|
||||||
// DEBUG: unreachable
|
// DEBUG: unreachable
|
||||||
|
|
||||||
|
// In playground mode keep verbose partial safety checks.
|
||||||
|
// PLAYGROUND-LABEL: _TF19OptimizationOptions25test_partial_safety_checkFTSiSi_Si
|
||||||
|
// PLAYGROUND-DAG: "fatal error"
|
||||||
|
// PLAYGROUND-DAG: %[[FATAL_ERROR:.+]] = function_ref @_TTOS_nndd__TFSs18_fatalErrorMessageFTVSs12StaticStringS_S_Su_T_
|
||||||
|
// PLAYGROUND: apply %[[FATAL_ERROR]]{{.*}} @noreturn
|
||||||
|
// PLAYGROUND: unreachable
|
||||||
|
|
||||||
// In release mode remove partial safety checks.
|
// In release mode remove partial safety checks.
|
||||||
// RELEASE-LABEL: _TF19OptimizationOptions25test_partial_safety_checkFTSiSi_Si
|
// RELEASE-LABEL: _TF19OptimizationOptions25test_partial_safety_checkFTSiSi_Si
|
||||||
// RELEASE-NOT: "fatal error"
|
// RELEASE-NOT: "fatal error"
|
||||||
|
|||||||
Reference in New Issue
Block a user