1 ; RUN: opt -S -passes=wholeprogramdevirt -whole-program-visibility -pass-remarks=wholeprogramdevirt %s 2>&1 | FileCheck %s
3 target datalayout = "e-p:64:64"
4 target triple = "x86_64-unknown-linux-gnu"
6 ; CHECK: remark: <unknown>:0:0: single-impl: devirtualized a call to vf
7 ; CHECK: remark: <unknown>:0:0: single-impl: devirtualized a call to vf
8 ; CHECK: remark: <unknown>:0:0: devirtualized vf
9 ; CHECK-NOT: devirtualized
11 @vt1 = constant [1 x ptr] [ptr @vf], !type !0
12 @vt2 = constant [1 x ptr] [ptr @vf], !type !0
14 define void @vf(ptr %this) {
18 ; CHECK: define void @call
19 define void @call(ptr %obj) {
20 %vtable = load ptr, ptr %obj
21 %pair = call {ptr, i1} @llvm.type.checked.load(ptr %vtable, i32 0, metadata !"typeid")
22 %fptr = extractvalue {ptr, i1} %pair, 0
23 %p = extractvalue {ptr, i1} %pair, 1
25 br i1 %p, label %cont, label %trap
28 ; CHECK: call void @vf(
29 call void %fptr(ptr %obj)
33 call void @llvm.trap()
37 @vt3 = private unnamed_addr constant [1 x i32] [
38 i32 trunc (i64 sub (i64 ptrtoint (ptr dso_local_equivalent @vf to i64), i64 ptrtoint (ptr @vt3 to i64)) to i32)
41 ; CHECK: define void @call2
42 define void @call2(ptr %obj) {
43 %vtable = load ptr, ptr %obj
44 %pair = call {ptr, i1} @llvm.type.checked.load(ptr %vtable, i32 0, metadata !"typeid2")
45 %fptr = extractvalue {ptr, i1} %pair, 0
46 %p = extractvalue {ptr, i1} %pair, 1
48 br i1 %p, label %cont, label %trap
51 ; CHECK: call void @vf(
52 call void %fptr(ptr %obj)
56 call void @llvm.trap()
60 declare {ptr, i1} @llvm.type.checked.load(ptr, i32, metadata)
61 declare void @llvm.trap()
63 !0 = !{i32 0, !"typeid"}
64 !1 = !{i32 0, !"typeid2"}