xref: /llvm-project/llvm/test/Transforms/CodeExtractor/PartialInlineCallRef.ll (revision bbbbbfbdcb1ab1ba9857138dfa0f2355da8e4499)
1; RUN: opt < %s -passes=partial-inliner -S  | FileCheck %s
2
3
4; Function Attrs: nounwind
5declare void @foo(...) local_unnamed_addr #0
6
7; Function Attrs: noinline
8define i32 @caller(ptr nocapture %arg, ptr nocapture %arg1, i32 %arg2) local_unnamed_addr #1 {
9bb:
10  %tmp = tail call i32 %arg(i32 %arg2) #0
11  %tmp3 = tail call i32 %arg1(i32 %arg2) #0
12  %tmp4 = add nsw i32 %tmp3, %tmp
13  ret i32 %tmp4
14}
15
16; Function Attrs: nounwind
17define i32 @bar(i32 %arg) #0 {
18bb:
19  %tmp = icmp slt i32 %arg, 0
20  br i1 %tmp, label %bb1, label %bb2
21
22bb1:                                              ; preds = %bb
23  tail call void (...) @foo() #0
24  tail call void (...) @foo() #0
25  tail call void (...) @foo() #0
26  tail call void (...) @foo() #0
27  tail call void (...) @foo() #0
28  tail call void (...) @foo() #0
29  tail call void (...) @foo() #0
30  tail call void (...) @foo() #0
31  tail call void (...) @foo() #0
32  br label %bb2
33
34bb2:                                              ; preds = %bb1, %bb
35  %tmp3 = phi i32 [ 0, %bb1 ], [ 1, %bb ]
36  ret i32 %tmp3
37}
38
39; Function Attrs: nounwind
40define i32 @dummy_caller(i32 %arg) local_unnamed_addr #0 {
41bb:
42; CHECK-LABEL: @dummy_caller
43; check that caller is not wrongly inlined by partial inliner
44; CHECK: call i32 @caller
45; CHECK-NOT: call .* @bar
46  %tmp = tail call i32 @caller(ptr nonnull @bar, ptr nonnull @bar, i32 %arg)
47  ret i32 %tmp
48}
49
50attributes #0 = { nounwind }
51attributes #1 = { noinline }
52
53!llvm.ident = !{!0}
54
55!0 = !{!"clang version 5.0.0 (trunk 300897) (llvm/trunk 300947)"}
56