[PATCH] Update TailCallElim to avoid making redundant changes
Duncan P. N. Exon Smith
dexonsmith at apple.com
Sat Mar 22 17:11:05 PDT 2014
Code is obviously correct, but can you add a testcase?
I think you can observe this misbehaviour in opt by setting
-debug-pass=Executions, which should print a "Made Modifications"
line to dbgs() when a pass reports change things. You’ll also need
a "REQUIRES: asserts" line.
On 2014 Mar 21, at 17:15, Kevin Modzelewski <kmod at dropbox.com> wrote:
> kmod added you to the CC list for the revision "Update TailCallElim to avoid making redundant changes".
>
> Hi #llvm,
>
> While experimenting with an iterated optimization pipeline, I noticed that
> the standard optimization pipeline would always change (most) functions.
> I tracked it down to TailCallElim always calling setTailCall(), even if the call
> is already a tail call; with this change the pipeline does convege after a few
> iterations.
>
> http://llvm-reviews.chandlerc.com/D3144
>
> Files:
> lib/Transforms/Scalar/TailRecursionElimination.cpp
>
> Index: lib/Transforms/Scalar/TailRecursionElimination.cpp
> ===================================================================
> --- lib/Transforms/Scalar/TailRecursionElimination.cpp
> +++ lib/Transforms/Scalar/TailRecursionElimination.cpp
> @@ -252,8 +252,10 @@
> for (BasicBlock::iterator I = BB->begin(), E = BB->end(); I != E; ++I) {
> if (CallInst *CI = dyn_cast<CallInst>(I)) {
> if (!ACT.UsesAlloca.count(CI)) {
> - CI->setTailCall();
> - MadeChange = true;
> + if (!CI->isTailCall()) {
> + CI->setTailCall();
> + MadeChange = true;
> + }
> }
> }
> }
> <D3144.1.patch>_______________________________________________
> llvm-commits mailing list
> llvm-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
More information about the llvm-commits
mailing list