Swift斷言->SIL__ver.垃圾箱

Swift斷言

Swift提供了assert,precondition, fatalError三種斷言方法。編程時(shí)可使用的API主要有以下5種

  1. assert(_:)
  2. assertionFailure()
  3. precondition(_:)
  4. preconditionFailure()
  5. fatalError()

具體這5個(gè)函數(shù)在那種情況下會(huì)使應(yīng)用程序強(qiáng)制崩潰,以下這位大佬給制作了一份方便易懂的參照表,提供了以上函數(shù)在不同編譯器優(yōu)化等級(jí)(Optimization Level)下是否崩潰的cheat sheet。
https://blog.krzyzanowskim.com/2015/03/09/swift-asserts-the-missing-manual/


function
debug
-Onone
release
-O
release
-Ounchecked
assert() YES NO NO
assertionFailure() YES NO NO**
precondition() YES YES NO
preconditionFailure() YES YES YES**
fatalError()* YES YES YES

* not really assertion, it is designed to terminate code execution always, no matter what.
** the optimizer may assume that this function will never be called.

具體在什么情況下應(yīng)采用哪個(gè)函數(shù)則有喵神的《關(guān)于 Swift Error 的分類(lèi)》這篇文章可以參考,這里不再贅述。
https://onevcat.com/2017/10/swift-error-category/

作為一個(gè)好奇的小白,我突然就對(duì)以上Swift斷言函數(shù)的實(shí)現(xiàn)產(chǎn)生了興趣。為什么根據(jù)不同的優(yōu)化等級(jí),會(huì)產(chǎn)生不同的結(jié)果。
接觸了一點(diǎn)Swift編譯的皮毛后,我試著將斷言函數(shù)編譯成SIL探查。

SIL

Swift編譯

SIL is an SSA-form IR with high-level semantic information designed to implement the Swift programming language.
https://github.com/apple/swift/blob/master/docs/SIL.rst#sil-in-the-swift-compiler

SIL是用以實(shí)現(xiàn)Swift的一種靜態(tài)單賦值形式(SSA-form)的中介碼(IR)。
*靜態(tài)單賦值形式-百度百科
用來(lái)達(dá)成以下目的

  • A set of guaranteed high-level optimizations that provide a predictable baseline for runtime and diagnostic behavior.
  • Diagnostic dataflow analysis passes that enforce Swift language requirements, such as definitive initialization of variables and constructors, code reachability, switch coverage.
  • High-level optimization passes, including retain/release optimization, dynamic method devirtualization, closure inlining, promoting heap allocations to stack allocations, promoting stack allocations to SSA registers, scalar replacement of aggregates (splitting aggregate allocations into multiple smaller allocations), and generic function instantiation.
  • A stable distribution format that can be used to distribute "fragile" inlineable or generic code with Swift library modules, to be optimized into client binaries.

有這位大佬翻譯并作出了詳細(xì)的解釋
http://www.lxweimin.com/p/c2880460c6cd

使用swiftc指令可以將Swift代碼編譯成SIL


// TODO: 以下尚未完成

Origin

// assert.swift
assert(false)

// assertionFailure.swift
assertionFailure()

// precondition.swift
precondition(false)

// preconditionFailure.swift
preconditionFailure()

// fatalError.swift
fatalError()

SILGen

compile -Onone
$ swiftc -emit-sil *.swift > *.sil
compile -O
$ swiftc -emit-sil -O *.swift > *_O.sil
compile -Ounchecked
$ swiftc -emit-sil -Ounchecked *.swift > *_Ounchecked.sil

SIL

assert.sil (-Onone)
sil_stage canonical

import Builtin
import Swift
import SwiftShims

// main
sil @main : $@convention(c) (Int32, UnsafeMutablePointer<Optional<UnsafeMutablePointer<Int8>>>) -> Int32 {
bb0(%0 : $Int32, %1 : $UnsafeMutablePointer<Optional<UnsafeMutablePointer<Int8>>>):
  %2 = string_literal utf8 "assert.swift"         // user: %4
  %3 = integer_literal $Builtin.Word, 12          // user: %8
  %4 = builtin "ptrtoint_Word"(%2 : $Builtin.RawPointer) : $Builtin.Word // user: %8
  br bb1                                          // id: %5

bb1:                                              // Preds: bb0
  %6 = integer_literal $Builtin.Int8, 2           // user: %8
  br bb2                                          // id: %7

bb2:                                              // Preds: bb1
  %8 = struct $StaticString (%4 : $Builtin.Word, %3 : $Builtin.Word, %6 : $Builtin.Int8) // user: %26
  %9 = integer_literal $Builtin.Int64, 1          // user: %10
  %10 = struct $UInt (%9 : $Builtin.Int64)        // user: %26
  // function_ref implicit closure #1 in default argument 1 of assert(_:_:file:line:)
  %11 = function_ref @$ss6assert__4file4lineySbyXK_SSyXKs12StaticStringVSutFfA0_SSycfu_ : $@convention(thin) () -> @owned String // user: %12
  %12 = thin_to_thick_function %11 : $@convention(thin) () -> @owned String to $@callee_guaranteed () -> @owned String // users: %13, %14
  strong_retain %12 : $@callee_guaranteed () -> @owned String // id: %13
  %14 = convert_escape_to_noescape %12 : $@callee_guaranteed () -> @owned String to $@noescape @callee_guaranteed () -> @owned String // user: %22
  br bb3                                          // id: %15

bb3:                                              // Preds: bb2
  br bb4                                          // id: %16

bb4:                                              // Preds: bb3
  %17 = string_literal utf8 "Assertion failed"    // user: %19
  %18 = integer_literal $Builtin.Word, 16         // user: %21
  %19 = builtin "ptrtoint_Word"(%17 : $Builtin.RawPointer) : $Builtin.Word // user: %21
  %20 = integer_literal $Builtin.Int8, 2          // user: %21
  %21 = struct $StaticString (%19 : $Builtin.Word, %18 : $Builtin.Word, %20 : $Builtin.Int8) // user: %26
  %22 = apply %14() : $@noescape @callee_guaranteed () -> @owned String // user: %26
  %23 = integer_literal $Builtin.Int32, 1         // user: %24
  %24 = struct $UInt32 (%23 : $Builtin.Int32)     // user: %26
  // function_ref _assertionFailure(_:_:file:line:flags:)
  %25 = function_ref @$ss17_assertionFailure__4file4line5flagss5NeverOs12StaticStringV_SSAHSus6UInt32VtF : $@convention(thin) (StaticString, @guaranteed String, StaticString, UInt, UInt32) -> Never // user: %26
  %26 = apply %25(%21, %22, %8, %10, %24) : $@convention(thin) (StaticString, @guaranteed String, StaticString, UInt, UInt32) -> Never
  unreachable                                     // id: %27
} // end sil function 'main'

// Bool.init(_builtinBooleanLiteral:)
sil public_external [transparent] [serialized] @$sSb22_builtinBooleanLiteralSbBi1__tcfC : $@convention(method) (Builtin.Int1, @thin Bool.Type) -> Bool {
// %0                                             // user: %2
bb0(%0 : $Builtin.Int1, %1 : $@thin Bool.Type):
  %2 = struct $Bool (%0 : $Builtin.Int1)          // user: %3
  return %2 : $Bool                               // id: %3
} // end sil function '$sSb22_builtinBooleanLiteralSbBi1__tcfC'

