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