1 ; RUN: opt -S -passes=wholeprogramdevirt -whole-program-visibility -pass-remarks=wholeprogramdevirt %s 2>&1 | FileCheck %s
3 target datalayout = "e-p:64:64"
4 target triple = "x86_64-unknown-linux-gnu"
6 ; CHECK: remark: <unknown>:0:0: single-impl: devirtualized a call to vf
7 ; CHECK: remark: <unknown>:0:0: devirtualized vf
8 ; CHECK-NOT: devirtualized
10 ; A vtable with "relative pointers", slots don't contain pointers to implementations, but instead have an i32 offset from the vtable itself to the implementation.
11 @vtable = internal unnamed_addr constant { [2 x i32] } { [2 x i32] [
12 i32 trunc (i64 sub (i64 ptrtoint (ptr @vfunc1_live to i64), i64 ptrtoint (ptr @vtable to i64)) to i32),
13 i32 trunc (i64 sub (i64 ptrtoint (ptr @vfunc2_dead to i64), i64 ptrtoint (ptr @vtable to i64)) to i32)
14 ]}, align 8, !type !0, !type !1
15 ;, !vcall_visibility !{i64 2}
16 !0 = !{i64 0, !"vfunc1.type"}
17 !1 = !{i64 4, !"vfunc2.type"}
19 define internal void @vfunc1_live() {
23 define internal void @vfunc2_dead() {
27 ; CHECK: define void @call
28 define void @call(ptr %obj) {
29 %vtable = load ptr, ptr %obj
30 %pair = call {ptr, i1} @llvm.type.checked.load.relative(ptr %vtable, i32 0, metadata !"vfunc1.type")
31 %fptr = extractvalue {ptr, i1} %pair, 0
32 %p = extractvalue {ptr, i1} %pair, 1
34 br i1 %p, label %cont, label %trap
37 ; CHECK: call void @vfunc1_live(
42 call void @llvm.trap()
46 declare {ptr, i1} @llvm.type.checked.load.relative(ptr, i32, metadata)
47 declare void @llvm.trap()