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