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