美文网首页
Swift断言->SIL__ver.垃圾箱

Swift断言->SIL__ver.垃圾箱

作者: daikiZhou | 来源:发表于2019-12-16 18:42 被阅读0次

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




相关文章

  • Swift断言->SIL__ver.垃圾箱

    Swift断言 Swift提供了assert,precondition, fatalError三种断言方法。编程时...

  • Swift - 断言

    assert 这个主要是用在测试阶段,主要是用在测试阶段,符合条件,强制性抛出错误 release模式下,是不会执...

  • Swift3.0 对异常错误的处理

    在OC中,单元测试时我们会使用断言,断言中条件满足时会产生异常,并打印出相应的断言错误。而在Swift对异常的处理...

  • swift 自定义assert

    在Swift中,通过assert实现断言,assert可以帮助开发者比较容易的发现和定位错误一个断言断定条件是tr...

  • Swift可选绑定、断言

    可选绑定 (optional binding) 使用可选绑定(optional binding)来判断可选类型是否...

  • Swift中的断言

    1. 断言 1.1 使用断言进行调试 age >= 0为false,断言被触发,终止应用。 注意:当代码使用优化编...

  • swift基础—断言(Assertion)

    可选类型可以让你判断值是否存在,你可以在代码中优雅地处理值缺失的情况。然而,在某些情况下,如果值缺失或者值并不满足...

  • Swift 基础之断言

    可选可以让你判断值是否存在,你可以在代码中优雅地处理值缺失的情况。然而,在某些情况下,如果值缺失或者值并不满足特定...

  • Swift4.0基础语法笔记

    Swift 语言特性 面向对象 1.1 调试 断点 打印函数 断言 1.2 注释 1.3 捕获异常 2.数据类型 ...

  • 自学Swift之断言 assertion

    断言概念: 官方概念太无聊,并且冗余... 断言(assertion) 是一个全局函数 断言理解: 我理解的断言(...

网友评论

      本文标题:Swift断言->SIL__ver.垃圾箱

      本文链接:https://www.haomeiwen.com/subject/fdpdnctx.html