diff options
author | Dan Gohman <gohman@apple.com> | 2012-05-10 18:57:38 +0000 |
---|---|---|
committer | Dan Gohman <gohman@apple.com> | 2012-05-10 18:57:38 +0000 |
commit | b401e3bd16c3d648464606d5e5b496dd61d12afc (patch) | |
tree | b07de7956a0b88f64d8677105b2ddd59eb17e254 /lib/Analysis/ValueTracking.cpp | |
parent | fe65d98dadbedf2650266ac71c1c093c3b97da1f (diff) | |
download | external_llvm-b401e3bd16c3d648464606d5e5b496dd61d12afc.zip external_llvm-b401e3bd16c3d648464606d5e5b496dd61d12afc.tar.gz external_llvm-b401e3bd16c3d648464606d5e5b496dd61d12afc.tar.bz2 |
Teach DeadStoreElimination to eliminate exit-block stores with phi addresses.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@156558 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Analysis/ValueTracking.cpp')
-rw-r--r-- | lib/Analysis/ValueTracking.cpp | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/lib/Analysis/ValueTracking.cpp b/lib/Analysis/ValueTracking.cpp index 1418e01..d245783 100644 --- a/lib/Analysis/ValueTracking.cpp +++ b/lib/Analysis/ValueTracking.cpp @@ -1796,6 +1796,37 @@ llvm::GetUnderlyingObject(Value *V, const TargetData *TD, unsigned MaxLookup) { return V; } +void +llvm::GetUnderlyingObjects(Value *V, + SmallVectorImpl<Value *> &Objects, + const TargetData *TD, + unsigned MaxLookup) { + SmallPtrSet<Value *, 4> Visited; + SmallVector<Value *, 4> Worklist; + Worklist.push_back(V); + do { + Value *P = Worklist.pop_back_val(); + P = GetUnderlyingObject(P, TD, MaxLookup); + + if (!Visited.insert(P)) + continue; + + if (SelectInst *SI = dyn_cast<SelectInst>(P)) { + Worklist.push_back(SI->getTrueValue()); + Worklist.push_back(SI->getFalseValue()); + continue; + } + + if (PHINode *PN = dyn_cast<PHINode>(P)) { + for (unsigned i = 0, e = PN->getNumIncomingValues(); i != e; ++i) + Worklist.push_back(PN->getIncomingValue(i)); + continue; + } + + Objects.push_back(P); + } while (!Worklist.empty()); +} + /// onlyUsedByLifetimeMarkers - Return true if the only users of this pointer /// are lifetime markers. /// |