// StaticString.init(_builtinStringLiteral:utf8CodeUnitCount:isASCII:)
sil public_external [transparent] [serialized] [readonly] @$ss12StaticStringV08_builtinB7Literal17utf8CodeUnitCount7isASCIIABBp_BwBi1_tcfC : $@convention(method) (Builtin.RawPointer, Builtin.Word, Builtin.Int1, @thin StaticString.Type) -> StaticString {
// %0                                             // user: %4
// %1                                             // user: %11
// %2                                             // user: %5
bb0(%0 : $Builtin.RawPointer, %1 : $Builtin.Word, %2 : $Builtin.Int1, %3 : $@thin StaticString.Type):
  %4 = builtin "ptrtoint_Word"(%0 : $Builtin.RawPointer) : $Builtin.Word // user: %11
  cond_br %2, bb2, bb1                            // id: %5

bb1:                                              // Preds: bb0
  %6 = integer_literal $Builtin.Int8, 0           // user: %7
  br bb3(%6 : $Builtin.Int8)                      // id: %7

bb2:                                              // Preds: bb0
  %8 = integer_literal $Builtin.Int8, 2           // user: %9
  br bb3(%8 : $Builtin.Int8)                      // id: %9

// %10                                            // user: %11
bb3(%10 : $Builtin.Int8):                         // Preds: bb2 bb1
  %11 = struct $StaticString (%4 : $Builtin.Word, %1 : $Builtin.Word, %10 : $Builtin.Int8) // user: %12
  return %11 : $StaticString                      // id: %12
} // end sil function '$ss12StaticStringV08_builtinB7Literal17utf8CodeUnitCount7isASCIIABBp_BwBi1_tcfC'

// UInt.init(_builtinIntegerLiteral:)
sil public_external [transparent] [serialized] @$sSu22_builtinIntegerLiteralSuBI_tcfC : $@convention(method) (Builtin.IntLiteral, @thin UInt.Type) -> UInt {
// %0                                             // user: %2
bb0(%0 : $Builtin.IntLiteral, %1 : $@thin UInt.Type):
  %2 = builtin "s_to_u_checked_trunc_IntLiteral_Int64"(%0 : $Builtin.IntLiteral) : $(Builtin.Int64, Builtin.Int1) // user: %3
  %3 = tuple_extract %2 : $(Builtin.Int64, Builtin.Int1), 0 // user: %4
  %4 = struct $UInt (%3 : $Builtin.Int64)         // user: %5
  return %4 : $UInt                               // id: %5
} // end sil function '$sSu22_builtinIntegerLiteralSuBI_tcfC'

// default argument 1 of assert(_:_:file:line:)
sil shared_external [transparent] [serialized] @$ss6assert__4file4lineySbyXK_SSyXKs12StaticStringVSutFfA0_ : $@convention(thin) () -> @owned @callee_guaranteed () -> @owned String {
bb0:
  // function_ref implicit closure #1 in default argument 1 of assert(_:_:file:line:)
  %0 = function_ref @$ss6assert__4file4lineySbyXK_SSyXKs12StaticStringVSutFfA0_SSycfu_ : $@convention(thin) () -> @owned String // user: %1
  %1 = thin_to_thick_function %0 : $@convention(thin) () -> @owned String to $@callee_guaranteed () -> @owned String // user: %2
  return %1 : $@callee_guaranteed () -> @owned String // id: %2
} // end sil function '$ss6assert__4file4lineySbyXK_SSyXKs12StaticStringVSutFfA0_'

// assert(_:_:file:line:)
sil public_external [transparent] [serialized] @$ss6assert__4file4lineySbyXK_SSyXKs12StaticStringVSutF : $@convention(thin) (@noescape @callee_guaranteed () -> Bool, @noescape @callee_guaranteed () -> @owned String, StaticString, UInt) -> () {
// %0                                             // user: %5
// %1                                             // user: %15
// %2                                             // user: %19
// %3                                             // user: %19
bb0(%0 : $@noescape @callee_guaranteed () -> Bool, %1 : $@noescape @callee_guaranteed () -> @owned String, %2 : $StaticString, %3 : $UInt):
  br bb1                                          // id: %4

bb1:                                              // Preds: bb0
  %5 = apply %0() : $@noescape @callee_guaranteed () -> Bool // user: %7
  %6 = integer_literal $Builtin.Int1, -1          // user: %8
  %7 = struct_extract %5 : $Bool, #Bool._value    // user: %8
  %8 = builtin "int_expect_Int1"(%7 : $Builtin.Int1, %6 : $Builtin.Int1) : $Builtin.Int1 // user: %9
  cond_br %8, bb3, bb2                            // id: %9

bb2:                                              // Preds: bb1
  %10 = string_literal utf8 "Assertion failed"    // user: %12
  %11 = integer_literal $Builtin.Word, 16         // user: %14
  %12 = builtin "ptrtoint_Word"(%10 : $Builtin.RawPointer) : $Builtin.Word // user: %14
  %13 = integer_literal $Builtin.Int8, 2          // user: %14
  %14 = struct $StaticString (%12 : $Builtin.Word, %11 : $Builtin.Word, %13 : $Builtin.Int8) // user: %19
  %15 = apply %1() : $@noescape @callee_guaranteed () -> @owned String // user: %19
  %16 = integer_literal $Builtin.Int32, 1         // user: %17
  %17 = struct $UInt32 (%16 : $Builtin.Int32)     // user: %19
  // function_ref _assertionFailure(_:_:file:line:flags:)
  %18 = function_ref @$ss17_assertionFailure__4file4line5flagss5NeverOs12StaticStringV_SSAHSus6UInt32VtF : $@convention(thin) (StaticString, @guaranteed String, StaticString, UInt, UInt32) -> Never // user: %19
  %19 = apply %18(%14, %15, %2, %3, %17) : $@convention(thin) (StaticString, @guaranteed String, StaticString, UInt, UInt32) -> Never
  unreachable                                     // id: %20

bb3:                                              // Preds: bb1
  %21 = tuple ()                                  // user: %22
  return %21 : $()                                // id: %22
} // end sil function '$ss6assert__4file4lineySbyXK_SSyXKs12StaticStringVSutF'

// _assertionFailure(_:_:file:line:flags:)
sil [noinline] [_semantics "programtermination_point"] @$ss17_assertionFailure__4file4line5flagss5NeverOs12StaticStringV_SSAHSus6UInt32VtF : $@convention(thin) (StaticString, @guaranteed String, StaticString, UInt, UInt32) -> Never

// implicit closure #1 in default argument 1 of assert(_:_:file:line:)
sil shared_external [transparent] [serialized] @$ss6assert__4file4lineySbyXK_SSyXKs12StaticStringVSutFfA0_SSycfu_ : $@convention(thin) () -> @owned String {
bb0:
  %0 = integer_literal $Builtin.Int64, 0          // user: %1
  %1 = struct $UInt64 (%0 : $Builtin.Int64)       // user: %4
  %2 = integer_literal $Builtin.Int64, -2305843009213693952 // user: %3
  %3 = value_to_bridge_object %2 : $Builtin.Int64 // user: %4
  %4 = struct $_StringObject (%1 : $UInt64, %3 : $Builtin.BridgeObject) // user: %5
  %5 = struct $_StringGuts (%4 : $_StringObject)  // user: %6
  %6 = struct $String (%5 : $_StringGuts)         // user: %7
  return %6 : $String                             // id: %7
} // end sil function '$ss6assert__4file4lineySbyXK_SSyXKs12StaticStringVSutFfA0_SSycfu_'




assert_O.sil (-O)
sil_stage canonical

import Builtin
import Swift
import SwiftShims

// main
sil @main : $@convention(c) (Int32, UnsafeMutablePointer<Optional<UnsafeMutablePointer<Int8>>>) -> Int32 {
bb0(%0 : $Int32, %1 : $UnsafeMutablePointer<Optional<UnsafeMutablePointer<Int8>>>):
  %2 = integer_literal $Builtin.Int32, 0          // user: %3
  %3 = struct $Int32 (%2 : $Builtin.Int32)        // user: %4
  return %3 : $Int32                              // id: %4
} // end sil function 'main'




assert_Ounchecked.sil (-Onone)
sil_stage canonical

import Builtin
import Swift
import SwiftShims

// main
sil @main : $@convention(c) (Int32, UnsafeMutablePointer<Optional<UnsafeMutablePointer<Int8>>>) -> Int32 {
bb0(%0 : $Int32, %1 : $UnsafeMutablePointer<Optional<UnsafeMutablePointer<Int8>>>):
  %2 = integer_literal $Builtin.Int32, 0          // user: %3
  %3 = struct $Int32 (%2 : $Builtin.Int32)        // user: %4
  return %3 : $Int32                              // id: %4
} // end sil function 'main'




assertionFailure.sil (-Onone)
sil_stage canonical

