1 ; RUN: opt -S -passes=wholeprogramdevirt -whole-program-visibility %s | FileCheck %s
3 target datalayout = "e-p:64:64"
4 target triple = "x86_64-unknown-linux-gnu"
6 @vt1 = constant [2 x ptr] [ptr zeroinitializer, ptr @vf], !type !0
7 @vt2 = constant ptr @vf, !type !1
9 define void @vf(ptr %this) {
13 ; CHECK: define void @unaligned1
14 define void @unaligned1(ptr %obj) {
15 %vtable = load ptr, ptr %obj
16 %p = call i1 @llvm.type.test(ptr %vtable, metadata !"typeid")
17 call void @llvm.assume(i1 %p)
18 %fptrptr = getelementptr i8, ptr %vtable, i32 1
19 %fptr = load ptr, ptr %fptrptr
21 call void %fptr(ptr %obj)
25 ; CHECK: define void @unaligned2
26 define void @unaligned2(ptr %obj) {
27 %vtable = load ptr, ptr %obj
28 %p = call i1 @llvm.type.test(ptr %vtable, metadata !"typeid2")
29 call void @llvm.assume(i1 %p)
30 %fptrptr = getelementptr i8, ptr %vtable, i32 1
31 %fptr = load ptr, ptr %fptrptr
33 call void %fptr(ptr %obj)
37 ; CHECK: define void @outofbounds
38 define void @outofbounds(ptr %obj) {
39 %vtable = load ptr, ptr %obj
40 %p = call i1 @llvm.type.test(ptr %vtable, metadata !"typeid")
41 call void @llvm.assume(i1 %p)
42 %fptrptr = getelementptr i8, ptr %vtable, i32 16
43 %fptr = load ptr, ptr %fptrptr
45 call void %fptr(ptr %obj)
49 ; CHECK: define void @nonfunction
50 define void @nonfunction(ptr %obj) {
51 %vtable = load ptr, ptr %obj
52 %p = call i1 @llvm.type.test(ptr %vtable, metadata !"typeid")
53 call void @llvm.assume(i1 %p)
54 %fptr = load ptr, ptr %vtable
56 call void %fptr(ptr %obj)
60 declare i1 @llvm.type.test(ptr, metadata)
61 declare void @llvm.assume(i1)
63 !0 = !{i32 0, !"typeid"}
64 !1 = !{i32 0, !"typeid2"}