From: Devang Patel Date: Tue, 11 Mar 2008 17:33:32 +0000 (+0000) Subject: Become multiple return value aware. X-Git-Tag: android-x86-6.0-r1~1003^2~29574 X-Git-Url: http://git.osdn.net/view?a=commitdiff_plain;h=826c49132a9cba1e08a5fce78d05561d9a3746ce;p=android-x86%2Fexternal-llvm.git Become multiple return value aware. 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 --- diff --git a/lib/Transforms/Scalar/TailRecursionElimination.cpp b/lib/Transforms/Scalar/TailRecursionElimination.cpp index 0623abe5dd1..d1320c990db 100644 --- a/lib/Transforms/Scalar/TailRecursionElimination.cpp +++ b/lib/Transforms/Scalar/TailRecursionElimination.cpp @@ -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(F->getReturnType())) + return 0; + for (Function::iterator BBI = F->begin(), E = F->end(); BBI != E; ++BBI) if (ReturnInst *RI = dyn_cast(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(Ret->getReturnValue()) && AccumulatorRecursionEliminationInitVal == 0 && !getCommonReturnValue(Ret, CI))