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