1; RUN: opt -S -wholeprogramdevirt -whole-program-visibility %s | FileCheck %s 2 3target datalayout = "e-p:64:64" 4target triple = "x86_64-unknown-linux-gnu" 5 6@vt1 = constant [1 x i8*] [i8* bitcast (i32 (i8*)* @vf1 to i8*)], !type !0 7@vt2 = constant [1 x i8*] [i8* bitcast (i32 (i8*)* @vf2 to i8*)], !type !0 8 9define i32 @vf1(i8* %this) readnone { 10 %this_int = ptrtoint i8* %this to i32 11 ret i32 %this_int 12} 13 14define i32 @vf2(i8* %this) readnone { 15 %this_int = ptrtoint i8* %this to i32 16 ret i32 %this_int 17} 18 19; CHECK: define i32 @call 20define i32 @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 !"typeid") 25 call void @llvm.assume(i1 %p) 26 %fptrptr = getelementptr [1 x i8*], [1 x i8*]* %vtable, i32 0, i32 0 27 %fptr = load i8*, i8** %fptrptr 28 %fptr_casted = bitcast i8* %fptr to i32 (i8*)* 29 ; CHECK: call i32 % 30 %result = call i32 %fptr_casted(i8* %obj) 31 ret i32 %result 32} 33 34declare i1 @llvm.type.test(i8*, metadata) 35declare void @llvm.assume(i1) 36 37!0 = !{i32 0, !"typeid"} 38