import Builtin
import Swift
import SwiftShims

// main
sil @main : $@convention(c) (Int32, UnsafeMutablePointer<Optional<UnsafeMutablePointer<Int8>>>) -> Int32 {
bb0(%0 : $Int32, %1 : $UnsafeMutablePointer<Optional<UnsafeMutablePointer<Int8>>>):
  %2 = string_literal utf8 "assertionFailure.swift" // user: %4
  %3 = integer_literal $Builtin.Word, 22          // user: %8
  %4 = builtin "ptrtoint_Word"(%2 : $Builtin.RawPointer) : $Builtin.Word // user: %8
  br bb1                                          // id: %5

bb1:                                              // Preds: bb0
  %6 = integer_literal $Builtin.Int8, 2           // user: %8
  br bb2                                          // id: %7

bb2:                                              // Preds: bb1
  %8 = struct $StaticString (%4 : $Builtin.Word, %3 : $Builtin.Word, %6 : $Builtin.Int8) // user: %16
  %9 = integer_literal $Builtin.Int64, 1          // user: %10
  %10 = struct $UInt (%9 : $Builtin.Int64)        // user: %16
  // function_ref default argument 0 of assertionFailure(_:file:line:)
  %11 = function_ref @$ss16assertionFailure_4file4lineySSyXK_s12StaticStringVSutFfA_ : $@convention(thin) () -> @owned @callee_guaranteed () -> @owned String // user: %12
  %12 = apply %11() : $@convention(thin) () -> @owned @callee_guaranteed () -> @owned String // users: %18, %17, %13, %14
  strong_retain %12 : $@callee_guaranteed () -> @owned String // id: %13
  %14 = convert_escape_to_noescape %12 : $@callee_guaranteed () -> @owned String to $@noescape @callee_guaranteed () -> @owned String // user: %16
  // function_ref assertionFailure(_:file:line:)
  %15 = function_ref @$ss16assertionFailure_4file4lineySSyXK_s12StaticStringVSutF : $@convention(thin) (@noescape @callee_guaranteed () -> @owned String, StaticString, UInt) -> () // user: %16
  %16 = apply %15(%14, %8, %10) : $@convention(thin) (@noescape @callee_guaranteed () -> @owned String, StaticString, UInt) -> ()
  strong_release %12 : $@callee_guaranteed () -> @owned String // id: %17
  strong_release %12 : $@callee_guaranteed () -> @owned String // id: %18
  %19 = integer_literal $Builtin.Int32, 0         // user: %20
  %20 = struct $Int32 (%19 : $Builtin.Int32)      // user: %21
  return %20 : $Int32                             // id: %21
} // end sil function 'main'

// StaticString.init(_builtinStringLiteral:utf8CodeUnitCount:isASCII:)
sil public_external [transparent] [serialized] [readonly] @$ss12StaticStringV08_builtinB7Literal17utf8CodeUnitCount7isASCIIABBp_BwBi1_tcfC : $@convention(method) (Builtin.RawPointer, Builtin.Word, Builtin.Int1, @thin StaticString.Type) -> StaticString {
// %0                                             // user: %4
// %1                                             // user: %11
// %2                                             // user: %5
bb0(%0 : $Builtin.RawPointer, %1 : $Builtin.Word, %2 : $Builtin.Int1, %3 : $@thin StaticString.Type):
  %4 = builtin "ptrtoint_Word"(%0 : $Builtin.RawPointer) : $Builtin.Word // user: %11
  cond_br %2, bb2, bb1                            // id: %5

bb1:                                              // Preds: bb0
  %6 = integer_literal $Builtin.Int8, 0           // user: %7
  br bb3(%6 : $Builtin.Int8)                      // id: %7

bb2:                                              // Preds: bb0
  %8 = integer_literal $Builtin.Int8, 2           // user: %9
  br bb3(%8 : $Builtin.Int8)                      // id: %9

// %10                                            // user: %11
bb3(%10 : $Builtin.Int8):                         // Preds: bb2 bb1
  %11 = struct $StaticString (%4 : $Builtin.Word, %1 : $Builtin.Word, %10 : $Builtin.Int8) // user: %12
  return %11 : $StaticString                      // id: %12
} // end sil function '$ss12StaticStringV08_builtinB7Literal17utf8CodeUnitCount7isASCIIABBp_BwBi1_tcfC'

// UInt.init(_builtinIntegerLiteral:)
sil public_external [transparent] [serialized] @$sSu22_builtinIntegerLiteralSuBI_tcfC : $@convention(method) (Builtin.IntLiteral, @thin UInt.Type) -> UInt {
// %0                                             // user: %2
bb0(%0 : $Builtin.IntLiteral, %1 : $@thin UInt.Type):
  %2 = builtin "s_to_u_checked_trunc_IntLiteral_Int64"(%0 : $Builtin.IntLiteral) : $(Builtin.Int64, Builtin.Int1) // user: %3
  %3 = tuple_extract %2 : $(Builtin.Int64, Builtin.Int1), 0 // user: %4
  %4 = struct $UInt (%3 : $Builtin.Int64)         // user: %5
  return %4 : $UInt                               // id: %5
} // end sil function '$sSu22_builtinIntegerLiteralSuBI_tcfC'

// default argument 0 of assertionFailure(_:file:line:)
sil shared_external [serialized] [always_inline] @$ss16assertionFailure_4file4lineySSyXK_s12StaticStringVSutFfA_ : $@convention(thin) () -> @owned @callee_guaranteed () -> @owned String {
bb0:
  // function_ref implicit closure #1 in default argument 0 of assertionFailure(_:file:line:)
  %0 = function_ref @$ss16assertionFailure_4file4lineySSyXK_s12StaticStringVSutFfA_SSycfu_ : $@convention(thin) () -> @owned String // user: %1
  %1 = thin_to_thick_function %0 : $@convention(thin) () -> @owned String to $@callee_guaranteed () -> @owned String // user: %2
  return %1 : $@callee_guaranteed () -> @owned String // id: %2
} // end sil function '$ss16assertionFailure_4file4lineySSyXK_s12StaticStringVSutFfA_'

// assertionFailure(_:file:line:)
sil [serialized] [always_inline] @$ss16assertionFailure_4file4lineySSyXK_s12StaticStringVSutF : $@convention(thin) (@noescape @callee_guaranteed () -> @owned String, StaticString, UInt) -> ()

// implicit closure #1 in default argument 0 of assertionFailure(_:file:line:)
sil shared_external [transparent] [serialized] @$ss16assertionFailure_4file4lineySSyXK_s12StaticStringVSutFfA_SSycfu_ : $@convention(thin) () -> @owned String {
bb0:
  %0 = integer_literal $Builtin.Int64, 0          // user: %1
  %1 = struct $UInt64 (%0 : $Builtin.Int64)       // user: %4
  %2 = integer_literal $Builtin.Int64, -2305843009213693952 // user: %3
  %3 = value_to_bridge_object %2 : $Builtin.Int64 // user: %4
  %4 = struct $_StringObject (%1 : $UInt64, %3 : $Builtin.BridgeObject) // user: %5
  %5 = struct $_StringGuts (%4 : $_StringObject)  // user: %6
  %6 = struct $String (%5 : $_StringGuts)         // user: %7
  return %6 : $String                             // id: %7
} // end sil function '$ss16assertionFailure_4file4lineySSyXK_s12StaticStringVSutFfA_SSycfu_'




assertionFailure_O.sil (-O)
sil_stage canonical

import Builtin
import Swift
import SwiftShims

// main
sil @main : $@convention(c) (Int32, UnsafeMutablePointer<Optional<UnsafeMutablePointer<Int8>>>) -> Int32 {
bb0(%0 : $Int32, %1 : $UnsafeMutablePointer<Optional<UnsafeMutablePointer<Int8>>>):
  %2 = integer_literal $Builtin.Int32, 0          // user: %3
  %3 = struct $Int32 (%2 : $Builtin.Int32)        // user: %4
  return %3 : $Int32                              // id: %4
} // end sil function 'main'




assertionFailure_Ounchecked.sil (-Ounchecked)
sil_stage canonical

import Builtin
import Swift
import SwiftShims

