summaryrefslogtreecommitdiff
path: root/test/Transforms
diff options
context:
space:
mode:
authorMichael Gottesman <mgottesman@apple.com>2013-07-05 20:45:13 +0000
committerMichael Gottesman <mgottesman@apple.com>2013-07-05 20:45:13 +0000
commitcd56727b555fd009c691d1c4ae308fbaf50e0c4f (patch)
tree33454d91b8f132ae5a5cb921cb10ebd2e048be28 /test/Transforms
parent1276b396130a0cdbbb8e6c05a6e43123df18ed60 (diff)
[TRE] Merged several tests into the the test basic.ll.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@185723 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/Transforms')
-rw-r--r--test/Transforms/TailCallElim/basic.ll58
-rw-r--r--test/Transforms/TailCallElim/intervening-inst.ll18
-rw-r--r--test/Transforms/TailCallElim/move_alloca_for_tail_call.ll15
-rw-r--r--test/Transforms/TailCallElim/return_constant.ll18
-rw-r--r--test/Transforms/TailCallElim/trivial_codegen_tailcall.ll11
5 files changed, 58 insertions, 62 deletions
diff --git a/test/Transforms/TailCallElim/basic.ll b/test/Transforms/TailCallElim/basic.ll
new file mode 100644
index 00000000000..fb90f9c99a2
--- /dev/null
+++ b/test/Transforms/TailCallElim/basic.ll
@@ -0,0 +1,58 @@
+; RUN: opt < %s -tailcallelim -S | FileCheck %s
+
+declare void @noarg()
+declare void @use(i32*)
+
+; Trivial case. Mark @noarg with tail call.
+define void @test0() {
+; CHECK: tail call void @noarg()
+ call void @noarg()
+ ret void
+}
+
+; PR615. Make sure that we do not move the alloca so that it interferes with the tail call.
+define i32 @test1() {
+; CHECK: i32 @test1()
+; CHECK-NEXT: alloca
+ %A = alloca i32 ; <i32*> [#uses=2]
+ store i32 5, i32* %A
+ call void @use(i32* %A)
+ %X = tail call i32 @test1() ; <i32> [#uses=1]
+ ret i32 %X
+}
+
+; This function contains intervening instructions which should be moved out of the way
+define i32 @test2(i32 %X) {
+; CHECK: i32 @test2
+; CHECK-NOT: call
+; CHECK: ret i32
+entry:
+ %tmp.1 = icmp eq i32 %X, 0 ; <i1> [#uses=1]
+ br i1 %tmp.1, label %then.0, label %endif.0
+then.0: ; preds = %entry
+ %tmp.4 = add i32 %X, 1 ; <i32> [#uses=1]
+ ret i32 %tmp.4
+endif.0: ; preds = %entry
+ %tmp.10 = add i32 %X, -1 ; <i32> [#uses=1]
+ %tmp.8 = call i32 @test2(i32 %tmp.10) ; <i32> [#uses=1]
+ %DUMMY = add i32 %X, 1 ; <i32> [#uses=0]
+ ret i32 %tmp.8
+}
+
+; Though this case seems to be fairly unlikely to occur in the wild, someone
+; plunked it into the demo script, so maybe they care about it.
+define i32 @test3(i32 %c) {
+; CHECK: i32 @test3
+; CHECK-NOT: call
+; CHECK: ret i32 0
+entry:
+ %tmp.1 = icmp eq i32 %c, 0 ; <i1> [#uses=1]
+ br i1 %tmp.1, label %return, label %else
+else: ; preds = %entry
+ %tmp.5 = add i32 %c, -1 ; <i32> [#uses=1]
+ %tmp.3 = call i32 @test3(i32 %tmp.5) ; <i32> [#uses=0]
+ ret i32 0
+return: ; preds = %entry
+ ret i32 0
+}
+
diff --git a/test/Transforms/TailCallElim/intervening-inst.ll b/test/Transforms/TailCallElim/intervening-inst.ll
deleted file mode 100644
index 10dffbd6942..00000000000
--- a/test/Transforms/TailCallElim/intervening-inst.ll
+++ /dev/null
@@ -1,18 +0,0 @@
-; This function contains intervening instructions which should be moved out of the way
-; RUN: opt < %s -tailcallelim -S | FileCheck %s
-
-define i32 @Test(i32 %X) {
-entry:
- %tmp.1 = icmp eq i32 %X, 0 ; <i1> [#uses=1]
- br i1 %tmp.1, label %then.0, label %endif.0
-then.0: ; preds = %entry
- %tmp.4 = add i32 %X, 1 ; <i32> [#uses=1]
- ret i32 %tmp.4
-endif.0: ; preds = %entry
- %tmp.10 = add i32 %X, -1 ; <i32> [#uses=1]
-; CHECK-NOT: call
- %tmp.8 = call i32 @Test( i32 %tmp.10 ) ; <i32> [#uses=1]
- %DUMMY = add i32 %X, 1 ; <i32> [#uses=0]
- ret i32 %tmp.8
-}
-
diff --git a/test/Transforms/TailCallElim/move_alloca_for_tail_call.ll b/test/Transforms/TailCallElim/move_alloca_for_tail_call.ll
deleted file mode 100644
index 741f5848bc6..00000000000
--- a/test/Transforms/TailCallElim/move_alloca_for_tail_call.ll
+++ /dev/null
@@ -1,15 +0,0 @@
-; RUN: opt -tailcallelim -S < %s | FileCheck %s
-; PR615
-
-declare void @bar(i32*)
-
-define i32 @foo() {
-; CHECK: i32 @foo()
-; CHECK-NEXT: alloca
- %A = alloca i32 ; <i32*> [#uses=2]
- store i32 17, i32* %A
- call void @bar( i32* %A )
- %X = tail call i32 @foo( ) ; <i32> [#uses=1]
- ret i32 %X
-}
-
diff --git a/test/Transforms/TailCallElim/return_constant.ll b/test/Transforms/TailCallElim/return_constant.ll
deleted file mode 100644
index e99e57e1457..00000000000
--- a/test/Transforms/TailCallElim/return_constant.ll
+++ /dev/null
@@ -1,18 +0,0 @@
-; Though this case seems to be fairly unlikely to occur in the wild, someone
-; plunked it into the demo script, so maybe they care about it.
-;
-; RUN: opt < %s -tailcallelim -S | FileCheck %s
-
-define i32 @aaa(i32 %c) {
-entry:
- %tmp.1 = icmp eq i32 %c, 0 ; <i1> [#uses=1]
- br i1 %tmp.1, label %return, label %else
-else: ; preds = %entry
- %tmp.5 = add i32 %c, -1 ; <i32> [#uses=1]
-; CHECK-NOT: call
- %tmp.3 = call i32 @aaa( i32 %tmp.5 ) ; <i32> [#uses=0]
- ret i32 0
-return: ; preds = %entry
- ret i32 0
-}
-
diff --git a/test/Transforms/TailCallElim/trivial_codegen_tailcall.ll b/test/Transforms/TailCallElim/trivial_codegen_tailcall.ll
deleted file mode 100644
index 7049e4d588d..00000000000
--- a/test/Transforms/TailCallElim/trivial_codegen_tailcall.ll
+++ /dev/null
@@ -1,11 +0,0 @@
-; RUN: opt < %s -tailcallelim -S | FileCheck %s
-
-
-declare void @foo()
-
-define void @bar() {
-; CHECK: tail call void @foo()
- call void @foo()
- ret void
-}
-