Become multiple return value aware.
authorDevang Patel <dpatel@apple.com>
Tue, 11 Mar 2008 17:33:32 +0000 (17:33 +0000)
committerDevang Patel <dpatel@apple.com>
Tue, 11 Mar 2008 17:33:32 +0000 (17:33 +0000)
Right now, the pass does not optimize tail recursions
involving multiple return values.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@48228 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Transforms/Scalar/TailRecursionElimination.cpp

index 0623abe5dd1b86116eabdcb5bbbf61a4b801cea8..d1320c990dbca4070a7691f09a6dd30f9782a573 100644 (file)
@@ -249,6 +249,10 @@ static Value *getCommonReturnValue(ReturnInst *TheRI, CallInst *CI) {
   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 @@ bool TailCallElim::ProcessReturningBlock(ReturnInst *Ret, BasicBlock *&OldEntry,
   // 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))