|
| 1 | +// Tests that under -enable-llvm-wme, IRGen marks wtables and wcall sites with |
| 2 | +// the right attributes and intrinsics. |
| 3 | + |
| 4 | +// RUN: %target-build-swift -Xfrontend -disable-objc-interop -Xfrontend -enable-llvm-wme \ |
| 5 | +// RUN: -Xfrontend -enable-relative-protocol-witness-tables \ |
| 6 | +// RUN: %s -emit-ir -o - | %FileCheck %s --check-prefix=CHECK --check-prefix=CHECK-%target-ptrsize |
| 7 | + |
| 8 | +// REQUIRES: PTRSIZE=64 |
| 9 | + |
| 10 | +protocol TheProtocol { |
| 11 | + func func1_live() |
| 12 | + func func2_dead() |
| 13 | +} |
| 14 | + |
| 15 | +struct MyStruct : TheProtocol { |
| 16 | + func func1_live() { print("MyStruct.func1_live") } |
| 17 | + func func2_dead() { print("MyStruct.func2_dead") } |
| 18 | +} |
| 19 | + |
| 20 | + |
| 21 | +// CHECK: @"$s4main8MyStructVAA11TheProtocolAAWP" = |
| 22 | +// CHECK-SAME: hidden constant [3 x i32] |
| 23 | +// CHECK-SAME: i32 trunc {{.*}} @"$s4main8MyStructVAA11TheProtocolAAMc" |
| 24 | +// CHECK-SAME: i32 trunc {{.*}} @"$s4main8MyStructVAA11TheProtocolA2aDP10func1_liveyyFTW" |
| 25 | +// CHECK-SAME: i32 trunc {{.*}} @"$s4main8MyStructVAA11TheProtocolA2aDP10func2_deadyyFTW" |
| 26 | +// CHECK-SAME: ], align 8, !type !0, !type !1, !vcall_visibility !2, !typed_global_not_for_cfi !3 |
| 27 | + |
| 28 | +func test1() { |
| 29 | + // CHECK: define hidden swiftcc void @"$s4main5test1yyF"() |
| 30 | + let x: MyStruct = MyStruct() |
| 31 | + x.func1_live() |
| 32 | + // CHECK: call swiftcc void @"$s4main8MyStructVACycfC"() |
| 33 | + // CHECK-NEXT: call swiftcc void @"$s4main8MyStructV10func1_liveyyF"() |
| 34 | + // CHECK-NEXT: ret void |
| 35 | +} |
| 36 | + |
| 37 | +func test2() { |
| 38 | + // CHECK: define hidden swiftcc void @"$s4main5test2yyF"() |
| 39 | + let x: TheProtocol = MyStruct() |
| 40 | + x.func1_live() |
| 41 | + // CHECK: [[TBL:%.*]] = phi i8** |
| 42 | + // CHECK: [[TBL2:%.*]] = bitcast i8** [[TBL]] to i32* |
| 43 | + // CHECK: [[ENTRY:%.*]] = getelementptr inbounds i32, i32* [[TBL2]], i32 1 |
| 44 | + // CHECK: [[ENTRY2:%.*]] = bitcast i32* [[ENTRY]] to i8* |
| 45 | + // CHECK: call { i8*, i1 } @llvm.type.checked.load.relative(i8* [[ENTRY2]], i32 0, metadata !"$s4main11TheProtocolP10func1_liveyyFTq") |
| 46 | +} |
| 47 | + |
| 48 | +// CHECK: !0 = !{i64 4, !"$s4main11TheProtocolP10func1_liveyyFTq"} |
| 49 | +// CHECK: !1 = !{i64 8, !"$s4main11TheProtocolP10func2_deadyyFTq"} |
| 50 | +// CHECK: !2 = !{i64 1, i64 4, i64 12} |
| 51 | +// CHECK: !3 = !{} |
0 commit comments