diff options
author | Duncan Sands <baldrick@free.fr> | 2010-06-26 12:53:31 +0000 |
---|---|---|
committer | Duncan Sands <baldrick@free.fr> | 2010-06-26 12:53:31 +0000 |
commit | d50e9e2566479301e687fc81e16dab7e3c2b50ea (patch) | |
tree | a7591ad25c85aba30c85d2f235391595dc4e4b53 /test | |
parent | 7a1d92a2cbc20888260efa7d5ad987dc39fcb134 (diff) |
Fix PR7328: when turning a tail recursion into a loop, need to preserve
the returned value after the tail call if it differs from other return
values. The optimal thing to do would be to introduce a phi node for
the return value, but for the moment just fix the miscompile.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@106947 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test')
-rw-r--r-- | test/Transforms/TailCallElim/2010-06-26-MultipleReturnValues.ll | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/test/Transforms/TailCallElim/2010-06-26-MultipleReturnValues.ll b/test/Transforms/TailCallElim/2010-06-26-MultipleReturnValues.ll new file mode 100644 index 0000000000..f39476f7da --- /dev/null +++ b/test/Transforms/TailCallElim/2010-06-26-MultipleReturnValues.ll @@ -0,0 +1,17 @@ +; RUN: opt < %s -tailcallelim -S | FileCheck %s +; PR7328 +define i32 @foo(i32 %x) { +; CHECK: define i32 @foo +entry: + %cond = icmp ugt i32 %x, 0 ; <i1> [#uses=1] + br i1 %cond, label %return, label %body + +body: ; preds = %entry + %y = add i32 %x, 1 ; <i32> [#uses=1] + %tmp = call i32 @foo(i32 %y) ; <i32> [#uses=0] + ret i32 0 +; CHECK: ret i32 0 + +return: ; preds = %entry + ret i32 1 +} |