xref: /llvm-project/llvm/test/Transforms/WholeProgramDevirt/vcp-too-wide-ints.ll (revision 0ecf7965929c4477c8b9821c68e0ad66b012d8fe)
1; RUN: opt -S -passes=wholeprogramdevirt -whole-program-visibility %s | FileCheck %s
2
3target datalayout = "e-p:64:64"
4target triple = "x86_64-unknown-linux-gnu"
5
6@vt1 = constant [1 x ptr] [ptr @vf1], !type !0
7@vt2 = constant [1 x ptr] [ptr @vf2], !type !0
8@vt3 = constant [1 x ptr] [ptr @vf3], !type !1
9@vt4 = constant [1 x ptr] [ptr @vf4], !type !1
10
11define i64 @vf1(ptr %this, i128 %arg) readnone {
12  %argtrunc = trunc i128 %arg to i64
13  ret i64 %argtrunc
14}
15
16define i64 @vf2(ptr %this, i128 %arg) readnone {
17  %argtrunc = trunc i128 %arg to i64
18  ret i64 %argtrunc
19}
20
21define i128 @vf3(ptr %this, i64 %arg) readnone {
22  %argzext = zext i64 %arg to i128
23  ret i128 %argzext
24}
25
26define i128 @vf4(ptr %this, i64 %arg) readnone {
27  %argzext = zext i64 %arg to i128
28  ret i128 %argzext
29}
30
31; CHECK: define i64 @call1
32define i64 @call1(ptr %obj) {
33  %vtable = load ptr, ptr %obj
34  %p = call i1 @llvm.type.test(ptr %vtable, metadata !"typeid1")
35  call void @llvm.assume(i1 %p)
36  %fptr = load ptr, ptr %vtable
37  ; CHECK: call i64 %
38  %result = call i64 %fptr(ptr %obj, i128 1)
39  ret i64 %result
40}
41
42; CHECK: define i128 @call2
43define i128 @call2(ptr %obj) {
44  %vtable = load ptr, ptr %obj
45  %p = call i1 @llvm.type.test(ptr %vtable, metadata !"typeid2")
46  call void @llvm.assume(i1 %p)
47  %fptr = load ptr, ptr %vtable
48  ; CHECK: call i128 %
49  %result = call i128 %fptr(ptr %obj, i64 1)
50  ret i128 %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