From f13f69f296c2a0433e694e7fa93fd79247186da9 Mon Sep 17 00:00:00 2001 From: Dan Gohman Date: Fri, 16 Apr 2010 16:01:18 +0000 Subject: Disable inlining of recursive calls. It can complicate tailcallelim and dependent analyses, and increase code size, so doing it profitably would require more complex heuristics. llvm-svn: 101471 --- llvm/test/Transforms/Inline/tail-recursion.ll | 29 +++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 llvm/test/Transforms/Inline/tail-recursion.ll (limited to 'llvm/test/Transforms') diff --git a/llvm/test/Transforms/Inline/tail-recursion.ll b/llvm/test/Transforms/Inline/tail-recursion.ll new file mode 100644 index 00000000000..146bed4cd07 --- /dev/null +++ b/llvm/test/Transforms/Inline/tail-recursion.ll @@ -0,0 +1,29 @@ +; RUN: opt -inline -tailcallelim -indvars -loop-deletion -S < %s | FileCheck %s + +; Inline shouldn't inline foo into itself because it's a tailcallelim +; candidate. Tailcallelim should convert the call into a loop. Indvars +; should calculate the exit value, making the loop dead. Loop deletion +; should delete the loop. +; PR6842 + +; CHECK: define i32 @bar() nounwind { +; CHECK-NEXT: ret i32 10000 +; CHECK-NEXT: } + +define internal i32 @foo(i32 %x) nounwind { + %i = add i32 %x, 1 ; [#uses=3] + %a = icmp slt i32 %i, 10000 ; [#uses=1] + br i1 %a, label %more, label %done + +done: ; preds = %0 + ret i32 %i + +more: ; preds = %0 + %z = tail call i32 @foo(i32 %i) ; [#uses=1] + ret i32 %z +} + +define i32 @bar() nounwind { + %z = call i32 @foo(i32 0) ; [#uses=1] + ret i32 %z +} -- cgit v1.2.3