From d217cfcf468712780cb3b06a36e0ce53897592c1 Mon Sep 17 00:00:00 2001 From: Dan Gohman Date: Wed, 21 Apr 2010 00:43:30 +0000 Subject: [PATCH] Revert r101471. For tight recursive functions which have multiple recursive callsites, inlining can reduce the number of calls by exponential factors, as it does in MultiSource/Benchmarks/Olden/treeadd. More involved heuristics will be needed. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@101969 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Analysis/InlineCost.cpp | 7 ------ test/Transforms/Inline/tail-recursion.ll | 29 ------------------------ 2 files changed, 36 deletions(-) delete mode 100644 test/Transforms/Inline/tail-recursion.ll diff --git a/lib/Analysis/InlineCost.cpp b/lib/Analysis/InlineCost.cpp index 50400d3085d..cb9e5526fc4 100644 --- a/lib/Analysis/InlineCost.cpp +++ b/lib/Analysis/InlineCost.cpp @@ -263,13 +263,6 @@ InlineCost InlineCostAnalyzer::getInlineCost(CallSite CS, CS.isNoInline()) return llvm::InlineCost::getNever(); - // Don't inline directly recursive calls, for now. Inlining a directly - // recursive call is effectively unrolling a loop, so it calls for different - // heuristics, which aren't implemented yet. Until then, err on the - // conservative side. - if (Callee == Caller) - return llvm::InlineCost::getNever(); - // InlineCost - This value measures how good of an inline candidate this call // site is to inline. A lower inline cost make is more likely for the call to // be inlined. This value may go negative. diff --git a/test/Transforms/Inline/tail-recursion.ll b/test/Transforms/Inline/tail-recursion.ll deleted file mode 100644 index 146bed4cd07..00000000000 --- a/test/Transforms/Inline/tail-recursion.ll +++ /dev/null @@ -1,29 +0,0 @@ -; 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 -}