// main
sil @main : $@convention(c) (Int32, UnsafeMutablePointer<Optional<UnsafeMutablePointer<Int8>>>) -> Int32 {
bb0(%0 : $Int32, %1 : $UnsafeMutablePointer<Optional<UnsafeMutablePointer<Int8>>>):
  unreachable                                     // id: %2
} // end sil function 'main'




precondition.sil (-Onone)
sil_stage canonical

import Builtin
import Swift
import SwiftShims

// main
sil @main : $@convention(c) (Int32, UnsafeMutablePointer<Optional<UnsafeMutablePointer<Int8>>>) -> Int32 {
bb0(%0 : $Int32, %1 : $UnsafeMutablePointer<Optional<UnsafeMutablePointer<Int8>>>):
  %2 = string_literal utf8 "precondition.swift"   // user: %4
  %3 = integer_literal $Builtin.Word, 18          // user: %8
  %4 = builtin "ptrtoint_Word"(%2 : $Builtin.RawPointer) : $Builtin.Word // user: %8
  br bb1                                          // id: %5

bb1:                                              // Preds: bb0
  %6 = integer_literal $Builtin.Int8, 2           // user: %8
  br bb2                                          // id: %7

bb2:                                              // Preds: bb1
  %8 = struct $StaticString (%4 : $Builtin.Word, %3 : $Builtin.Word, %6 : $Builtin.Int8) // user: %26
  %9 = integer_literal $Builtin.Int64, 1          // user: %10
  %10 = struct $UInt (%9 : $Builtin.Int64)        // user: %26
  // function_ref implicit closure #1 in default argument 1 of precondition(_:_:file:line:)
  %11 = function_ref @$ss12precondition__4file4lineySbyXK_SSyXKs12StaticStringVSutFfA0_SSycfu_ : $@convention(thin) () -> @owned String // user: %12
  %12 = thin_to_thick_function %11 : $@convention(thin) () -> @owned String to $@callee_guaranteed () -> @owned String // users: %13, %14
  strong_retain %12 : $@callee_guaranteed () -> @owned String // id: %13
  %14 = convert_escape_to_noescape %12 : $@callee_guaranteed () -> @owned String to $@noescape @callee_guaranteed () -> @owned String // user: %22
  br bb3                                          // id: %15

bb3:                                              // Preds: bb2
  br bb4                                          // id: %16

bb4:                                              // Preds: bb3
  %17 = string_literal utf8 "Precondition failed" // user: %19
  %18 = integer_literal $Builtin.Word, 19         // user: %21
  %19 = builtin "ptrtoint_Word"(%17 : $Builtin.RawPointer) : $Builtin.Word // user: %21
  %20 = integer_literal $Builtin.Int8, 2          // user: %21
  %21 = struct $StaticString (%19 : $Builtin.Word, %18 : $Builtin.Word, %20 : $Builtin.Int8) // user: %26
  %22 = apply %14() : $@noescape @callee_guaranteed () -> @owned String // user: %26
  %23 = integer_literal $Builtin.Int32, 1         // user: %24
  %24 = struct $UInt32 (%23 : $Builtin.Int32)     // user: %26
  // function_ref _assertionFailure(_:_:file:line:flags:)
  %25 = function_ref @$ss17_assertionFailure__4file4line5flagss5NeverOs12StaticStringV_SSAHSus6UInt32VtF : $@convention(thin) (StaticString, @guaranteed String, StaticString, UInt, UInt32) -> Never // user: %26
  %26 = apply %25(%21, %22, %8, %10, %24) : $@convention(thin) (StaticString, @guaranteed String, StaticString, UInt, UInt32) -> Never
  unreachable                                     // id: %27
} // end sil function 'main'

// Bool.init(_builtinBooleanLiteral:)
sil public_external [transparent] [serialized] @$sSb22_builtinBooleanLiteralSbBi1__tcfC : $@convention(method) (Builtin.Int1, @thin Bool.Type) -> Bool {
// %0                                             // user: %2
bb0(%0 : $Builtin.Int1, %1 : $@thin Bool.Type):
  %2 = struct $Bool (%0 : $Builtin.Int1)          // user: %3
  return %2 : $Bool                               // id: %3
} // end sil function '$sSb22_builtinBooleanLiteralSbBi1__tcfC'

// StaticString.init(_builtinStringLiteral:utf8CodeUnitCount:isASCII:)
sil public_external [transparent] [serialized] [readonly] @$ss12StaticStringV08_builtinB7Literal17utf8CodeUnitCount7isASCIIABBp_BwBi1_tcfC : $@convention(method) (Builtin.RawPointer, Builtin.Word, Builtin.Int1, @thin StaticString.Type) -> StaticString {
// %0                                             // user: %4
// %1                                             // user: %11
// %2                                             // user: %5
bb0(%0 : $Builtin.RawPointer, %1 : $Builtin.Word, %2 : $Builtin.Int1, %3 : $@thin StaticString.Type):
  %4 = builtin "ptrtoint_Word"(%0 : $Builtin.RawPointer) : $Builtin.Word // user: %11
  cond_br %2, bb2, bb1                            // id: %5

bb1:                                              // Preds: bb0
  %6 = integer_literal $Builtin.Int8, 0           // user: %7
  br bb3(%6 : $Builtin.Int8)                      // id: %7

bb2:                                              // Preds: bb0
  %8 = integer_literal $Builtin.Int8, 2           // user: %9
  br bb3(%8 : $Builtin.Int8)                      // id: %9

// %10                                            // user: %11
bb3(%10 : $Builtin.Int8):                         // Preds: bb2 bb1
  %11 = struct $StaticString (%4 : $Builtin.Word, %1 : $Builtin.Word, %10 : $Builtin.Int8) // user: %12
  return %11 : $StaticString                      // id: %12
} // end sil function '$ss12StaticStringV08_builtinB7Literal17utf8CodeUnitCount7isASCIIABBp_BwBi1_tcfC'

// UInt.init(_builtinIntegerLiteral:)
sil public_external [transparent] [serialized] @$sSu22_builtinIntegerLiteralSuBI_tcfC : $@convention(method) (Builtin.IntLiteral, @thin UInt.Type) -> UInt {
// %0                                             // user: %2
bb0(%0 : $Builtin.IntLiteral, %1 : $@thin UInt.Type):
  %2 = builtin "s_to_u_checked_trunc_IntLiteral_Int64"(%0 : $Builtin.IntLiteral) : $(Builtin.Int64, Builtin.Int1) // user: %3
  %3 = tuple_extract %2 : $(Builtin.Int64, Builtin.Int1), 0 // user: %4
  %4 = struct $UInt (%3 : $Builtin.Int64)         // user: %5
  return %4 : $UInt                               // id: %5
} // end sil function '$sSu22_builtinIntegerLiteralSuBI_tcfC'

// default argument 1 of precondition(_:_:file:line:)
sil shared_external [transparent] [serialized] @$ss12precondition__4file4lineySbyXK_SSyXKs12StaticStringVSutFfA0_ : $@convention(thin) () -> @owned @callee_guaranteed () -> @owned String {
bb0:
  // function_ref implicit closure #1 in default argument 1 of precondition(_:_:file:line:)
  %0 = function_ref @$ss12precondition__4file4lineySbyXK_SSyXKs12StaticStringVSutFfA0_SSycfu_ : $@convention(thin) () -> @owned String // user: %1
  %1 = thin_to_thick_function %0 : $@convention(thin) () -> @owned String to $@callee_guaranteed () -> @owned String // user: %2
  return %1 : $@callee_guaranteed () -> @owned String // id: %2
} // end sil function '$ss12precondition__4file4lineySbyXK_SSyXKs12StaticStringVSutFfA0_'

