1*9880d681SAndroid Build Coastguard Worker; RUN: opt -S -wholeprogramdevirt %s | FileCheck %s 2*9880d681SAndroid Build Coastguard Worker 3*9880d681SAndroid Build Coastguard Workertarget datalayout = "e-p:64:64" 4*9880d681SAndroid Build Coastguard Workertarget triple = "x86_64-unknown-linux-gnu" 5*9880d681SAndroid Build Coastguard Worker 6*9880d681SAndroid Build Coastguard Worker@vt1 = constant [1 x i8*] [i8* bitcast (i1 (i8*)* @vf0 to i8*)], !type !0 7*9880d681SAndroid Build Coastguard Worker@vt2 = constant [1 x i8*] [i8* bitcast (i1 (i8*)* @vf0 to i8*)], !type !0, !type !1 8*9880d681SAndroid Build Coastguard Worker@vt3 = constant [1 x i8*] [i8* bitcast (i1 (i8*)* @vf1 to i8*)], !type !0, !type !1 9*9880d681SAndroid Build Coastguard Worker@vt4 = constant [1 x i8*] [i8* bitcast (i1 (i8*)* @vf1 to i8*)], !type !1 10*9880d681SAndroid Build Coastguard Worker 11*9880d681SAndroid Build Coastguard Workerdefine i1 @vf0(i8* %this) readnone { 12*9880d681SAndroid Build Coastguard Worker ret i1 0 13*9880d681SAndroid Build Coastguard Worker} 14*9880d681SAndroid Build Coastguard Worker 15*9880d681SAndroid Build Coastguard Workerdefine i1 @vf1(i8* %this) readnone { 16*9880d681SAndroid Build Coastguard Worker ret i1 1 17*9880d681SAndroid Build Coastguard Worker} 18*9880d681SAndroid Build Coastguard Worker 19*9880d681SAndroid Build Coastguard Worker; CHECK: define i1 @call1 20*9880d681SAndroid Build Coastguard Workerdefine i1 @call1(i8* %obj) { 21*9880d681SAndroid Build Coastguard Worker %vtableptr = bitcast i8* %obj to [1 x i8*]** 22*9880d681SAndroid Build Coastguard Worker %vtable = load [1 x i8*]*, [1 x i8*]** %vtableptr 23*9880d681SAndroid Build Coastguard Worker ; CHECK: [[VT1:%[^ ]*]] = bitcast [1 x i8*]* {{.*}} to i8* 24*9880d681SAndroid Build Coastguard Worker %vtablei8 = bitcast [1 x i8*]* %vtable to i8* 25*9880d681SAndroid Build Coastguard Worker %p = call i1 @llvm.type.test(i8* %vtablei8, metadata !"typeid1") 26*9880d681SAndroid Build Coastguard Worker call void @llvm.assume(i1 %p) 27*9880d681SAndroid Build Coastguard Worker %fptrptr = getelementptr [1 x i8*], [1 x i8*]* %vtable, i32 0, i32 0 28*9880d681SAndroid Build Coastguard Worker %fptr = load i8*, i8** %fptrptr 29*9880d681SAndroid Build Coastguard Worker %fptr_casted = bitcast i8* %fptr to i1 (i8*)* 30*9880d681SAndroid Build Coastguard Worker ; CHECK: [[RES1:%[^ ]*]] = icmp eq i8* [[VT1]], bitcast ([1 x i8*]* @vt3 to i8*) 31*9880d681SAndroid Build Coastguard Worker %result = call i1 %fptr_casted(i8* %obj) 32*9880d681SAndroid Build Coastguard Worker ; CHECK: ret i1 [[RES1]] 33*9880d681SAndroid Build Coastguard Worker ret i1 %result 34*9880d681SAndroid Build Coastguard Worker} 35*9880d681SAndroid Build Coastguard Worker 36*9880d681SAndroid Build Coastguard Worker; CHECK: define i1 @call2 37*9880d681SAndroid Build Coastguard Workerdefine i1 @call2(i8* %obj) { 38*9880d681SAndroid Build Coastguard Worker %vtableptr = bitcast i8* %obj to [1 x i8*]** 39*9880d681SAndroid Build Coastguard Worker %vtable = load [1 x i8*]*, [1 x i8*]** %vtableptr 40*9880d681SAndroid Build Coastguard Worker ; CHECK: [[VT2:%[^ ]*]] = bitcast [1 x i8*]* {{.*}} to i8* 41*9880d681SAndroid Build Coastguard Worker %vtablei8 = bitcast [1 x i8*]* %vtable to i8* 42*9880d681SAndroid Build Coastguard Worker %p = call i1 @llvm.type.test(i8* %vtablei8, metadata !"typeid2") 43*9880d681SAndroid Build Coastguard Worker call void @llvm.assume(i1 %p) 44*9880d681SAndroid Build Coastguard Worker %fptrptr = getelementptr [1 x i8*], [1 x i8*]* %vtable, i32 0, i32 0 45*9880d681SAndroid Build Coastguard Worker %fptr = load i8*, i8** %fptrptr 46*9880d681SAndroid Build Coastguard Worker %fptr_casted = bitcast i8* %fptr to i1 (i8*)* 47*9880d681SAndroid Build Coastguard Worker ; CHECK: [[RES1:%[^ ]*]] = icmp ne i8* [[VT1]], bitcast ([1 x i8*]* @vt2 to i8*) 48*9880d681SAndroid Build Coastguard Worker %result = call i1 %fptr_casted(i8* %obj) 49*9880d681SAndroid Build Coastguard Worker ret i1 %result 50*9880d681SAndroid Build Coastguard Worker} 51*9880d681SAndroid Build Coastguard Worker 52*9880d681SAndroid Build Coastguard Workerdeclare i1 @llvm.type.test(i8*, metadata) 53*9880d681SAndroid Build Coastguard Workerdeclare void @llvm.assume(i1) 54*9880d681SAndroid Build Coastguard Worker 55*9880d681SAndroid Build Coastguard Worker!0 = !{i32 0, !"typeid1"} 56*9880d681SAndroid Build Coastguard Worker!1 = !{i32 0, !"typeid2"} 57