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 (i64 (i8*, i128)* @vf1 to i8*)], !type !0
7 @vt2 = constant [1 x i8*] [i8* bitcast (i64 (i8*, i128)* @vf2 to i8*)], !type !0
8 @vt3 = constant [1 x i8*] [i8* bitcast (i128 (i8*, i64)* @vf3 to i8*)], !type !1
9 @vt4 = constant [1 x i8*] [i8* bitcast (i128 (i8*, i64)* @vf4 to i8*)], !type !1
11 define i64 @vf1(i8* %this, i128 %arg) readnone {
12 %argtrunc = trunc i128 %arg to i64
16 define i64 @vf2(i8* %this, i128 %arg) readnone {
17 %argtrunc = trunc i128 %arg to i64
21 define i128 @vf3(i8* %this, i64 %arg) readnone {
22 %argzext = zext i64 %arg to i128
26 define i128 @vf4(i8* %this, i64 %arg) readnone {
27 %argzext = zext i64 %arg to i128
31 ; CHECK: define i64 @call1
32 define i64 @call1(i8* %obj) {
33 %vtableptr = bitcast i8* %obj to [1 x i8*]**
34 %vtable = load [1 x i8*]*, [1 x i8*]** %vtableptr
35 %vtablei8 = bitcast [1 x i8*]* %vtable to i8*
36 %p = call i1 @llvm.type.test(i8* %vtablei8, metadata !"typeid1")
37 call void @llvm.assume(i1 %p)
38 %fptrptr = getelementptr [1 x i8*], [1 x i8*]* %vtable, i32 0, i32 0
39 %fptr = load i8*, i8** %fptrptr
40 %fptr_casted = bitcast i8* %fptr to i64 (i8*, i128)*
42 %result = call i64 %fptr_casted(i8* %obj, i128 1)
46 ; CHECK: define i128 @call2
47 define i128 @call2(i8* %obj) {
48 %vtableptr = bitcast i8* %obj to [1 x i8*]**
49 %vtable = load [1 x i8*]*, [1 x i8*]** %vtableptr
50 %vtablei8 = bitcast [1 x i8*]* %vtable to i8*
51 %p = call i1 @llvm.type.test(i8* %vtablei8, metadata !"typeid2")
52 call void @llvm.assume(i1 %p)
53 %fptrptr = getelementptr [1 x i8*], [1 x i8*]* %vtable, i32 0, i32 0
54 %fptr = load i8*, i8** %fptrptr
55 %fptr_casted = bitcast i8* %fptr to i128 (i8*, i64)*
57 %result = call i128 %fptr_casted(i8* %obj, i64 1)
61 declare i1 @llvm.type.test(i8*, metadata)
62 declare void @llvm.assume(i1)
64 !0 = !{i32 0, !"typeid1"}
65 !1 = !{i32 0, !"typeid2"}