diff options
| author | Devang Patel <dpatel@apple.com> | 2008-03-11 17:33:32 +0000 |
|---|---|---|
| committer | Devang Patel <dpatel@apple.com> | 2008-03-11 17:33:32 +0000 |
| commit | 5663fe6613774ba6e834e1cfcbaa912c6bc3f241 (patch) | |
| tree | d4895d229619aad05782026d0be699a4016a1c32 /llvm/lib | |
| parent | e418de302334e6b9519428fced35a79a031a79b1 (diff) | |
| download | bcm5719-llvm-5663fe6613774ba6e834e1cfcbaa912c6bc3f241.tar.gz bcm5719-llvm-5663fe6613774ba6e834e1cfcbaa912c6bc3f241.zip | |
Become multiple return value aware.
Right now, the pass does not optimize tail recursions
involving multiple return values.
llvm-svn: 48228
Diffstat (limited to 'llvm/lib')
| -rw-r--r-- | llvm/lib/Transforms/Scalar/TailRecursionElimination.cpp | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/llvm/lib/Transforms/Scalar/TailRecursionElimination.cpp b/llvm/lib/Transforms/Scalar/TailRecursionElimination.cpp index 0623abe5dd1..d1320c990db 100644 --- a/llvm/lib/Transforms/Scalar/TailRecursionElimination.cpp +++ b/llvm/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<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)) |

