summaryrefslogtreecommitdiff
path: root/test/Transforms/CodeExtractor
diff options
context:
space:
mode:
authorDimitry Andric <dim@FreeBSD.org>2017-05-02 18:30:13 +0000
committerDimitry Andric <dim@FreeBSD.org>2017-05-02 18:30:13 +0000
commita303c417bbdb53703c2c17398b08486bde78f1f6 (patch)
tree98366d6b93d863cefdc53f16c66c0c5ae7fb2261 /test/Transforms/CodeExtractor
parent12f3ca4cdb95b193af905a00e722a4dcb40b3de3 (diff)
Notes
Diffstat (limited to 'test/Transforms/CodeExtractor')
-rw-r--r--test/Transforms/CodeExtractor/MultipleExitBranchProb.ll6
-rw-r--r--test/Transforms/CodeExtractor/PartialInlineAnd.ll56
-rw-r--r--test/Transforms/CodeExtractor/PartialInlineAndOr.ll63
-rw-r--r--test/Transforms/CodeExtractor/PartialInlineOptRemark.ll40
-rw-r--r--test/Transforms/CodeExtractor/PartialInlineOr.ll97
-rw-r--r--test/Transforms/CodeExtractor/PartialInlineOrAnd.ll71
-rw-r--r--test/Transforms/CodeExtractor/SingleCondition.ll23
-rw-r--r--test/Transforms/CodeExtractor/unreachable-block.ll6
8 files changed, 355 insertions, 7 deletions
diff --git a/test/Transforms/CodeExtractor/MultipleExitBranchProb.ll b/test/Transforms/CodeExtractor/MultipleExitBranchProb.ll
index e37b7e636450..425e96973596 100644
--- a/test/Transforms/CodeExtractor/MultipleExitBranchProb.ll
+++ b/test/Transforms/CodeExtractor/MultipleExitBranchProb.ll
@@ -1,4 +1,4 @@
-; RUN: opt < %s -partial-inliner -S | FileCheck %s
+; RUN: opt < %s -partial-inliner -max-num-inline-blocks=2 -S | FileCheck %s
; This test checks to make sure that CodeExtractor updates
; the exit branch probabilities for multiple exit blocks.
@@ -22,7 +22,7 @@ ret i32 %val
; CHECK-LABEL: @dummyCaller
; CHECK: call
-; CHECK-NEXT: br i1 {{.*}}!prof [[COUNT1:![0-9]+]]
+; CHECK-NEXT: br i1 {{.*}}return.i{{.*}}return.2{{.*}}!prof [[COUNT1:![0-9]+]]
}
!llvm.module.flags = !{!0}
@@ -31,4 +31,4 @@ ret i32 %val
!2 = !{!"branch_weights", i32 5, i32 5}
!3 = !{!"branch_weights", i32 4, i32 1}
-; CHECK: [[COUNT1]] = !{!"branch_weights", i32 8, i32 31}
+; CHECK: [[COUNT1]] = !{!"branch_weights", i32 31, i32 8}
diff --git a/test/Transforms/CodeExtractor/PartialInlineAnd.ll b/test/Transforms/CodeExtractor/PartialInlineAnd.ll
new file mode 100644
index 000000000000..e981a5ba5816
--- /dev/null
+++ b/test/Transforms/CodeExtractor/PartialInlineAnd.ll
@@ -0,0 +1,56 @@
+; RUN: opt < %s -partial-inliner -S | FileCheck %s
+; RUN: opt < %s -passes=partial-inliner -S | FileCheck %s
+; RUN: opt < %s -partial-inliner -max-num-inline-blocks=2 -S | FileCheck --check-prefix=LIMIT %s
+; RUN: opt < %s -passes=partial-inliner -max-num-inline-blocks=2 -S | FileCheck --check-prefix=LIMIT %s
+
+; Function Attrs: nounwind uwtable
+define i32 @bar(i32 %arg) local_unnamed_addr #0 {
+bb:
+ %tmp = icmp slt i32 %arg, 0
+ br i1 %tmp, label %bb1, label %bb5
+
+bb1: ; preds = %bb
+ %tmp2 = tail call i32 (...) @channels() #2
+ %tmp3 = icmp slt i32 %tmp2, %arg
+ br i1 %tmp3, label %bb4, label %bb5
+
+bb4: ; preds = %bb1
+ tail call void (...) @foo() #2
+ tail call void (...) @foo() #2
+ tail call void (...) @foo() #2
+ tail call void (...) @foo() #2
+ tail call void (...) @foo() #2
+ tail call void (...) @foo() #2
+ tail call void (...) @foo() #2
+ tail call void (...) @foo() #2
+ tail call void (...) @foo() #2
+ br label %bb5
+
+bb5: ; preds = %bb4, %bb1, %bb
+ %tmp6 = phi i32 [ 0, %bb4 ], [ 1, %bb1 ], [ 1, %bb ]
+ ret i32 %tmp6
+}
+
+declare i32 @channels(...) local_unnamed_addr #1
+
+declare void @foo(...) local_unnamed_addr #1
+
+; Function Attrs: nounwind uwtable
+define i32 @dummy_caller(i32 %arg) local_unnamed_addr #0 {
+bb:
+; CHECK-LABEL: @dummy_caller
+; CHECK: br i1
+; CHECK: br i1
+; CHECK: call void @bar.1_
+; LIMIT-LABEL: @dummy_caller
+; LIMIT: br i1
+; LIMIT-NOT: br
+; LIMIT: call void @bar.1_
+ %tmp = tail call i32 @bar(i32 %arg)
+ ret i32 %tmp
+}
+
+attributes #0 = { nounwind }
+attributes #1 = { nounwind }
+attributes #2 = { nounwind }
+
diff --git a/test/Transforms/CodeExtractor/PartialInlineAndOr.ll b/test/Transforms/CodeExtractor/PartialInlineAndOr.ll
new file mode 100644
index 000000000000..485e06ce1023
--- /dev/null
+++ b/test/Transforms/CodeExtractor/PartialInlineAndOr.ll
@@ -0,0 +1,63 @@
+; RUN: opt < %s -partial-inliner -S | FileCheck %s
+; RUN: opt < %s -passes=partial-inliner -S | FileCheck %s
+; RUN: opt < %s -partial-inliner -max-num-inline-blocks=3 -S | FileCheck --check-prefix=LIMIT %s
+; RUN: opt < %s -passes=partial-inliner -max-num-inline-blocks=3 -S | FileCheck --check-prefix=LIMIT %s
+
+; Function Attrs: nounwind uwtable
+define i32 @bar(i32 %arg) local_unnamed_addr #0 {
+bb:
+ %tmp = icmp slt i32 %arg, 0
+ br i1 %tmp, label %bb1, label %bb4
+
+bb1: ; preds = %bb
+ %tmp2 = tail call i32 (...) @n() #2
+ %tmp3 = icmp slt i32 %tmp2, %arg
+ br i1 %tmp3, label %bb7, label %bb4
+
+bb4: ; preds = %bb1, %bb
+ %tmp5 = tail call i32 (...) @m() #2
+ %tmp6 = icmp slt i32 %tmp5, %arg
+ br i1 %tmp6, label %bb7, label %bb8
+
+bb7: ; preds = %bb4, %bb1
+ tail call void (...) @foo() #2
+ tail call void (...) @foo() #2
+ tail call void (...) @foo() #2
+ tail call void (...) @foo() #2
+ tail call void (...) @foo() #2
+ tail call void (...) @foo() #2
+ tail call void (...) @foo() #2
+ tail call void (...) @foo() #2
+ tail call void (...) @foo() #2
+ br label %bb8
+
+bb8: ; preds = %bb7, %bb4
+ %tmp9 = phi i32 [ 0, %bb7 ], [ 1, %bb4 ]
+ ret i32 %tmp9
+}
+
+declare i32 @n(...) local_unnamed_addr #1
+
+declare i32 @m(...) local_unnamed_addr #1
+
+declare void @foo(...) local_unnamed_addr #1
+
+; Function Attrs: nounwind uwtable
+define i32 @dummy_caller(i32 %arg) local_unnamed_addr #0 {
+bb:
+; CHECK-LABEL: @dummy_caller
+; CHECK: br i1
+; CHECK: br i1
+; CHECK: br i1
+; CHECK: call void @bar.1_
+; LIMIT-LABEL: @dummy_caller
+; LIMIT-NOT: br i1
+; LIMIT: call i32 @bar
+ %tmp = tail call i32 @bar(i32 %arg)
+ ret i32 %tmp
+}
+
+attributes #0 = { nounwind }
+attributes #1 = { nounwind }
+attributes #2 = { nounwind }
+
diff --git a/test/Transforms/CodeExtractor/PartialInlineOptRemark.ll b/test/Transforms/CodeExtractor/PartialInlineOptRemark.ll
index 3ba03843046c..c8808182f717 100644
--- a/test/Transforms/CodeExtractor/PartialInlineOptRemark.ll
+++ b/test/Transforms/CodeExtractor/PartialInlineOptRemark.ll
@@ -7,6 +7,8 @@
; RUN: opt -S -passes=partial-inliner -pass-remarks=partial-inlining --disable-partial-inlining < %s 2>&1 | FileCheck --check-prefix=LIMIT %s
; RUN: opt -S -partial-inliner -pass-remarks=partial-inlining -max-partial-inlining=0 < %s 2>&1 | FileCheck --check-prefix=LIMIT %s
; RUN: opt -S -passes=partial-inliner -pass-remarks=partial-inlining -max-partial-inlining=0 < %s 2>&1 | FileCheck --check-prefix=LIMIT %s
+; RUN: opt -S -partial-inliner -pass-remarks=partial-inlining -inline-threshold=0 < %s 2>&1 | FileCheck --check-prefix=LIMIT %s
+; RUN: opt -S -passes=partial-inliner -pass-remarks=partial-inlining -inline-threshold=0 < %s 2>&1 | FileCheck --check-prefix=LIMIT %s
define i32 @bar(i32 %arg) local_unnamed_addr #0 !dbg !5 {
bb:
@@ -30,6 +32,38 @@ bb2: ; preds = %bb1, %bb
ret i32 %tmp3, !dbg !19
}
+define i32 @bar_noinline(i32 %arg) local_unnamed_addr #1 !dbg !5 {
+bb:
+ %tmp = icmp slt i32 %arg, 0, !dbg !7
+ br i1 %tmp, label %bb1, label %bb2, !dbg !8
+
+bb1: ; preds = %bb
+ tail call void (...) @foo() #0, !dbg !9
+ tail call void (...) @foo() #0, !dbg !10
+ tail call void (...) @foo() #0, !dbg !11
+ br label %bb2, !dbg !18
+
+bb2: ; preds = %bb1, %bb
+ %tmp3 = phi i32 [ 0, %bb1 ], [ 1, %bb ]
+ ret i32 %tmp3, !dbg !19
+}
+
+define i32 @bar_alwaysinline(i32 %arg) local_unnamed_addr #2 !dbg !5 {
+bb:
+ %tmp = icmp slt i32 %arg, 0, !dbg !7
+ br i1 %tmp, label %bb1, label %bb2, !dbg !8
+
+bb1: ; preds = %bb
+ tail call void (...) @foo() #0, !dbg !9
+ tail call void (...) @foo() #0, !dbg !10
+ tail call void (...) @foo() #0, !dbg !11
+ br label %bb2, !dbg !18
+
+bb2: ; preds = %bb1, %bb
+ %tmp3 = phi i32 [ 0, %bb1 ], [ 1, %bb ]
+ ret i32 %tmp3, !dbg !19
+}
+
; Function Attrs: nounwind
declare void @foo(...) local_unnamed_addr #0
@@ -37,12 +71,18 @@ declare void @foo(...) local_unnamed_addr #0
define i32 @dummy_caller(i32 %arg) local_unnamed_addr #0 !dbg !20 {
bb:
; CHECK:remark{{.*}}bar partially inlined into dummy_caller
+; CHECK-NOT:remark{{.*}}bar_noinline partially inlined into dummy_caller
+; CHECK-NOT:remark{{.*}}bar_alwaysinline partially inlined into dummy_caller
; LIMIT-NOT:remark{{.*}}bar partially inlined into dummy_caller
%tmp = tail call i32 @bar(i32 %arg), !dbg !21
+ %tmp2 = tail call i32 @bar_noinline(i32 %arg), !dbg !21
+ %tmp3 = tail call i32 @bar_alwaysinline(i32 %arg), !dbg !21
ret i32 %tmp, !dbg !22
}
attributes #0 = { nounwind }
+attributes #1 = { noinline nounwind }
+attributes #2 = { alwaysinline nounwind }
!llvm.dbg.cu = !{!0}
!llvm.module.flags = !{!3}
diff --git a/test/Transforms/CodeExtractor/PartialInlineOr.ll b/test/Transforms/CodeExtractor/PartialInlineOr.ll
new file mode 100644
index 000000000000..5408b4faaf70
--- /dev/null
+++ b/test/Transforms/CodeExtractor/PartialInlineOr.ll
@@ -0,0 +1,97 @@
+; RUN: opt < %s -partial-inliner -S | FileCheck %s
+; RUN: opt < %s -passes=partial-inliner -S | FileCheck %s
+; RUN: opt < %s -partial-inliner -max-num-inline-blocks=2 -S | FileCheck --check-prefix=LIMIT %s
+; RUN: opt < %s -passes=partial-inliner -max-num-inline-blocks=2 -S | FileCheck --check-prefix=LIMIT %s
+
+; Function Attrs: nounwind uwtable
+define i32 @bar(i32 %arg) local_unnamed_addr #0 {
+bb:
+ %tmp = icmp slt i32 %arg, 0
+ br i1 %tmp, label %bb4, label %bb1
+
+bb1: ; preds = %bb
+ %tmp2 = tail call i32 (...) @channels() #1
+ %tmp3 = icmp slt i32 %tmp2, %arg
+ br i1 %tmp3, label %bb4, label %bb5
+
+bb4: ; preds = %bb1, %bb
+ tail call void (...) @foo() #1
+ tail call void (...) @foo() #1
+ tail call void (...) @foo() #1
+ tail call void (...) @foo() #1
+ tail call void (...) @foo() #1
+ tail call void (...) @foo() #1
+ tail call void (...) @foo() #1
+ tail call void (...) @foo() #1
+ tail call void (...) @foo() #1
+ br label %bb5
+
+bb5: ; preds = %bb4, %bb1
+ %.0 = phi i32 [ 0, %bb4 ], [ 1, %bb1 ]
+ ret i32 %.0
+}
+
+declare i32 @channels(...) local_unnamed_addr
+
+declare void @foo(...) local_unnamed_addr
+
+; Function Attrs: nounwind uwtable
+define i32 @dummy_caller(i32 %arg) local_unnamed_addr #0 {
+bb:
+; CHECK-LABEL: @dummy_caller
+; CHECK: br i1
+; CHECK: br i1
+; CHECK: call void @bar.2_
+; LIMIT-LABEL: @dummy_caller
+; LIMIT-NOT: br
+; LIMIT: call i32 @bar(
+ %tmp = tail call i32 @bar(i32 %arg)
+ ret i32 %tmp
+}
+
+define i32 @bar_multi_ret(i32 %arg) local_unnamed_addr #0 {
+bb:
+ %tmp = icmp slt i32 %arg, 0
+ br i1 %tmp, label %bb4, label %bb1
+
+bb1: ; preds = %bb
+ %tmp2 = tail call i32 (...) @channels() #1
+ %tmp3 = icmp slt i32 %tmp2, %arg
+ br i1 %tmp3, label %bb4, label %bb5
+
+bb4: ; preds = %bb1, %bb
+ tail call void (...) @foo() #1
+ tail call void (...) @foo() #1
+ tail call void (...) @foo() #1
+ tail call void (...) @foo() #1
+ %tmp4 = icmp slt i32 %arg, 10
+ br i1 %tmp4, label %bb6, label %bb5
+bb6:
+ tail call void (...) @foo() #1
+ %tmp5 = icmp slt i32 %arg, 3
+ br i1 %tmp5, label %bb7, label %bb5
+bb7:
+ tail call void (...) @foo() #1
+ br label %bb8
+bb8:
+ ret i32 0
+
+bb5: ; preds = %bb4, %bb1
+ %.0 = phi i32 [ 0, %bb4 ], [ 1, %bb1 ], [0, %bb6]
+ ret i32 %.0
+}
+
+define i32 @dummy_caller2(i32 %arg) local_unnamed_addr #0 {
+; CHECK: br i1
+; CHECK: br i1
+; CHECK: call {{.*}} @bar_multi_ret.1_
+ %tmp = tail call i32 @bar_multi_ret(i32 %arg)
+ ret i32 %tmp
+}
+
+attributes #0 = { nounwind uwtable }
+attributes #1 = { nounwind }
+
+!llvm.ident = !{!0}
+
+!0 = !{!"clang version 5.0.0 (trunk 300576)"}
diff --git a/test/Transforms/CodeExtractor/PartialInlineOrAnd.ll b/test/Transforms/CodeExtractor/PartialInlineOrAnd.ll
new file mode 100644
index 000000000000..282d300fadb9
--- /dev/null
+++ b/test/Transforms/CodeExtractor/PartialInlineOrAnd.ll
@@ -0,0 +1,71 @@
+; RUN: opt < %s -partial-inliner -S | FileCheck %s
+; RUN: opt < %s -passes=partial-inliner -S | FileCheck %s
+; RUN: opt < %s -partial-inliner -max-num-inline-blocks=3 -S | FileCheck --check-prefix=LIMIT3 %s
+; RUN: opt < %s -passes=partial-inliner -max-num-inline-blocks=3 -S | FileCheck --check-prefix=LIMIT3 %s
+; RUN: opt < %s -partial-inliner -max-num-inline-blocks=2 -S | FileCheck --check-prefix=LIMIT2 %s
+; RUN: opt < %s -passes=partial-inliner -max-num-inline-blocks=2 -S | FileCheck --check-prefix=LIMIT2 %s
+
+
+; Function Attrs: nounwind uwtable
+define i32 @bar(i32 %arg) local_unnamed_addr #0 {
+bb:
+ %tmp = icmp slt i32 %arg, 0
+ br i1 %tmp, label %bb4, label %bb1
+
+bb1: ; preds = %bb
+ %tmp2 = tail call i32 (...) @n() #2
+ %tmp3 = icmp slt i32 %tmp2, %arg
+ br i1 %tmp3, label %bb4, label %bb8
+
+bb4: ; preds = %bb1, %bb
+ %tmp5 = tail call i32 (...) @m() #2
+ %tmp6 = icmp sgt i32 %tmp5, %arg
+ br i1 %tmp6, label %bb7, label %bb8
+
+bb7: ; preds = %bb4
+ tail call void (...) @foo() #2
+ tail call void (...) @foo() #2
+ tail call void (...) @foo() #2
+ tail call void (...) @foo() #2
+ tail call void (...) @foo() #2
+ tail call void (...) @foo() #2
+ tail call void (...) @foo() #2
+ tail call void (...) @foo() #2
+ tail call void (...) @foo() #2
+ br label %bb8
+
+bb8: ; preds = %bb7, %bb4, %bb1
+ %tmp9 = phi i32 [ 0, %bb7 ], [ 1, %bb4 ], [ 1, %bb1 ]
+ ret i32 %tmp9
+}
+
+declare i32 @n(...) local_unnamed_addr #1
+
+declare i32 @m(...) local_unnamed_addr #1
+
+declare void @foo(...) local_unnamed_addr #1
+
+; Function Attrs: nounwind uwtable
+define i32 @dummy_caller(i32 %arg) local_unnamed_addr #0 {
+bb:
+; CHECK-LABEL: @dummy_caller
+; CHECK: br i1
+; CHECK: br i1
+; CHECK: br i1
+; CHECK: call void @bar.1_
+; LIMIT3-LABEL: @dummy_caller
+; LIMIT3: br i1
+; LIMIT3: br i1
+; LIMIT3-NOT: br i1
+; LIMIT3: call void @bar.1_
+; LIMIT2-LABEL: @dummy_caller
+; LIMIT2-NOT: br i1
+; LIMIT2: call i32 @bar(
+ %tmp = tail call i32 @bar(i32 %arg)
+ ret i32 %tmp
+}
+
+attributes #0 = { nounwind }
+attributes #1 = { nounwind }
+attributes #2 = { nounwind }
+
diff --git a/test/Transforms/CodeExtractor/SingleCondition.ll b/test/Transforms/CodeExtractor/SingleCondition.ll
new file mode 100644
index 000000000000..90cda889a21b
--- /dev/null
+++ b/test/Transforms/CodeExtractor/SingleCondition.ll
@@ -0,0 +1,23 @@
+; RUN: opt < %s -partial-inliner -S | FileCheck %s
+; RUN: opt < %s -passes=partial-inliner -S | FileCheck %s
+
+define internal i32 @inlinedFunc(i1 %cond, i32* align 4 %align.val) {
+entry:
+ br i1 %cond, label %if.then, label %return
+if.then:
+ ; Dummy store to have more than 0 uses
+ store i32 10, i32* %align.val, align 4
+ br label %return
+return: ; preds = %entry
+ ret i32 0
+}
+
+define internal i32 @dummyCaller(i1 %cond, i32* align 2 %align.val) {
+entry:
+; CHECK-LABEL: @dummyCaller
+; CHECK: br
+; CHECK: call void @inlinedFunc.1_
+ %val = call i32 @inlinedFunc(i1 %cond, i32* %align.val)
+ ret i32 %val
+}
+
diff --git a/test/Transforms/CodeExtractor/unreachable-block.ll b/test/Transforms/CodeExtractor/unreachable-block.ll
index d20a35718e68..09f41f6bd2fb 100644
--- a/test/Transforms/CodeExtractor/unreachable-block.ll
+++ b/test/Transforms/CodeExtractor/unreachable-block.ll
@@ -9,13 +9,11 @@
; CHECK-LABEL: define internal void @tinkywinky.1_ontrue() {
; CHECK-NEXT: newFuncRoot:
; CHECK-NEXT: br label %ontrue
-; CHECK: .exitStub:
+; CHECK: onfalse{{.*}}:
; CHECK-NEXT: ret void
; CHECK: ontrue:
; CHECK-NEXT: call void @patatino()
-; CHECK-NEXT: br label %onfalse
-; CHECK: onfalse:
-; CHECK-NEXT: br label %.exitStub
+; CHECK-NEXT: br label %onfalse{{.*}}
; CHECK-NEXT: }
declare void @patatino()