[PATCH] Update TailCallElim to avoid making redundant changes

Kevin Modzelewski kmod at dropbox.com
Fri Mar 21 17:15:51 PDT 2014


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;
+            }
           }
         }
       }
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D3144.1.patch
Type: text/x-patch
Size: 652 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20140321/aaeeb9de/attachment.bin>


More information about the llvm-commits mailing list