[llvm-commits] [llvm] r48228 - /llvm/trunk/lib/Transforms/Scalar/TailRecursionElimination.cpp

Devang Patel dpatel at apple.com
Tue Mar 11 10:33:32 PDT 2008


Author: dpatel
Date: Tue Mar 11 12:33:32 2008
New Revision: 48228

URL: http://llvm.org/viewvc/llvm-project?rev=48228&view=rev
Log:
Become multiple return value aware.
Right now, the pass does not optimize tail recursions 
involving multiple return values.

Modified:
    llvm/trunk/lib/Transforms/Scalar/TailRecursionElimination.cpp

Modified: llvm/trunk/lib/Transforms/Scalar/TailRecursionElimination.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/TailRecursionElimination.cpp?rev=48228&r1=48227&r2=48228&view=diff

==============================================================================
--- llvm/trunk/lib/Transforms/Scalar/TailRecursionElimination.cpp (original)
+++ llvm/trunk/lib/Transforms/Scalar/TailRecursionElimination.cpp Tue Mar 11 12:33:32 2008
@@ -249,6 +249,10 @@
   Function *F = TheRI->getParent()->getParent();
   Value *ReturnedValue = 0;
 
+  // TODO: Handle multiple value ret instructions;
+  if (isa<StructType>(F->getReturnType()))
+      return 0;
+
   for (Function::iterator BBI = F->begin(), E = F->end(); BBI != E; ++BBI)
     if (ReturnInst *RI = dyn_cast<ReturnInst>(BBI->getTerminator()))
       if (RI != TheRI) {
@@ -363,7 +367,7 @@
   // of the call and return void, ignore the value of the call and return a
   // constant, return the value returned by the tail call, or that are being
   // accumulator recursion variable eliminated.
-  if (Ret->getNumOperands() != 0 && Ret->getReturnValue() != CI &&
+  if (Ret->getNumOperands() == 1 && Ret->getReturnValue() != CI &&
       !isa<UndefValue>(Ret->getReturnValue()) &&
       AccumulatorRecursionEliminationInitVal == 0 &&
       !getCommonReturnValue(Ret, CI))





More information about the llvm-commits mailing list