Files
swift-mirror/test/SILOptimizer/sil_combine_devirt.sil
Roman Levenstein 8ad61d5cd6 Use function signatures for SILDeclRefs in witness_tables, vtables and witness_method instructions.
Textual SIL was sometimes ambiguous when SILDeclRefs were used, because the textual representation of SILDeclRefs was the same for functions that have the same name, but different signatures.
2017-01-27 12:16:14 -08:00

55 lines
1.8 KiB
Plaintext

// RUN: %target-sil-opt -assume-parsing-unqualified-ownership-sil -enable-sil-verify-all %s -devirtualizer | %FileCheck %s
sil_stage canonical
import Builtin
import Swift
/*
class Foo {
var m_val : Int32
init(x : Int32) { m_val = x }
func get() -> Int32 {return m_val}
}
func test_me(x : Int32) -> Foo { return Foo(x) }
func main() { print(test_me(3).get()) } */
class Foo {
var m_val: Int32
init(x: Int32)
func get() -> Int32
}
//CHECK: _TF4main4mainFT_T_
//CHECK: function_ref @_TFC4main3Foo3getfS0_FT_Si
//CHECK: return
sil @_TF4main4mainFT_T_ : $@convention(thin) () -> () {
bb0:
// function_ref swift
%0 = function_ref @_Ts5printFT3valSi_T_ : $@convention(thin) (Int32) -> () // user: %8
%1 = integer_literal $Builtin.Int32, 3 // user: %2
%2 = struct $Int32 (%1 : $Builtin.Int32) // user: %5
%3 = alloc_ref $Foo // users: %6, %7, %4
%4 = ref_element_addr %3 : $Foo, #Foo.m_val // user: %5
store %2 to %4 : $*Int32 // id: %5
%6 = class_method %3 : $Foo, #Foo.get!1 : (Foo) -> () -> Int32, $@convention(method) (@guaranteed Foo) -> Int32 // user: %7
%7 = apply %6(%3) : $@convention(method) (@guaranteed Foo) -> Int32 // user: %8
%8 = apply %0(%7) : $@convention(thin) (Int32) -> ()
%9 = tuple () // user: %10
return %9 : $() // id: %10
}
sil @_Ts5printFT3valSi_T_ : $@convention(thin) (Int32) -> ()
// main.Foo.get (main.Foo)() -> Swift.Int32
sil [noinline] @_TFC4main3Foo3getfS0_FT_Si : $@convention(method) (@guaranteed Foo) -> Int32 {
bb0(%0 : $Foo):
%1 = ref_element_addr %0 : $Foo, #Foo.m_val // user: %2
%2 = load %1 : $*Int32 // user: %4
return %2 : $Int32 // id: %4
}
sil_vtable Foo {
#Foo.get!1: _TFC4main3Foo3getfS0_FT_Si
}