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 {
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: 0
52+ case . release: 1
53+ case . unchecked: 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 }
You can’t perform that action at this time.
0 commit comments