// precondition(_:_:file:line:)
sil public_external [transparent] [serialized] @$ss12precondition__4file4lineySbyXK_SSyXKs12StaticStringVSutF : $@convention(thin) (@noescape @callee_guaranteed () -> Bool, @noescape @callee_guaranteed () -> @owned String, StaticString, UInt) -> () {
// %0                                             // user: %5
// %1                                             // user: %15
// %2                                             // user: %19
// %3                                             // user: %19
bb0(%0 : $@noescape @callee_guaranteed () -> Bool, %1 : $@noescape @callee_guaranteed () -> @owned String, %2 : $StaticString, %3 : $UInt):
  br bb1                                          // id: %4

bb1:                                              // Preds: bb0
  %5 = apply %0() : $@noescape @callee_guaranteed () -> Bool // user: %7
  %6 = integer_literal $Builtin.Int1, -1          // user: %8
  %7 = struct_extract %5 : $Bool, #Bool._value    // user: %8
  %8 = builtin "int_expect_Int1"(%7 : $Builtin.Int1, %6 : $Builtin.Int1) : $Builtin.Int1 // user: %9
  cond_br %8, bb3, bb2                            // id: %9

bb2:                                              // Preds: bb1
  %10 = string_literal utf8 "Precondition failed" // user: %12
  %11 = integer_literal $Builtin.Word, 19         // user: %14
  %12 = builtin "ptrtoint_Word"(%10 : $Builtin.RawPointer) : $Builtin.Word // user: %14
  %13 = integer_literal $Builtin.Int8, 2          // user: %14
  %14 = struct $StaticString (%12 : $Builtin.Word, %11 : $Builtin.Word, %13 : $Builtin.Int8) // user: %19
  %15 = apply %1() : $@noescape @callee_guaranteed () -> @owned String // user: %19
  %16 = integer_literal $Builtin.Int32, 1         // user: %17
  %17 = struct $UInt32 (%16 : $Builtin.Int32)     // user: %19
  // function_ref _assertionFailure(_:_:file:line:flags:)
  %18 = function_ref @$ss17_assertionFailure__4file4line5flagss5NeverOs12StaticStringV_SSAHSus6UInt32VtF : $@convention(thin) (StaticString, @guaranteed String, StaticString, UInt, UInt32) -> Never // user: %19
  %19 = apply %18(%14, %15, %2, %3, %17) : $@convention(thin) (StaticString, @guaranteed String, StaticString, UInt, UInt32) -> Never
  unreachable                                     // id: %20

bb3:                                              // Preds: bb1
  %21 = tuple ()                                  // user: %22
  return %21 : $()                                // id: %22
} // end sil function '$ss12precondition__4file4lineySbyXK_SSyXKs12StaticStringVSutF'

// _assertionFailure(_:_:file:line:flags:)
sil [noinline] [_semantics "programtermination_point"] @$ss17_assertionFailure__4file4line5flagss5NeverOs12StaticStringV_SSAHSus6UInt32VtF : $@convention(thin) (StaticString, @guaranteed String, StaticString, UInt, UInt32) -> Never

// implicit closure #1 in default argument 1 of precondition(_:_:file:line:)
sil shared_external [transparent] [serialized] @$ss12precondition__4file4lineySbyXK_SSyXKs12StaticStringVSutFfA0_SSycfu_ : $@convention(thin) () -> @owned String {
bb0:
  %0 = integer_literal $Builtin.Int64, 0          // user: %1
  %1 = struct $UInt64 (%0 : $Builtin.Int64)       // user: %4
  %2 = integer_literal $Builtin.Int64, -2305843009213693952 // user: %3
  %3 = value_to_bridge_object %2 : $Builtin.Int64 // user: %4
  %4 = struct $_StringObject (%1 : $UInt64, %3 : $Builtin.BridgeObject) // user: %5
  %5 = struct $_StringGuts (%4 : $_StringObject)  // user: %6
  %6 = struct $String (%5 : $_StringGuts)         // user: %7
  return %6 : $String                             // id: %7
} // end sil function '$ss12precondition__4file4lineySbyXK_SSyXKs12StaticStringVSutFfA0_SSycfu_'




precondition_O.sil (-O)
sil_stage canonical

import Builtin
import Swift
import SwiftShims

// main
sil @main : $@convention(c) (Int32, UnsafeMutablePointer<Optional<UnsafeMutablePointer<Int8>>>) -> Int32 {
bb0(%0 : $Int32, %1 : $UnsafeMutablePointer<Optional<UnsafeMutablePointer<Int8>>>):
  %2 = integer_literal $Builtin.Int1, -1          // user: %3
  cond_fail %2 : $Builtin.Int1                    // id: %3
  unreachable                                     // id: %4
} // end sil function 'main'




precondition_Ounchecked.sil (-Ounchecked)
sil_stage canonical

import Builtin
import Swift
import SwiftShims

// main
sil @main : $@convention(c) (Int32, UnsafeMutablePointer<Optional<UnsafeMutablePointer<Int8>>>) -> Int32 {
bb0(%0 : $Int32, %1 : $UnsafeMutablePointer<Optional<UnsafeMutablePointer<Int8>>>):
  %2 = integer_literal $Builtin.Int32, 0          // user: %3
  %3 = struct $Int32 (%2 : $Builtin.Int32)        // user: %4
  return %3 : $Int32                              // id: %4
} // end sil function 'main'




preconditionFailure.sil (-Onone)
sil_stage canonical

import Builtin
import Swift
import SwiftShims

// main
sil @main : $@convention(c) (Int32, UnsafeMutablePointer<Optional<UnsafeMutablePointer<Int8>>>) -> Int32 {
bb0(%0 : $Int32, %1 : $UnsafeMutablePointer<Optional<UnsafeMutablePointer<Int8>>>):
  %2 = string_literal utf8 "preconditionFailure.swift" // user: %4
  %3 = integer_literal $Builtin.Word, 25          // user: %8
  %4 = builtin "ptrtoint_Word"(%2 : $Builtin.RawPointer) : $Builtin.Word // user: %8
  br bb1                                          // id: %5

bb1:                                              // Preds: bb0
  %6 = integer_literal $Builtin.Int8, 2           // user: %8
  br bb2                                          // id: %7

bb2:                                              // Preds: bb1
  %8 = struct $StaticString (%4 : $Builtin.Word, %3 : $Builtin.Word, %6 : $Builtin.Int8) // user: %25
  %9 = integer_literal $Builtin.Int64, 1          // user: %10
  %10 = struct $UInt (%9 : $Builtin.Int64)        // user: %25
  // function_ref implicit closure #1 in default argument 0 of preconditionFailure(_:file:line:)
  %11 = function_ref @$ss19preconditionFailure_4file4lines5NeverOSSyXK_s12StaticStringVSutFfA_SSycfu_ : $@convention(thin) () -> @owned String // user: %12
  %12 = thin_to_thick_function %11 : $@convention(thin) () -> @owned String to $@callee_guaranteed () -> @owned String // users: %13, %14
  strong_retain %12 : $@callee_guaranteed () -> @owned String // id: %13
  %14 = convert_escape_to_noescape %12 : $@callee_guaranteed () -> @owned String to $@noescape @callee_guaranteed () -> @owned String // user: %21
  br bb3                                          // id: %15

bb3:                                              // Preds: bb2
  %16 = string_literal utf8 "Fatal error"         // user: %18
  %17 = integer_literal $Builtin.Word, 11         // user: %20
  %18 = builtin "ptrtoint_Word"(%16 : $Builtin.RawPointer) : $Builtin.Word // user: %20
  %19 = integer_literal $Builtin.Int8, 2          // user: %20
  %20 = struct $StaticString (%18 : $Builtin.Word, %17 : $Builtin.Word, %19 : $Builtin.Int8) // user: %25
  %21 = apply %14() : $@noescape @callee_guaranteed () -> @owned String // user: %25
  %22 = integer_literal $Builtin.Int32, 1         // user: %23
  %23 = struct $UInt32 (%22 : $Builtin.Int32)     // user: %25
  // function_ref _assertionFailure(_:_:file:line:flags:)
  %24 = function_ref @$ss17_assertionFailure__4file4line5flagss5NeverOs12StaticStringV_SSAHSus6UInt32VtF : $@convention(thin) (StaticString, @guaranteed String, StaticString, UInt, UInt32) -> Never // user: %25
  %25 = apply %24(%20, %21, %8, %10, %23) : $@convention(thin) (StaticString, @guaranteed String, StaticString, UInt, UInt32) -> Never
  unreachable                                     // id: %26
} // end sil function 'main'

