1 ; RUN: opt -S -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 i8*] [i8* bitcast (i1 (i8*)* @vf0 to i8*)], !type !0
7 @vt2 = constant [1 x i8*] [i8* bitcast (i1 (i8*)* @vf0 to i8*)], !type !0, !type !1
8 @vt3 = constant [1 x i8*] [i8* bitcast (i1 (i8*)* @vf1 to i8*)], !type !0, !type !1
9 @vt4 = constant [1 x i8*] [i8* bitcast (i1 (i8*)* @vf1 to i8*)], !type !1
11 define i1 @vf0(i8* %this) readnone {
15 define i1 @vf1(i8* %this) readnone {
19 ; CHECK: define i1 @call
20 define i1 @call(i8* %obj) {
21 %vtableptr = bitcast i8* %obj to [1 x i8*]**
22 %vtable = load [1 x i8*]*, [1 x i8*]** %vtableptr
23 %vtablei8 = bitcast [1 x i8*]* %vtable to i8*
24 %p = call i1 @llvm.type.test(i8* %vtablei8, metadata !"typeid1")
25 call void @llvm.assume(i1 %p)
26 %p2 = call i1 @llvm.type.test(i8* %vtablei8, metadata !"typeid1")
27 call void @llvm.assume(i1 %p2)
28 %fptrptr = getelementptr [1 x i8*], [1 x i8*]* %vtable, i32 0, i32 0
29 %fptr = load i8*, i8** %fptrptr
30 %fptr_casted = bitcast i8* %fptr to i1 (i8*)*
31 ; CHECK: [[RES1:%[^ ]*]] = icmp eq [1 x i8*]* %vtable, @vt3
32 %result = call i1 %fptr_casted(i8* %obj)
33 ; CHECK: ret i1 [[RES1]]
37 declare i1 @llvm.type.test(i8*, metadata)
38 declare void @llvm.assume(i1)
40 !0 = !{i32 0, !"typeid1"}
41 !1 = !{i32 0, !"typeid2"}