Skip to content

Commit e4eef60

Browse files
authored
Merge pull request swiftlang#22283 from gottesmm/pr-cb343878fcc1fe04d940cc593956ceb81f870ebc
2 parents cf53143 + 229662a commit e4eef60

File tree

1 file changed

+43
-0
lines changed

1 file changed

+43
-0
lines changed
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
// RUN: %target-sil-opt -enable-sil-ownership -enable-sil-verify-all %s -sil-combine -devirtualizer -dce | %FileCheck %s
2+
3+
// REQUIRES: SR9831
4+
5+
sil_stage canonical
6+
7+
import Builtin
8+
import Swift
9+
import SwiftShims
10+
11+
class A {
12+
init(m: Int)
13+
convenience init(n: Int)
14+
func foo() -> Int32
15+
deinit
16+
}
17+
18+
// test.A.foo (test.A)() -> Swift.Int32
19+
sil hidden [noinline] [ossa] @_TFC4test1A3foofS0_FT_Vs5Int32 : $@convention(method) (@guaranteed A) -> Int32 {
20+
bb0(%0 : @guaranteed $A):
21+
%2 = integer_literal $Builtin.Int32, 1
22+
%3 = struct $Int32 (%2 : $Builtin.Int32)
23+
return %3 : $Int32
24+
}
25+
26+
// CHECK-LABEL: @test_alloc_ref_dynamic_devirt
27+
// CHECK-NOT: class_method
28+
// CHECK: function_ref @_TFC4test1A3foofS0_FT_Vs5Int32
29+
// CHECK: apply
30+
// CHECK: return
31+
sil [ossa] @test_alloc_ref_dynamic_devirt : $@convention(thin) () -> Int32 {
32+
bb0:
33+
%1 = metatype $@thick A.Type
34+
%2 = alloc_ref_dynamic %1 : $@thick A.Type, $A
35+
%8 = class_method %2 : $A, #A.foo!1 : (A) -> () -> Int32, $@convention(method) (@guaranteed A) -> Int32
36+
%9 = apply %8(%2) : $@convention(method) (@guaranteed A) -> Int32
37+
destroy_value %2 : $A
38+
return %9 : $Int32
39+
}
40+
41+
sil_vtable A {
42+
#A.foo!1: @_TFC4test1A3foofS0_FT_Vs5Int32
43+
}

0 commit comments

Comments
 (0)