// StaticString.init(_builtinStringLiteral:utf8CodeUnitCount:isASCII:)
sil public_external [transparent] [serialized] [readonly] @$ss12StaticStringV08_builtinB7Literal17utf8CodeUnitCount7isASCIIABBp_BwBi1_tcfC : $@convention(method) (Builtin.RawPointer, Builtin.Word, Builtin.Int1, @thin StaticString.Type) -> StaticString {
// %0                                             // user: %4
// %1                                             // user: %11
// %2                                             // user: %5
bb0(%0 : $Builtin.RawPointer, %1 : $Builtin.Word, %2 : $Builtin.Int1, %3 : $@thin StaticString.Type):
  %4 = builtin "ptrtoint_Word"(%0 : $Builtin.RawPointer) : $Builtin.Word // user: %11
  cond_br %2, bb2, bb1                            // id: %5

bb1:                                              // Preds: bb0
  %6 = integer_literal $Builtin.Int8, 0           // user: %7
  br bb3(%6 : $Builtin.Int8)                      // id: %7

bb2:                                              // Preds: bb0
  %8 = integer_literal $Builtin.Int8, 2           // user: %9
  br bb3(%8 : $Builtin.Int8)                      // id: %9

// %10                                            // user: %11
bb3(%10 : $Builtin.Int8):                         // Preds: bb2 bb1
  %11 = struct $StaticString (%4 : $Builtin.Word, %1 : $Builtin.Word, %10 : $Builtin.Int8) // user: %12
  return %11 : $StaticString                      // id: %12
} // end sil function '$ss12StaticStringV08_builtinB7Literal17utf8CodeUnitCount7isASCIIABBp_BwBi1_tcfC'

// UInt.init(_builtinIntegerLiteral:)
sil public_external [transparent] [serialized] @$sSu22_builtinIntegerLiteralSuBI_tcfC : $@convention(method) (Builtin.IntLiteral, @thin UInt.Type) -> UInt {
// %0                                             // user: %2
bb0(%0 : $Builtin.IntLiteral, %1 : $@thin UInt.Type):
  %2 = builtin "s_to_u_checked_trunc_IntLiteral_Int64"(%0 : $Builtin.IntLiteral) : $(Builtin.Int64, Builtin.Int1) // user: %3
  %3 = tuple_extract %2 : $(Builtin.Int64, Builtin.Int1), 0 // user: %4
  %4 = struct $UInt (%3 : $Builtin.Int64)         // user: %5
  return %4 : $UInt                               // id: %5
} // end sil function '$sSu22_builtinIntegerLiteralSuBI_tcfC'

// default argument 0 of preconditionFailure(_:file:line:)
sil shared_external [transparent] [serialized] @$ss19preconditionFailure_4file4lines5NeverOSSyXK_s12StaticStringVSutFfA_ : $@convention(thin) () -> @owned @callee_guaranteed () -> @owned String {
bb0:
  // function_ref implicit closure #1 in default argument 0 of preconditionFailure(_:file:line:)
  %0 = function_ref @$ss19preconditionFailure_4file4lines5NeverOSSyXK_s12StaticStringVSutFfA_SSycfu_ : $@convention(thin) () -> @owned String // user: %1
  %1 = thin_to_thick_function %0 : $@convention(thin) () -> @owned String to $@callee_guaranteed () -> @owned String // user: %2
  return %1 : $@callee_guaranteed () -> @owned String // id: %2
} // end sil function '$ss19preconditionFailure_4file4lines5NeverOSSyXK_s12StaticStringVSutFfA_'

// preconditionFailure(_:file:line:)
sil public_external [transparent] [serialized] @$ss19preconditionFailure_4file4lines5NeverOSSyXK_s12StaticStringVSutF : $@convention(thin) (@noescape @callee_guaranteed () -> @owned String, StaticString, UInt) -> Never {
// %0                                             // user: %9
// %1                                             // user: %13
// %2                                             // user: %13
bb0(%0 : $@noescape @callee_guaranteed () -> @owned String, %1 : $StaticString, %2 : $UInt):
  br bb1                                          // id: %3

bb1:                                              // Preds: bb0
  %4 = string_literal utf8 "Fatal error"          // user: %6
  %5 = integer_literal $Builtin.Word, 11          // user: %8
  %6 = builtin "ptrtoint_Word"(%4 : $Builtin.RawPointer) : $Builtin.Word // user: %8
  %7 = integer_literal $Builtin.Int8, 2           // user: %8
  %8 = struct $StaticString (%6 : $Builtin.Word, %5 : $Builtin.Word, %7 : $Builtin.Int8) // user: %13
  %9 = apply %0() : $@noescape @callee_guaranteed () -> @owned String // user: %13
  %10 = integer_literal $Builtin.Int32, 1         // user: %11
  %11 = struct $UInt32 (%10 : $Builtin.Int32)     // user: %13
  // function_ref _assertionFailure(_:_:file:line:flags:)
  %12 = function_ref @$ss17_assertionFailure__4file4line5flagss5NeverOs12StaticStringV_SSAHSus6UInt32VtF : $@convention(thin) (StaticString, @guaranteed String, StaticString, UInt, UInt32) -> Never // user: %13
  %13 = apply %12(%8, %9, %1, %2, %11) : $@convention(thin) (StaticString, @guaranteed String, StaticString, UInt, UInt32) -> Never
  unreachable                                     // id: %14
} // end sil function '$ss19preconditionFailure_4file4lines5NeverOSSyXK_s12StaticStringVSutF'

// _assertionFailure(_:_:file:line:flags:)
sil [noinline] [_semantics "programtermination_point"] @$ss17_assertionFailure__4file4line5flagss5NeverOs12StaticStringV_SSAHSus6UInt32VtF : $@convention(thin) (StaticString, @guaranteed String, StaticString, UInt, UInt32) -> Never

// implicit closure #1 in default argument 0 of preconditionFailure(_:file:line:)
sil shared_external [transparent] [serialized] @$ss19preconditionFailure_4file4lines5NeverOSSyXK_s12StaticStringVSutFfA_SSycfu_ : $@convention(thin) () -> @owned String {
bb0:
  %0 = integer_literal $Builtin.Int64, 0          // user: %1
  %1 = struct $UInt64 (%0 : $Builtin.Int64)       // user: %4
  %2 = integer_literal $Builtin.Int64, -2305843009213693952 // user: %3
  %3 = value_to_bridge_object %2 : $Builtin.Int64 // user: %4
  %4 = struct $_StringObject (%1 : $UInt64, %3 : $Builtin.BridgeObject) // user: %5
  %5 = struct $_StringGuts (%4 : $_StringObject)  // user: %6
  %6 = struct $String (%5 : $_StringGuts)         // user: %7
  return %6 : $String                             // id: %7
} // end sil function '$ss19preconditionFailure_4file4lines5NeverOSSyXK_s12StaticStringVSutFfA_SSycfu_'




preconditionFailure_O.sil (-O)
sil_stage canonical

import Builtin
import Swift
import SwiftShims

// main
sil @main : $@convention(c) (Int32, UnsafeMutablePointer<Optional<UnsafeMutablePointer<Int8>>>) -> Int32 {
bb0(%0 : $Int32, %1 : $UnsafeMutablePointer<Optional<UnsafeMutablePointer<Int8>>>):
  %2 = builtin "int_trap"() : $Never
  unreachable                                     // id: %3
} // end sil function 'main'




preconditionFailure_Ounchecked.sil (-Ounchecked)
sil_stage canonical

import Builtin
import Swift
import SwiftShims

// main
sil @main : $@convention(c) (Int32, UnsafeMutablePointer<Optional<UnsafeMutablePointer<Int8>>>) -> Int32 {
bb0(%0 : $Int32, %1 : $UnsafeMutablePointer<Optional<UnsafeMutablePointer<Int8>>>):
  unreachable                                     // id: %2
} // end sil function 'main'




fatalError.sil (-Onone)
sil_stage canonical

import Builtin
import Swift
import SwiftShims

