1 ; RUN: opt -S -wholeprogramdevirt %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 (i32 (i8*, i32)* @vf1 to i8*)], !type !0
7 @vt2 = constant [1 x i8*] [i8* bitcast (i32 (i8*, i32)* @vf2 to i8*)], !type !0
9 declare i32 @vf1(i8* %this, i32 %arg) readnone
11 define i32 @vf2(i8* %this, i32 %arg) readnone {
15 ; CHECK: define i32 @fn
16 define i32 @fn(i8* %obj) {
17 %vtableptr = bitcast i8* %obj to [1 x i8*]**
18 %vtable = load [1 x i8*]*, [1 x i8*]** %vtableptr
19 %vtablei8 = bitcast [1 x i8*]* %vtable to i8*
20 %p = call i1 @llvm.type.test(i8* %vtablei8, metadata !"typeid")
21 call void @llvm.assume(i1 %p)
22 %fptrptr = getelementptr [1 x i8*], [1 x i8*]* %vtable, i32 0, i32 0
23 %fptr = load i8*, i8** %fptrptr
24 %fptr_casted = bitcast i8* %fptr to i32 (i8*, i32)*
26 %result = call i32 %fptr_casted(i8* %obj, i32 1)
29 declare i1 @llvm.type.test(i8*, metadata)
30 declare void @llvm.assume(i1)
32 !0 = !{i32 0, !"typeid"}