Swift断言->SIL__ver.垃圾箱

Swift断言

Swift提供了assert,precondition, fatalError三种断言方法。编程时可使用的API主要有以下5种

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

具体这5个函数在那种情况下会使应用程序强制崩溃,以下这位大佬给制作了一份方便易懂的参照表,提供了以上函数在不同编译器优化等级(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.

具体在什么情况下应采用哪个函数则有喵神的《关于 Swift Error 的分类》这篇文章可以参考,这里不再赘述。
https://onevcat.com/2017/10/swift-error-category/

作为一个好奇的小白,我突然就对以上Swift断言函数的实现产生了兴趣。为什么根据不同的优化等级,会产生不同的结果。
接触了一点Swift编译的皮毛后,我试着将断言函数编译成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是用以实现Swift的一种静态单赋值形式(SSA-form)的中介码(IR)。
*静态单赋值形式-百度百科
用来达成以下目的

  • 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.

有这位大佬翻译并作出了详细的解释
https://www.jianshu.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




最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
  • 序言:七十年代末,一起剥皮案震惊了整个滨河市,随后出现的几起案子,更是在滨河造成了极大的恐慌,老刑警刘岩,带你破解...
    沈念sama阅读 203,937评论 6 478
  • 序言:滨河连续发生了三起死亡事件,死亡现场离奇诡异,居然都是意外死亡,警方通过查阅死者的电脑和手机,发现死者居然都...
    沈念sama阅读 85,503评论 2 381
  • 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
    开封第一讲书人阅读 150,712评论 0 337
  • 文/不坏的土叔 我叫张陵,是天一观的道长。 经常有香客问我,道长,这世上最难降的妖魔是什么? 我笑而不...
    开封第一讲书人阅读 54,668评论 1 276
  • 正文 为了忘掉前任,我火速办了婚礼,结果婚礼上,老公的妹妹穿的比我还像新娘。我一直安慰自己,他们只是感情好,可当我...
    茶点故事阅读 63,677评论 5 366
  • 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
    开封第一讲书人阅读 48,601评论 1 281
  • 那天,我揣着相机与录音,去河边找鬼。 笑死,一个胖子当着我的面吹牛,可吹牛的内容都是我干的。 我是一名探鬼主播,决...
    沈念sama阅读 37,975评论 3 396
  • 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...
    开封第一讲书人阅读 36,637评论 0 258
  • 序言:老挝万荣一对情侣失踪,失踪者是张志新(化名)和其女友刘颖,没想到半个月后,有当地人在树林里发现了一具尸体,经...
    沈念sama阅读 40,881评论 1 298
  • 正文 独居荒郊野岭守林人离奇死亡,尸身上长有42处带血的脓包…… 初始之章·张勋 以下内容为张勋视角 年9月15日...
    茶点故事阅读 35,621评论 2 321
  • 正文 我和宋清朗相恋三年,在试婚纱的时候发现自己被绿了。 大学时的朋友给我发了我未婚夫和他白月光在一起吃饭的照片。...
    茶点故事阅读 37,710评论 1 329
  • 序言:一个原本活蹦乱跳的男人离奇死亡,死状恐怖,灵堂内的尸体忽然破棺而出,到底是诈尸还是另有隐情,我是刑警宁泽,带...
    沈念sama阅读 33,387评论 4 319
  • 正文 年R本政府宣布,位于F岛的核电站,受9级特大地震影响,放射性物质发生泄漏。R本人自食恶果不足惜,却给世界环境...
    茶点故事阅读 38,971评论 3 307
  • 文/蒙蒙 一、第九天 我趴在偏房一处隐蔽的房顶上张望。 院中可真热闹,春花似锦、人声如沸。这庄子的主人今日做“春日...
    开封第一讲书人阅读 29,947评论 0 19
  • 文/苍兰香墨 我抬头看了看天上的太阳。三九已至,却和暖如春,着一层夹袄步出监牢的瞬间,已是汗流浃背。 一阵脚步声响...
    开封第一讲书人阅读 31,189评论 1 260
  • 我被黑心中介骗来泰国打工, 没想到刚下飞机就差点儿被人妖公主榨干…… 1. 我叫王不留,地道东北人。 一个月前我还...
    沈念sama阅读 44,805评论 2 349
  • 正文 我出身青楼,却偏偏与公主长得像,于是被迫代替她去往敌国和亲。 传闻我的和亲对象是个残疾皇子,可洞房花烛夜当晚...
    茶点故事阅读 42,449评论 2 342