File tree Expand file tree Collapse file tree 3 files changed +35
-18
lines changed
SwiftCompilerSources/Sources/Optimizer
InstructionSimplification Expand file tree Collapse file tree 3 files changed +35
-18
lines changed Original file line number Diff line number Diff line change @@ -150,19 +150,20 @@ private extension BuiltinInst {
150150 }
151151
152152 func optimizeAssertConfig( _ context: SimplifyContext ) {
153- let literal : IntegerLiteralInst
154- switch context. options. assertConfiguration {
155- case . enabled:
156- let builder = Builder ( before: self , context)
157- literal = builder. createIntegerLiteral ( 1 , type: type)
158- case . disabled:
153+ // The values for the assert_configuration call are:
154+ // 0: Debug
155+ // 1: Release
156+ // 2: Fast / Unchecked
157+ let config = context. options. assertConfiguration
158+ switch config {
159+ case . debug, . release, . unchecked:
159160 let builder = Builder ( before: self , context)
160- literal = builder. createIntegerLiteral ( 0 , type: type)
161- default :
161+ let literal = builder. createIntegerLiteral ( config. integerValue, type: type)
162+ uses. replaceAll ( with: literal, context)
163+ context. erase ( instruction: self )
164+ case . unknown:
162165 return
163166 }
164- uses. replaceAll ( with: literal, context)
165- context. erase ( instruction: self )
166167 }
167168
168169 func optimizeTargetTypeConst( _ context: SimplifyContext ) {
Original file line number Diff line number Diff line change @@ -36,16 +36,31 @@ struct Options {
3636 _bridged. hasFeature ( feature)
3737 }
3838
39+ // The values for the assert_configuration call are:
40+ // 0: Debug
41+ // 1: Release
42+ // 2: Fast / Unchecked
3943 enum AssertConfiguration {
40- case enabled
41- case disabled
44+ case debug
45+ case release
46+ case unchecked
4247 case unknown
48+
49+ var integerValue : Int {
50+ switch self {
51+ case . debug: return 0
52+ case . release: return 1
53+ case . unchecked: return 2
54+ case . unknown: fatalError ( )
55+ }
56+ }
4357 }
4458
4559 var assertConfiguration : AssertConfiguration {
4660 switch _bridged. getAssertConfiguration ( ) {
47- case . Debug: return . enabled
48- case . Release, . Unchecked: return . disabled
61+ case . Debug: return . debug
62+ case . Release: return . release
63+ case . Unchecked: return . unchecked
4964 default : return . unknown
5065 }
5166 }
Original file line number Diff line number Diff line change 11// RUN: %target-sil-opt -enable-sil-verify-all %s -onone-simplification -simplify-instruction=builtin | %FileCheck %s --check-prefix=CHECK --check-prefix=CHECK-EARLY
22// RUN: %target-sil-opt -enable-sil-verify-all %s -late-onone-simplification -simplify-instruction=builtin | %FileCheck %s --check-prefix=CHECK --check-prefix=CHECK-LATE
3- // RUN: %target-sil-opt -enable-sil-verify-all %s -assert-conf-id=1 -onone-simplification -simplify-instruction=builtin | %FileCheck %s --check-prefix=CHECK --check-prefix=CHECK-NOASSERTS
4- // RUN: %target-sil-opt -enable-sil-verify-all %s -assert-conf-id=2 -onone-simplification -simplify-instruction=builtin | %FileCheck %s --check-prefix=CHECK --check-prefix=CHECK-NOASSERTS
3+ // RUN: %target-sil-opt -enable-sil-verify-all %s -assert-conf-id=1 -onone-simplification -simplify-instruction=builtin | %FileCheck %s --check-prefix=CHECK --check-prefix=CHECK-NOASSERTS1
4+ // RUN: %target-sil-opt -enable-sil-verify-all %s -assert-conf-id=2 -onone-simplification -simplify-instruction=builtin | %FileCheck %s --check-prefix=CHECK --check-prefix=CHECK-NOASSERTS2
55
66// REQUIRES: swift_in_compiler
77
417417
418418// CHECK-LABEL: sil @remove_assert_configuration
419419// CHECK-NOT: builtin "assert_configuration"
420- // CHECK-EARLY: [[L:%.*]] = integer_literal $Builtin.Int8, 1
421- // CHECK-NOASSERTS: [[L:%.*]] = integer_literal $Builtin.Int8, 0
420+ // CHECK-EARLY: [[L:%.*]] = integer_literal $Builtin.Int8, 0
421+ // CHECK-NOASSERTS1: [[L:%.*]] = integer_literal $Builtin.Int8, 1
422+ // CHECK-NOASSERTS2: [[L:%.*]] = integer_literal $Builtin.Int8, 2
422423// CHECK: [[R:%.*]] = struct $Int8 ([[L]] : $Builtin.Int8)
423424// CHECK: return [[R]]
424425// CHECK: } // end sil function 'remove_assert_configuration'
You can’t perform that action at this time.
0 commit comments