1 ; RUN: opt -S -wholeprogramdevirt %s | FileCheck %s
3 target datalayout = "e-p:64:64"
4 target triple = "x86_64-unknown-linux-gnu"
6 %vtTy = type { [2 x void (i8*)*], [2 x void (i8*)*] }
8 @vt = constant %vtTy { [2 x void (i8*)*] [void (i8*)* null, void (i8*)* @vf1], [2 x void (i8*)*] [void (i8*)* null, void (i8*)* @vf2] }, !type !0, !type !1
10 define void @vf1(i8* %this) {
14 define void @vf2(i8* %this) {
18 ; CHECK: define void @call1
19 define void @call1(i8* %obj) {
20 %vtableptr = bitcast i8* %obj to [1 x i8*]**
21 %vtable = load [1 x i8*]*, [1 x i8*]** %vtableptr
22 %vtablei8 = bitcast [1 x i8*]* %vtable to i8*
23 %p = call i1 @llvm.type.test(i8* %vtablei8, metadata !"typeid1")
24 call void @llvm.assume(i1 %p)
25 %fptrptr = getelementptr [1 x i8*], [1 x i8*]* %vtable, i32 0, i32 0
26 %fptr = load i8*, i8** %fptrptr
27 %fptr_casted = bitcast i8* %fptr to void (i8*)*
28 ; CHECK: call void @vf1(
29 call void %fptr_casted(i8* %obj)
33 ; CHECK: define void @call2
34 define void @call2(i8* %obj) {
35 %vtableptr = bitcast i8* %obj to [1 x i8*]**
36 %vtable = load [1 x i8*]*, [1 x i8*]** %vtableptr
37 %vtablei8 = bitcast [1 x i8*]* %vtable to i8*
38 %p = call i1 @llvm.type.test(i8* %vtablei8, metadata !"typeid2")
39 call void @llvm.assume(i1 %p)
40 %fptrptr = getelementptr [1 x i8*], [1 x i8*]* %vtable, i32 0, i32 0
41 %fptr = load i8*, i8** %fptrptr
42 %fptr_casted = bitcast i8* %fptr to void (i8*)*
43 ; CHECK: call void @vf2(
44 call void %fptr_casted(i8* %obj)
48 declare i1 @llvm.type.test(i8*, metadata)
49 declare void @llvm.assume(i1)
51 !0 = !{i32 8, !"typeid1"}
52 !1 = !{i32 24, !"typeid2"}