File tree Expand file tree Collapse file tree 2 files changed +30
-14
lines changed
SwiftCompilerSources/Sources/Optimizer
InstructionSimplification Expand file tree Collapse file tree 2 files changed +30
-14
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: 0
52
+ case . release: 1
53
+ case . unchecked: 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
}
You can’t perform that action at this time.
0 commit comments