Created
August 21, 2017 02:15
-
-
Save omochi/0784cf73c95460bd461416e4834be0cd to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
sil_stage raw | |
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>>>): | |
// function_ref main() | |
%2 = function_ref @_T01a4mainyyF : $@convention(thin) () -> () // user: %3 | |
%3 = apply %2() : $@convention(thin) () -> () | |
%4 = integer_literal $Builtin.Int32, 0 // user: %5 | |
%5 = struct $Int32 (%4 : $Builtin.Int32) // user: %6 | |
return %5 : $Int32 // id: %6 | |
} // end sil function 'main' | |
// variable initialization expression of Cat.age | |
sil hidden [transparent] @_T01a3CatC3ageSivfi : $@convention(thin) () -> Int { | |
bb0: | |
// function_ref Int.init(_builtinIntegerLiteral:) | |
%0 = function_ref @_T0S2iBi2048_22_builtinIntegerLiteral_tcfC : $@convention(method) (Builtin.Int2048, @thin Int.Type) -> Int // user: %3 | |
%1 = metatype $@thin Int.Type // user: %3 | |
%2 = integer_literal $Builtin.Int2048, 0 // user: %3 | |
%3 = apply %0(%2, %1) : $@convention(method) (Builtin.Int2048, @thin Int.Type) -> Int // user: %4 | |
return %3 : $Int // id: %4 | |
} // end sil function '_T01a3CatC3ageSivfi' | |
// Int.init(_builtinIntegerLiteral:) | |
sil [transparent] [serialized] @_T0S2iBi2048_22_builtinIntegerLiteral_tcfC : $@convention(method) (Builtin.Int2048, @thin Int.Type) -> Int | |
// Cat.age.getter | |
sil hidden [transparent] @_T01a3CatC3ageSifg : $@convention(method) (@guaranteed Cat) -> Int { | |
// %0 // users: %2, %1 | |
bb0(%0 : $Cat): | |
debug_value %0 : $Cat, let, name "self", argno 1 // id: %1 | |
%2 = ref_element_addr %0 : $Cat, #Cat.age // user: %3 | |
%3 = begin_access [read] [dynamic] %2 : $*Int // users: %5, %4 | |
%4 = load [trivial] %3 : $*Int // user: %6 | |
end_access %3 : $*Int // id: %5 | |
return %4 : $Int // id: %6 | |
} // end sil function '_T01a3CatC3ageSifg' | |
// Cat.age.setter | |
sil hidden [transparent] @_T01a3CatC3ageSifs : $@convention(method) (Int, @guaranteed Cat) -> () { | |
// %0 // users: %6, %2 | |
// %1 // users: %4, %3 | |
bb0(%0 : $Int, %1 : $Cat): | |
debug_value %0 : $Int, let, name "value", argno 1 // id: %2 | |
debug_value %1 : $Cat, let, name "self", argno 2 // id: %3 | |
%4 = ref_element_addr %1 : $Cat, #Cat.age // user: %5 | |
%5 = begin_access [modify] [dynamic] %4 : $*Int // users: %7, %6 | |
assign %0 to %5 : $*Int // id: %6 | |
end_access %5 : $*Int // id: %7 | |
%8 = tuple () // user: %9 | |
return %8 : $() // id: %9 | |
} // end sil function '_T01a3CatC3ageSifs' | |
// closure #1 in Cat.age.materializeForSet | |
sil private [transparent] @_T01a3CatC3ageSifmytfU_ : $@convention(method) (Builtin.RawPointer, @inout Builtin.UnsafeValueBuffer, @inout Cat, @thick Cat.Type) -> () { | |
// %1 // user: %4 | |
bb0(%0 : $Builtin.RawPointer, %1 : $*Builtin.UnsafeValueBuffer, %2 : $*Cat, %3 : $@thick Cat.Type): | |
end_unpaired_access [dynamic] %1 : $*Builtin.UnsafeValueBuffer // id: %4 | |
%5 = tuple () // user: %6 | |
return %5 : $() // id: %6 | |
} // end sil function '_T01a3CatC3ageSifmytfU_' | |
// Cat.age.materializeForSet | |
sil hidden [transparent] @_T01a3CatC3ageSifm : $@convention(method) (Builtin.RawPointer, @inout Builtin.UnsafeValueBuffer, @guaranteed Cat) -> (Builtin.RawPointer, Optional<Builtin.RawPointer>) { | |
// %1 // user: %4 | |
// %2 // user: %3 | |
bb0(%0 : $Builtin.RawPointer, %1 : $*Builtin.UnsafeValueBuffer, %2 : $Cat): | |
%3 = ref_element_addr %2 : $Cat, #Cat.age // users: %5, %4 | |
%4 = begin_unpaired_access [modify] [dynamic] %3 : $*Int, %1 : $*Builtin.UnsafeValueBuffer | |
%5 = address_to_pointer %3 : $*Int to $Builtin.RawPointer // user: %9 | |
// function_ref closure #1 in Cat.age.materializeForSet | |
%6 = function_ref @_T01a3CatC3ageSifmytfU_ : $@convention(method) (Builtin.RawPointer, @inout Builtin.UnsafeValueBuffer, @inout Cat, @thick Cat.Type) -> () // user: %7 | |
%7 = thin_function_to_pointer %6 : $@convention(method) (Builtin.RawPointer, @inout Builtin.UnsafeValueBuffer, @inout Cat, @thick Cat.Type) -> () to $Builtin.RawPointer // user: %8 | |
%8 = enum $Optional<Builtin.RawPointer>, #Optional.some!enumelt.1, %7 : $Builtin.RawPointer // user: %9 | |
%9 = tuple (%5 : $Builtin.RawPointer, %8 : $Optional<Builtin.RawPointer>) // user: %10 | |
return %9 : $(Builtin.RawPointer, Optional<Builtin.RawPointer>) // id: %10 | |
} // end sil function '_T01a3CatC3ageSifm' | |
// Cat.deinit | |
sil hidden @_T01a3CatCfd : $@convention(method) (@guaranteed Cat) -> @owned Builtin.NativeObject { | |
// %0 // users: %2, %1 | |
bb0(%0 : $Cat): | |
debug_value %0 : $Cat, let, name "self", argno 1 // id: %1 | |
%2 = unchecked_ref_cast %0 : $Cat to $Builtin.NativeObject // user: %3 | |
%3 = unchecked_ownership_conversion %2 : $Builtin.NativeObject, @guaranteed to @owned // user: %4 | |
return %3 : $Builtin.NativeObject // id: %4 | |
} // end sil function '_T01a3CatCfd' | |
// Cat.__deallocating_deinit | |
sil hidden @_T01a3CatCfD : $@convention(method) (@owned Cat) -> () { | |
// %0 // users: %6, %5, %3, %1 | |
bb0(%0 : $Cat): | |
debug_value %0 : $Cat, let, name "self", argno 1 // id: %1 | |
// function_ref Cat.deinit | |
%2 = function_ref @_T01a3CatCfd : $@convention(method) (@guaranteed Cat) -> @owned Builtin.NativeObject // user: %4 | |
%3 = begin_borrow %0 : $Cat // users: %5, %4 | |
%4 = apply %2(%3) : $@convention(method) (@guaranteed Cat) -> @owned Builtin.NativeObject // user: %7 | |
end_borrow %3 from %0 : $Cat, $Cat // id: %5 | |
end_lifetime %0 : $Cat // id: %6 | |
%7 = unchecked_ref_cast %4 : $Builtin.NativeObject to $Cat // user: %8 | |
dealloc_ref %7 : $Cat // id: %8 | |
%9 = tuple () // user: %10 | |
return %9 : $() // id: %10 | |
} // end sil function '_T01a3CatCfD' | |
// Cat.__allocating_init() | |
sil hidden @_T01a3CatCACycfC : $@convention(method) (@thick Cat.Type) -> @owned Cat { | |
bb0(%0 : $@thick Cat.Type): | |
%1 = alloc_ref $Cat // user: %3 | |
// function_ref Cat.init() | |
%2 = function_ref @_T01a3CatCACycfc : $@convention(method) (@owned Cat) -> @owned Cat // user: %3 | |
%3 = apply %2(%1) : $@convention(method) (@owned Cat) -> @owned Cat // user: %4 | |
return %3 : $Cat // id: %4 | |
} // end sil function '_T01a3CatCACycfC' | |
// Cat.init() | |
sil hidden @_T01a3CatCACycfc : $@convention(method) (@owned Cat) -> @owned Cat { | |
// %0 // users: %2, %1 | |
bb0(%0 : $Cat): | |
debug_value %0 : $Cat, let, name "self" // id: %1 | |
%2 = mark_uninitialized [rootself] %0 : $Cat // users: %12, %11, %10, %5 | |
// function_ref variable initialization expression of Cat.age | |
%3 = function_ref @_T01a3CatC3ageSivfi : $@convention(thin) () -> Int // user: %4 | |
%4 = apply %3() : $@convention(thin) () -> Int // user: %8 | |
%5 = begin_borrow %2 : $Cat // users: %10, %6 | |
%6 = ref_element_addr %5 : $Cat, #Cat.age // user: %7 | |
%7 = begin_access [modify] [dynamic] %6 : $*Int // users: %9, %8 | |
assign %4 to %7 : $*Int // id: %8 | |
end_access %7 : $*Int // id: %9 | |
end_borrow %5 from %2 : $Cat, $Cat // id: %10 | |
%11 = copy_value %2 : $Cat // user: %13 | |
destroy_value %2 : $Cat // id: %12 | |
return %11 : $Cat // id: %13 | |
} // end sil function '_T01a3CatCACycfc' | |
// f2(_:) | |
sil hidden @_T01a2f2ySizF : $@convention(thin) (@inout Int) -> () { | |
// %0 // users: %6, %1 | |
bb0(%0 : $*Int): | |
debug_value_addr %0 : $*Int, var, name "x", argno 1 // id: %1 | |
// function_ref Int.init(_builtinIntegerLiteral:) | |
%2 = function_ref @_T0S2iBi2048_22_builtinIntegerLiteral_tcfC : $@convention(method) (Builtin.Int2048, @thin Int.Type) -> Int // user: %5 | |
%3 = metatype $@thin Int.Type // user: %5 | |
%4 = integer_literal $Builtin.Int2048, 33 // user: %5 | |
%5 = apply %2(%4, %3) : $@convention(method) (Builtin.Int2048, @thin Int.Type) -> Int // user: %7 | |
%6 = begin_access [modify] [unknown] %0 : $*Int // users: %8, %7 | |
assign %5 to %6 : $*Int // id: %7 | |
end_access %6 : $*Int // id: %8 | |
%9 = tuple () // user: %10 | |
return %9 : $() // id: %10 | |
} // end sil function '_T01a2f2ySizF' | |
// main() | |
sil hidden @_T01a4mainyyF : $@convention(thin) () -> () { | |
bb0: | |
// function_ref f2(_:) | |
%0 = function_ref @_T01a2f2ySizF : $@convention(thin) (@inout Int) -> () // user: %15 | |
// function_ref Cat.__allocating_init() | |
%1 = function_ref @_T01a3CatCACycfC : $@convention(method) (@thick Cat.Type) -> @owned Cat // user: %3 | |
%2 = metatype $@thick Cat.Type // user: %3 | |
%3 = apply %1(%2) : $@convention(method) (@thick Cat.Type) -> @owned Cat // users: %28, %20, %14, %13, %6 | |
%4 = alloc_stack $Builtin.UnsafeValueBuffer // users: %27, %23, %9 | |
%5 = alloc_stack $Int // users: %26, %7 | |
%6 = begin_borrow %3 : $Cat // users: %14, %9, %8 | |
%7 = address_to_pointer %5 : $*Int to $Builtin.RawPointer // user: %9 | |
%8 = class_method %6 : $Cat, #Cat.age!materializeForSet.1 : (Cat) -> (Builtin.RawPointer, inout Builtin.UnsafeValueBuffer) -> (Builtin.RawPointer, Builtin.RawPointer?), $@convention(method) (Builtin.RawPointer, @inout Builtin.UnsafeValueBuffer, @guaranteed Cat) -> (Builtin.RawPointer, Optional<Builtin.RawPointer>) // user: %9 | |
%9 = apply %8(%7, %4, %6) : $@convention(method) (Builtin.RawPointer, @inout Builtin.UnsafeValueBuffer, @guaranteed Cat) -> (Builtin.RawPointer, Optional<Builtin.RawPointer>) // users: %11, %10 | |
%10 = tuple_extract %9 : $(Builtin.RawPointer, Optional<Builtin.RawPointer>), 0 // user: %12 | |
%11 = tuple_extract %9 : $(Builtin.RawPointer, Optional<Builtin.RawPointer>), 1 // user: %16 | |
%12 = pointer_to_address %10 : $Builtin.RawPointer to [strict] $*Int // user: %13 | |
%13 = mark_dependence %12 : $*Int on %3 : $Cat // users: %22, %15 | |
end_borrow %6 from %3 : $Cat, $Cat // id: %14 | |
%15 = apply %0(%13) : $@convention(thin) (@inout Int) -> () | |
switch_enum %11 : $Optional<Builtin.RawPointer>, case #Optional.some!enumelt.1: bb1, case #Optional.none!enumelt: bb2 // id: %16 | |
// %17 // user: %18 | |
bb1(%17 : $Builtin.RawPointer): // Preds: bb0 | |
%18 = pointer_to_thin_function %17 : $Builtin.RawPointer to $@convention(method) (Builtin.RawPointer, @inout Builtin.UnsafeValueBuffer, @inout Cat, @thick Cat.Type) -> () // user: %23 | |
%19 = alloc_stack $Cat // users: %24, %23, %20 | |
store %3 to [init] %19 : $*Cat // id: %20 | |
%21 = metatype $@thick Cat.Type // user: %23 | |
%22 = address_to_pointer %13 : $*Int to $Builtin.RawPointer // user: %23 | |
%23 = apply %18(%22, %4, %19, %21) : $@convention(method) (Builtin.RawPointer, @inout Builtin.UnsafeValueBuffer, @inout Cat, @thick Cat.Type) -> () | |
dealloc_stack %19 : $*Cat // id: %24 | |
br bb2 // id: %25 | |
bb2: // Preds: bb1 bb0 | |
dealloc_stack %5 : $*Int // id: %26 | |
dealloc_stack %4 : $*Builtin.UnsafeValueBuffer // id: %27 | |
destroy_value %3 : $Cat // id: %28 | |
%29 = tuple () // user: %30 | |
return %29 : $() // id: %30 | |
} // end sil function '_T01a4mainyyF' | |
sil_vtable Cat { | |
#Cat.age!getter.1: (Cat) -> () -> Int : _T01a3CatC3ageSifg // Cat.age.getter | |
#Cat.age!setter.1: (Cat) -> (Int) -> () : _T01a3CatC3ageSifs // Cat.age.setter | |
#Cat.age!materializeForSet.1: (Cat) -> (Builtin.RawPointer, inout Builtin.UnsafeValueBuffer) -> (Builtin.RawPointer, Builtin.RawPointer?) : _T01a3CatC3ageSifm // Cat.age.materializeForSet | |
#Cat.init!initializer.1: (Cat.Type) -> () -> Cat : _T01a3CatCACycfc // Cat.init() | |
#Cat.deinit!deallocator: _T01a3CatCfD // Cat.__deallocating_deinit | |
} | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Cat { | |
var age: Int = 0 | |
} | |
func f2(_ x: inout Int) { | |
x = 33 | |
} | |
func main() { | |
f2(&Cat().age) | |
} | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment