diff options
author | Tim Northover <tnorthover@apple.com> | 2015-02-10 19:49:18 +0000 |
---|---|---|
committer | Tim Northover <tnorthover@apple.com> | 2015-02-10 19:49:18 +0000 |
commit | 43c0d2db50a90f54028877869d5fb86bdb0502b7 (patch) | |
tree | f41971964cd5752239bcd7b8be801adf15ae42ac /llvm/lib/Transforms | |
parent | 851563f9c3bc6b5db812cfa95add5387e6e433df (diff) | |
download | bcm5719-llvm-43c0d2db50a90f54028877869d5fb86bdb0502b7.tar.gz bcm5719-llvm-43c0d2db50a90f54028877869d5fb86bdb0502b7.zip |
DeadArgElim: arguments affect all returned sub-values by default.
Unless we meet an insertvalue on a path from some value to a return, that value
will be live if *any* of the return's components are live, so all of those
components must be added to the MaybeLiveUses.
Previously we were deleting arguments if sub-value 0 turned out to be dead.
llvm-svn: 228731
Diffstat (limited to 'llvm/lib/Transforms')
-rw-r--r-- | llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp | 20 |
1 files changed, 16 insertions, 4 deletions
diff --git a/llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp b/llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp index 50698bb26c8..596204dac62 100644 --- a/llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp +++ b/llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp @@ -146,7 +146,7 @@ namespace { private: Liveness MarkIfNotLive(RetOrArg Use, UseVector &MaybeLiveUses); Liveness SurveyUse(const Use *U, UseVector &MaybeLiveUses, - unsigned RetValNum = 0); + unsigned RetValNum = -1U); Liveness SurveyUses(const Value *V, UseVector &MaybeLiveUses); void SurveyFunction(const Function &F); @@ -443,9 +443,21 @@ DAE::Liveness DAE::SurveyUse(const Use *U, // function's return value is live. We use RetValNum here, for the case // that U is really a use of an insertvalue instruction that uses the // original Use. - RetOrArg Use = CreateRet(RI->getParent()->getParent(), RetValNum); - // We might be live, depending on the liveness of Use. - return MarkIfNotLive(Use, MaybeLiveUses); + const Function *F = RI->getParent()->getParent(); + if (RetValNum != -1U) { + RetOrArg Use = CreateRet(F, RetValNum); + // We might be live, depending on the liveness of Use. + return MarkIfNotLive(Use, MaybeLiveUses); + } else { + DAE::Liveness Result; + for (unsigned i = 0; i < NumRetVals(F); ++i) { + RetOrArg Use = CreateRet(F, i); + // We might be live, depending on the liveness of Use. All Results + // should be the same since they depend only on F. + Result = MarkIfNotLive(Use, MaybeLiveUses); + } + return Result; + } } if (const InsertValueInst *IV = dyn_cast<InsertValueInst>(V)) { if (U->getOperandNo() != InsertValueInst::getAggregateOperandIndex() |