1 ; -stats requires asserts
4 ; RUN: opt -S -passes=wholeprogramdevirt -whole-program-visibility -pass-remarks=wholeprogramdevirt -stats %s 2>&1 | FileCheck %s
6 target datalayout = "e-p:64:64"
7 target triple = "x86_64-unknown-linux-gnu"
9 ; CHECK: remark: {{.*}} unique-ret-val: devirtualized a call to vf0
10 ; CHECK: remark: {{.*}} unique-ret-val: devirtualized a call to vf0
11 ; CHECK: remark: {{.*}} devirtualized vf0
12 ; CHECK: remark: {{.*}} devirtualized vf1
14 @vt1 = constant [1 x ptr] [ptr @vf0], !type !0
15 @vt2 = constant [1 x ptr] [ptr @vf0], !type !0, !type !1
16 @vt3 = constant [1 x ptr] [ptr @vf1], !type !0, !type !1
17 @vt4 = constant [1 x ptr] [ptr @vf1], !type !1
19 define i1 @vf0(ptr %this) readnone {
23 define i1 @vf1(ptr %this) readnone {
27 ; CHECK: define i1 @call1
28 define i1 @call1(ptr %obj) {
29 %vtable = load ptr, ptr %obj
30 %p = call i1 @llvm.type.test(ptr %vtable, metadata !"typeid1")
31 call void @llvm.assume(i1 %p)
32 %fptr = load ptr, ptr %vtable
33 ; CHECK: [[RES1:%[^ ]*]] = icmp eq ptr %vtable, @vt3
34 %result = call i1 %fptr(ptr %obj)
35 ; CHECK: ret i1 [[RES1]]
39 ; CHECK: define i32 @call2
40 define i32 @call2(ptr %obj) {
41 %vtable = load ptr, ptr %obj
42 %p = call i1 @llvm.type.test(ptr %vtable, metadata !"typeid2")
43 call void @llvm.assume(i1 %p)
44 %fptr = load ptr, ptr %vtable
45 ; Intentional type mismatch to test zero extend.
46 ; CHECK: [[RES2:%[^ ]*]] = icmp ne ptr %vtable, @vt2
47 %result = call i32 %fptr(ptr %obj)
48 ; CHECK: [[ZEXT2:%[^ ]*]] = zext i1 [[RES2]] to i32
49 ; CHECK: ret i32 [[ZEXT2:%[^ ]*]]
53 declare i1 @llvm.type.test(ptr, metadata)
54 declare void @llvm.assume(i1)
56 !0 = !{i32 0, !"typeid1"}
57 !1 = !{i32 0, !"typeid2"}
59 ; CHECK: 2 wholeprogramdevirt - Number of whole program devirtualization targets
60 ; CHECK: 2 wholeprogramdevirt - Number of unique return value optimizations