-
-
Save rintaro/0aa9c71409eacc5af24e60ed5744c0cf 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 canonical | |
import Builtin | |
import Swift | |
import SwiftShims | |
public protocol P { | |
func foo() | |
} | |
public struct S<T> : P { | |
@_hasStorage var x: T { get set } | |
public __consuming func foo() | |
init(x: T) | |
} | |
public func testing<T>(c: T) where T : P | |
// 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' | |
// S.foo() | |
sil @$s4test1SV3fooyyF : $@convention(method) <T> (@in S<T>) -> () { | |
// %0 // users: %2, %1 | |
bb0(%0 : $*S<T>): | |
debug_value_addr %0 : $*S<T>, let, name "self", argno 1 // id: %1 | |
destroy_addr %0 : $*S<T> // id: %2 | |
%3 = tuple () // user: %4 | |
return %3 : $() // id: %4 | |
} // end sil function '$s4test1SV3fooyyF' | |
// protocol witness for P.foo() in conformance S<A> | |
sil shared [transparent] [serialized] [thunk] @$s4test1SVyxGAA1PA2aEP3fooyyFTW : $@convention(witness_method: P) <τ_0_0> (@in_guaranteed S<τ_0_0>) -> () { | |
// %0 // user: %2 | |
bb0(%0 : $*S<τ_0_0>): | |
// function_ref S.foo() | |
%1 = function_ref @$s4test1SV3fooyyF : $@convention(method) <τ_0_0> (@in S<τ_0_0>) -> () // user: %2 | |
%2 = apply %1<τ_0_0>(%0) : $@convention(method) <τ_0_0> (@in S<τ_0_0>) -> () | |
%3 = tuple () // user: %4 | |
return %3 : $() // id: %4 | |
} // end sil function '$s4test1SVyxGAA1PA2aEP3fooyyFTW' | |
// testing<A>(c:) | |
sil @$s4test7testing1cyx_tAA1PRzlF : $@convention(thin) <T where T : P> (@in_guaranteed T) -> () { | |
// %0 // users: %3, %1 | |
bb0(%0 : $*T): | |
debug_value_addr %0 : $*T, let, name "c", argno 1 // id: %1 | |
%2 = witness_method $T, #P.foo!1 : <Self where Self : P> (Self) -> () -> () : $@convention(witness_method: P) <τ_0_0 where τ_0_0 : P> (@in_guaranteed τ_0_0) -> () // user: %3 | |
%3 = apply %2<T>(%0) : $@convention(witness_method: P) <τ_0_0 where τ_0_0 : P> (@in_guaranteed τ_0_0) -> () | |
%4 = tuple () // user: %5 | |
return %4 : $() // id: %5 | |
} // end sil function '$s4test7testing1cyx_tAA1PRzlF' | |
sil_witness_table [serialized] <T> S<T>: P module test { | |
method #P.foo!1: <Self where Self : P> (Self) -> () -> () : @$s4test1SVyxGAA1PA2aEP3fooyyFTW // protocol witness for P.foo() in conformance S<A> | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment