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 {
150
150
}
151
151
152
152
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:
159
160
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:
162
165
return
163
166
}
164
- uses. replaceAll ( with: literal, context)
165
- context. erase ( instruction: self )
166
167
}
167
168
168
169
func optimizeTargetTypeConst( _ context: SimplifyContext ) {
Original file line number Diff line number Diff line change @@ -36,16 +36,31 @@ struct Options {
36
36
_bridged. hasFeature ( feature)
37
37
}
38
38
39
+ // The values for the assert_configuration call are:
40
+ // 0: Debug
41
+ // 1: Release
42
+ // 2: Fast / Unchecked
39
43
enum AssertConfiguration {
40
- case enabled
41
- case disabled
44
+ case debug
45
+ case release
46
+ case unchecked
42
47
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
+ }
43
57
}
44
58
45
59
var assertConfiguration : AssertConfiguration {
46
60
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
49
64
default : return . unknown
50
65
}
51
66
}
Original file line number Diff line number Diff line change 1
1
// RUN: %target-sil-opt -enable-sil-verify-all %s -onone-simplification -simplify-instruction=builtin | %FileCheck %s --check-prefix=CHECK --check-prefix=CHECK-EARLY
2
2
// 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
5
5
6
6
// REQUIRES: swift_in_compiler
7
7
417
417
418
418
// CHECK-LABEL: sil @remove_assert_configuration
419
419
// 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
422
423
// CHECK: [[R:%.*]] = struct $Int8 ([[L]] : $Builtin.Int8)
423
424
// CHECK: return [[R]]
424
425
// CHECK: } // end sil function 'remove_assert_configuration'
You can’t perform that action at this time.
0 commit comments