1 ; RUN: opt -S -passes=wholeprogramdevirt -whole-program-visibility %s | FileCheck %s
3 target datalayout = "e-p:64:64"
4 target triple = "x86_64-unknown-linux-gnu"
6 @vt1 = constant [1 x ptr] [ptr @vf], !type !0
7 @vt2 = constant [1 x ptr] [ptr @vf], !type !0
9 define void @vf(ptr %this) {
13 ; CHECK: define void @call
14 define void @call(ptr %obj) {
15 %vtable = load ptr, ptr %obj
16 %p = call i1 @llvm.type.test(ptr %vtable, metadata !"typeid")
17 call void @llvm.assume(i1 %p)
18 %p2 = call i1 @llvm.type.test(ptr %vtable, metadata !"typeid")
19 call void @llvm.assume(i1 %p2)
20 %fptr = load ptr, ptr %vtable
21 ; CHECK: call void @vf(
22 call void %fptr(ptr %obj)
26 declare ptr @llvm.load.relative.i32(ptr, i32)
28 @vt3 = private unnamed_addr constant [1 x i32] [
29 i32 trunc (i64 sub (i64 ptrtoint (ptr dso_local_equivalent @vf to i64), i64 ptrtoint (ptr @vt3 to i64)) to i32)
32 ; CHECK: define void @call2
33 define void @call2(ptr %obj) {
34 %vtable = load ptr, ptr %obj
35 %p = call i1 @llvm.type.test(ptr %vtable, metadata !"typeid2")
36 call void @llvm.assume(i1 %p)
37 %p2 = call i1 @llvm.type.test(ptr %vtable, metadata !"typeid2")
38 call void @llvm.assume(i1 %p2)
39 %fptr = call ptr @llvm.load.relative.i32(ptr %vtable, i32 0)
40 ; CHECK: call void @vf(
41 call void %fptr(ptr %obj)
45 declare i1 @llvm.type.test(ptr, metadata)
46 declare void @llvm.assume(i1)
48 !0 = !{i32 0, !"typeid"}
49 !1 = !{i32 0, !"typeid2"}