1; -stats requires asserts 2; REQUIRES: asserts 3 4; RUN: opt -S -passes=wholeprogramdevirt -whole-program-visibility -pass-remarks=wholeprogramdevirt -stats %s 2>&1 | FileCheck %s 5 6target datalayout = "e-p:64:64" 7target triple = "x86_64-unknown-linux-gnu" 8 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 13 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 18 19define i1 @vf0(ptr %this) readnone { 20 ret i1 0 21} 22 23define i1 @vf1(ptr %this) readnone { 24 ret i1 1 25} 26 27; CHECK: define i1 @call1 28define 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]] 36 ret i1 %result 37} 38 39; CHECK: define i32 @call2 40define 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:%[^ ]*]] 50 ret i32 %result 51} 52 53declare i1 @llvm.type.test(ptr, metadata) 54declare void @llvm.assume(i1) 55 56!0 = !{i32 0, !"typeid1"} 57!1 = !{i32 0, !"typeid2"} 58 59; CHECK: 2 wholeprogramdevirt - Number of whole program devirtualization targets 60; CHECK: 2 wholeprogramdevirt - Number of unique return value optimizations 61