// main
sil @main : $@convention(c) (Int32, UnsafeMutablePointer<Optional<UnsafeMutablePointer<Int8>>>) -> Int32 {
bb0(%0 : $Int32, %1 : $UnsafeMutablePointer<Optional<UnsafeMutablePointer<Int8>>>):
  %2 = string_literal utf8 "fatalError.swift"     // user: %4
  %3 = integer_literal $Builtin.Word, 16          // user: %8
  %4 = builtin "ptrtoint_Word"(%2 : $Builtin.RawPointer) : $Builtin.Word // user: %8
  br bb1                                          // id: %5

bb1:                                              // Preds: bb0
  %6 = integer_literal $Builtin.Int8, 2           // user: %8
  br bb2                                          // id: %7

bb2:                                              // Preds: bb1
  %8 = struct $StaticString (%4 : $Builtin.Word, %3 : $Builtin.Word, %6 : $Builtin.Int8) // user: %26
  %9 = integer_literal $Builtin.Int64, 1          // user: %10
  %10 = struct $UInt (%9 : $Builtin.Int64)        // user: %26
  // function_ref implicit closure #1 in default argument 0 of fatalError(_:file:line:)
  %11 = function_ref @$ss10fatalError_4file4lines5NeverOSSyXK_s12StaticStringVSutFfA_SSycfu_ : $@convention(thin) () -> @owned String // user: %12
  %12 = thin_to_thick_function %11 : $@convention(thin) () -> @owned String to $@callee_guaranteed () -> @owned String // users: %13, %14
  strong_retain %12 : $@callee_guaranteed () -> @owned String // id: %13
  %14 = convert_escape_to_noescape %12 : $@callee_guaranteed () -> @owned String to $@noescape @callee_guaranteed () -> @owned String // user: %20
  %15 = string_literal utf8 "Fatal error"         // user: %17
  %16 = integer_literal $Builtin.Word, 11         // user: %19
  %17 = builtin "ptrtoint_Word"(%15 : $Builtin.RawPointer) : $Builtin.Word // user: %19
  %18 = integer_literal $Builtin.Int8, 2          // user: %19
  %19 = struct $StaticString (%17 : $Builtin.Word, %16 : $Builtin.Word, %18 : $Builtin.Int8) // user: %26
  %20 = apply %14() : $@noescape @callee_guaranteed () -> @owned String // user: %26
  br bb3                                          // id: %21

bb3:                                              // Preds: bb2
  %22 = integer_literal $Builtin.Int32, 1         // user: %24
  br bb4                                          // id: %23

bb4:                                              // Preds: bb3
  %24 = struct $UInt32 (%22 : $Builtin.Int32)     // user: %26
  // function_ref _assertionFailure(_:_:file:line:flags:)
  %25 = function_ref @$ss17_assertionFailure__4file4line5flagss5NeverOs12StaticStringV_SSAHSus6UInt32VtF : $@convention(thin) (StaticString, @guaranteed String, StaticString, UInt, UInt32) -> Never // user: %26
  %26 = apply %25(%19, %20, %8, %10, %24) : $@convention(thin) (StaticString, @guaranteed String, StaticString, UInt, UInt32) -> Never
  unreachable                                     // id: %27
} // end sil function 'main'

// StaticString.init(_builtinStringLiteral:utf8CodeUnitCount:isASCII:)
sil public_external [transparent] [serialized] [readonly] @$ss12StaticStringV08_builtinB7Literal17utf8CodeUnitCount7isASCIIABBp_BwBi1_tcfC : $@convention(method) (Builtin.RawPointer, Builtin.Word, Builtin.Int1, @thin StaticString.Type) -> StaticString {
// %0                                             // user: %4
// %1                                             // user: %11
// %2                                             // user: %5
bb0(%0 : $Builtin.RawPointer, %1 : $Builtin.Word, %2 : $Builtin.Int1, %3 : $@thin StaticString.Type):
  %4 = builtin "ptrtoint_Word"(%0 : $Builtin.RawPointer) : $Builtin.Word // user: %11
  cond_br %2, bb2, bb1                            // id: %5

bb1:                                              // Preds: bb0
  %6 = integer_literal $Builtin.Int8, 0           // user: %7
  br bb3(%6 : $Builtin.Int8)                      // id: %7

bb2:                                              // Preds: bb0
  %8 = integer_literal $Builtin.Int8, 2           // user: %9
  br bb3(%8 : $Builtin.Int8)                      // id: %9

// %10                                            // user: %11
bb3(%10 : $Builtin.Int8):                         // Preds: bb2 bb1
  %11 = struct $StaticString (%4 : $Builtin.Word, %1 : $Builtin.Word, %10 : $Builtin.Int8) // user: %12
  return %11 : $StaticString                      // id: %12
} // end sil function '$ss12StaticStringV08_builtinB7Literal17utf8CodeUnitCount7isASCIIABBp_BwBi1_tcfC'

// UInt.init(_builtinIntegerLiteral:)
sil public_external [transparent] [serialized] @$sSu22_builtinIntegerLiteralSuBI_tcfC : $@convention(method) (Builtin.IntLiteral, @thin UInt.Type) -> UInt {
// %0                                             // user: %2
bb0(%0 : $Builtin.IntLiteral, %1 : $@thin UInt.Type):
  %2 = builtin "s_to_u_checked_trunc_IntLiteral_Int64"(%0 : $Builtin.IntLiteral) : $(Builtin.Int64, Builtin.Int1) // user: %3
  %3 = tuple_extract %2 : $(Builtin.Int64, Builtin.Int1), 0 // user: %4
  %4 = struct $UInt (%3 : $Builtin.Int64)         // user: %5
  return %4 : $UInt                               // id: %5
} // end sil function '$sSu22_builtinIntegerLiteralSuBI_tcfC'

// default argument 0 of fatalError(_:file:line:)
sil shared_external [transparent] [serialized] @$ss10fatalError_4file4lines5NeverOSSyXK_s12StaticStringVSutFfA_ : $@convention(thin) () -> @owned @callee_guaranteed () -> @owned String {
bb0:
  // function_ref implicit closure #1 in default argument 0 of fatalError(_:file:line:)
  %0 = function_ref @$ss10fatalError_4file4lines5NeverOSSyXK_s12StaticStringVSutFfA_SSycfu_ : $@convention(thin) () -> @owned String // user: %1
  %1 = thin_to_thick_function %0 : $@convention(thin) () -> @owned String to $@callee_guaranteed () -> @owned String // user: %2
  return %1 : $@callee_guaranteed () -> @owned String // id: %2
} // end sil function '$ss10fatalError_4file4lines5NeverOSSyXK_s12StaticStringVSutFfA_'

// fatalError(_:file:line:)
sil public_external [transparent] [serialized] @$ss10fatalError_4file4lines5NeverOSSyXK_s12StaticStringVSutF : $@convention(thin) (@noescape @callee_guaranteed () -> @owned String, StaticString, UInt) -> Never {
// %0                                             // user: %8
// %1                                             // user: %14
// %2                                             // user: %14
bb0(%0 : $@noescape @callee_guaranteed () -> @owned String, %1 : $StaticString, %2 : $UInt):
  %3 = string_literal utf8 "Fatal error"          // user: %5
  %4 = integer_literal $Builtin.Word, 11          // user: %7
  %5 = builtin "ptrtoint_Word"(%3 : $Builtin.RawPointer) : $Builtin.Word // user: %7
  %6 = integer_literal $Builtin.Int8, 2           // user: %7
  %7 = struct $StaticString (%5 : $Builtin.Word, %4 : $Builtin.Word, %6 : $Builtin.Int8) // user: %14
  %8 = apply %0() : $@noescape @callee_guaranteed () -> @owned String // user: %14
  br bb1                                          // id: %9

bb1:                                              // Preds: bb0
  %10 = integer_literal $Builtin.Int32, 1         // user: %12
  br bb2                                          // id: %11

bb2:                                              // Preds: bb1
  %12 = struct $UInt32 (%10 : $Builtin.Int32)     // user: %14
  // function_ref _assertionFailure(_:_:file:line:flags:)
  %13 = function_ref @$ss17_assertionFailure__4file4line5flagss5NeverOs12StaticStringV_SSAHSus6UInt32VtF : $@convention(thin) (StaticString, @guaranteed String, StaticString, UInt, UInt32) -> Never // user: %14
  %14 = apply %13(%7, %8, %1, %2, %12) : $@convention(thin) (StaticString, @guaranteed String, StaticString, UInt, UInt32) -> Never
  unreachable                                     // id: %15
} // end sil function '$ss10fatalError_4file4lines5NeverOSSyXK_s12StaticStringVSutF'

