xref: /llvm-project/llvm/test/Transforms/Inline/call-intrinsic-objectsize.ll (revision 2d69827c5c754f0eca98e497ecf0e52ed54b4fd3)
1; RUN: opt -passes=inline -S %s -inline-threshold=20 2>&1 | FileCheck %s
2
3%struct.nodemask_t = type { [16 x i64] }
4@numa_nodes_parsed = external constant %struct.nodemask_t, align 8
5
6declare void @foo()
7declare i64 @llvm.objectsize.i64.p0(ptr, i1 immarg, i1 immarg, i1 immarg)
8
9; Test that we inline @callee into @caller.
10define i64 @caller() {
11; CHECK-LABEL: @caller(
12; CHECK-NEXT:    [[TMP1:%.*]] = tail call i64 @llvm.objectsize.i64.p0(ptr @numa_nodes_parsed, i1 false, i1 false, i1 false)
13; CHECK-NEXT:    [[TMP2:%.*]] = icmp uge i64 [[TMP1]], 128
14; CHECK-NEXT:    br i1 [[TMP2]], label %[[CALLEE_EXIT:.*]], label %[[HANDLER_TYPE_MISMATCH94_I:.*]]
15; CHECK:       [[HANDLER_TYPE_MISMATCH94_I]]:
16; CHECK-NEXT:    call void @foo()
17; CHECK-NEXT:    call void @foo()
18; CHECK-NEXT:    call void @foo()
19; CHECK-NEXT:    call void @foo()
20; CHECK-NEXT:    call void @foo()
21; CHECK-NEXT:    call void @foo()
22; CHECK-NEXT:    br label %[[CALLEE_EXIT]]
23; CHECK:       [[CALLEE_EXIT]]:
24; CHECK-NEXT:    ret i64 [[TMP1]]
25;
26  %1 = tail call i64 @callee()
27  ret i64 %1
28}
29
30; Testing the InlineCost of the call to @llvm.objectsize.i64.p0.
31; Do not change the linkage of @callee; that will give it a severe discount in
32; cost (LastCallToStaticBonus).
33define i64 @callee() {
34  %1 = tail call i64 @llvm.objectsize.i64.p0(ptr @numa_nodes_parsed, i1 false, i1 false, i1 false)
35  %2 = icmp uge i64 %1, 128
36  br i1 %2, label %cont95, label %handler.type_mismatch94
37
38handler.type_mismatch94:
39  call void @foo()
40  call void @foo()
41  call void @foo()
42  call void @foo()
43  call void @foo()
44  call void @foo()
45  br label %cont95
46
47cont95:
48  ret i64 %1
49}
50
51