blob: 7c52f26ebeaa802ddf29372870eae7e0c6e91482 [file] [log] [blame]
Peter Collingbourne0312f612016-06-25 00:23:04 +00001; RUN: opt -S -wholeprogramdevirt %s | FileCheck %s
2
3target datalayout = "e-p:64:64"
4target triple = "x86_64-unknown-linux-gnu"
5
6@vt1 = constant [1 x i8*] [i8* bitcast (void (i8*)* @vf to i8*)], !type !0
7@vt2 = constant [1 x i8*] [i8* bitcast (void (i8*)* @vf to i8*)], !type !0
8
9define void @vf(i8* %this) {
10 ret void
11}
12
13; CHECK: define void @call
14define void @call(i8* %obj) {
15 %vtableptr = bitcast i8* %obj to [1 x i8*]**
16 %vtable = load [1 x i8*]*, [1 x i8*]** %vtableptr
17 %vtablei8 = bitcast [1 x i8*]* %vtable to i8*
18 %pair = call {i8*, i1} @llvm.type.checked.load(i8* %vtablei8, i32 0, metadata !"typeid")
19 %fptr = extractvalue {i8*, i1} %pair, 0
20 %p = extractvalue {i8*, i1} %pair, 1
21 ; CHECK: br i1 true,
22 br i1 %p, label %cont, label %trap
23
24cont:
25 %fptr_casted = bitcast i8* %fptr to void (i8*)*
26 ; CHECK: call void @vf(
27 call void %fptr_casted(i8* %obj)
28 ret void
29
30trap:
31 call void @llvm.trap()
32 unreachable
33}
34
35declare {i8*, i1} @llvm.type.checked.load(i8*, i32, metadata)
36declare void @llvm.trap()
37
38!0 = !{i32 0, !"typeid"}