// _assertionFailure(_:_:file:line:flags:)
sil [noinline] [_semantics "programtermination_point"] @$ss17_assertionFailure__4file4line5flagss5NeverOs12StaticStringV_SSAHSus6UInt32VtF : $@convention(thin) (StaticString, @guaranteed String, StaticString, UInt, UInt32) -> Never

// implicit closure #1 in default argument 0 of fatalError(_:file:line:)
sil shared_external [transparent] [serialized] @$ss10fatalError_4file4lines5NeverOSSyXK_s12StaticStringVSutFfA_SSycfu_ : $@convention(thin) () -> @owned String {
bb0:
  %0 = integer_literal $Builtin.Int64, 0          // user: %1
  %1 = struct $UInt64 (%0 : $Builtin.Int64)       // user: %4
  %2 = integer_literal $Builtin.Int64, -2305843009213693952 // user: %3
  %3 = value_to_bridge_object %2 : $Builtin.Int64 // user: %4
  %4 = struct $_StringObject (%1 : $UInt64, %3 : $Builtin.BridgeObject) // user: %5
  %5 = struct $_StringGuts (%4 : $_StringObject)  // user: %6
  %6 = struct $String (%5 : $_StringGuts)         // user: %7
  return %6 : $String                             // id: %7
} // end sil function '$ss10fatalError_4file4lines5NeverOSSyXK_s12StaticStringVSutFfA_SSycfu_'




fatalError_O.sil (-O)
sil_stage canonical

import Builtin
import Swift
import SwiftShims

// main
sil @main : $@convention(c) (Int32, UnsafeMutablePointer<Optional<UnsafeMutablePointer<Int8>>>) -> Int32 {
bb0(%0 : $Int32, %1 : $UnsafeMutablePointer<Optional<UnsafeMutablePointer<Int8>>>):
  %2 = string_literal utf8 "fatalError.swift"     // user: %4
  %3 = integer_literal $Builtin.Word, 16          // user: %6
  %4 = builtin "ptrtoint_Word"(%2 : $Builtin.RawPointer) : $Builtin.Word // user: %6
  %5 = integer_literal $Builtin.Int8, 2           // users: %12, %6
  %6 = struct $StaticString (%4 : $Builtin.Word, %3 : $Builtin.Word, %5 : $Builtin.Int8) // user: %23
  %7 = integer_literal $Builtin.Int64, 1          // user: %8
  %8 = struct $UInt (%7 : $Builtin.Int64)         // user: %23
  %9 = string_literal utf8 "Fatal error"          // user: %11
  %10 = integer_literal $Builtin.Word, 11         // user: %12
  %11 = builtin "ptrtoint_Word"(%9 : $Builtin.RawPointer) : $Builtin.Word // user: %12
  %12 = struct $StaticString (%11 : $Builtin.Word, %10 : $Builtin.Word, %5 : $Builtin.Int8) // user: %23
  %13 = integer_literal $Builtin.Int64, 0         // user: %14
  %14 = struct $UInt64 (%13 : $Builtin.Int64)     // user: %17
  %15 = integer_literal $Builtin.Int64, -2305843009213693952 // user: %16
  %16 = value_to_bridge_object %15 : $Builtin.Int64 // user: %17
  %17 = struct $_StringObject (%14 : $UInt64, %16 : $Builtin.BridgeObject) // user: %18
  %18 = struct $_StringGuts (%17 : $_StringObject) // user: %19
  %19 = struct $String (%18 : $_StringGuts)       // user: %23
  %20 = integer_literal $Builtin.Int32, 0         // user: %21
  %21 = struct $UInt32 (%20 : $Builtin.Int32)     // user: %23
  // function_ref _assertionFailure(_:_:file:line:flags:)
  %22 = function_ref @$ss17_assertionFailure__4file4line5flagss5NeverOs12StaticStringV_SSAHSus6UInt32VtF : $@convention(thin) (StaticString, @guaranteed String, StaticString, UInt, UInt32) -> Never // user: %23
  %23 = apply %22(%12, %19, %6, %8, %21) : $@convention(thin) (StaticString, @guaranteed String, StaticString, UInt, UInt32) -> Never
  unreachable                                     // id: %24
} // end sil function 'main'

// _assertionFailure(_:_:file:line:flags:)
sil [noinline] [_semantics "programtermination_point"] @$ss17_assertionFailure__4file4line5flagss5NeverOs12StaticStringV_SSAHSus6UInt32VtF : $@convention(thin) (StaticString, @guaranteed String, StaticString, UInt, UInt32) -> Never




fatalError_Ounchecked.sil (-Ounchecked)
sil_stage canonical

import Builtin
import Swift
import SwiftShims

// main
sil @main : $@convention(c) (Int32, UnsafeMutablePointer<Optional<UnsafeMutablePointer<Int8>>>) -> Int32 {
bb0(%0 : $Int32, %1 : $UnsafeMutablePointer<Optional<UnsafeMutablePointer<Int8>>>):
  %2 = string_literal utf8 "fatalError.swift"     // user: %4
  %3 = integer_literal $Builtin.Word, 16          // user: %6
  %4 = builtin "ptrtoint_Word"(%2 : $Builtin.RawPointer) : $Builtin.Word // user: %6
  %5 = integer_literal $Builtin.Int8, 2           // users: %12, %6
  %6 = struct $StaticString (%4 : $Builtin.Word, %3 : $Builtin.Word, %5 : $Builtin.Int8) // user: %23
  %7 = integer_literal $Builtin.Int64, 1          // user: %8
  %8 = struct $UInt (%7 : $Builtin.Int64)         // user: %23
  %9 = string_literal utf8 "Fatal error"          // user: %11
  %10 = integer_literal $Builtin.Word, 11         // user: %12
  %11 = builtin "ptrtoint_Word"(%9 : $Builtin.RawPointer) : $Builtin.Word // user: %12
  %12 = struct $StaticString (%11 : $Builtin.Word, %10 : $Builtin.Word, %5 : $Builtin.Int8) // user: %23
  %13 = integer_literal $Builtin.Int64, 0         // user: %14
  %14 = struct $UInt64 (%13 : $Builtin.Int64)     // user: %17
  %15 = integer_literal $Builtin.Int64, -2305843009213693952 // user: %16
  %16 = value_to_bridge_object %15 : $Builtin.Int64 // user: %17
  %17 = struct $_StringObject (%14 : $UInt64, %16 : $Builtin.BridgeObject) // user: %18
  %18 = struct $_StringGuts (%17 : $_StringObject) // user: %19
  %19 = struct $String (%18 : $_StringGuts)       // user: %23
  %20 = integer_literal $Builtin.Int32, 0         // user: %21
  %21 = struct $UInt32 (%20 : $Builtin.Int32)     // user: %23
  // function_ref _assertionFailure(_:_:file:line:flags:)
  %22 = function_ref @$ss17_assertionFailure__4file4line5flagss5NeverOs12StaticStringV_SSAHSus6UInt32VtF : $@convention(thin) (StaticString, @guaranteed String, StaticString, UInt, UInt32) -> Never // user: %23
  %23 = apply %22(%12, %19, %6, %8, %21) : $@convention(thin) (StaticString, @guaranteed String, StaticString, UInt, UInt32) -> Never
  unreachable                                     // id: %24
} // end sil function 'main'

// _assertionFailure(_:_:file:line:flags:)
sil [noinline] [_semantics "programtermination_point"] @$ss17_assertionFailure__4file4line5flagss5NeverOs12StaticStringV_SSAHSus6UInt32VtF : $@convention(thin) (StaticString, @guaranteed String, StaticString, UInt, UInt32) -> Never




最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡(jiǎn)書(shū)系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。