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 | ed7c24e2d9a3841607ce6f6e409129ae7de58761 (patch) | |
tree | ffa1a85f54a7f2a637aed8040dd70d6d0f3d1a4c /llvm/lib/Analysis/ValueTracking.cpp | |
parent | 671ce47d607b68e6a8ed606c721fcaaea90beb36 (diff) | |
download | bcm5719-llvm-ed7c24e2d9a3841607ce6f6e409129ae7de58761.tar.gz bcm5719-llvm-ed7c24e2d9a3841607ce6f6e409129ae7de58761.zip |
Teach DeadStoreElimination to eliminate exit-block stores with phi addresses.
llvm-svn: 156558
Diffstat (limited to 'llvm/lib/Analysis/ValueTracking.cpp')
-rw-r--r-- | llvm/lib/Analysis/ValueTracking.cpp | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/llvm/lib/Analysis/ValueTracking.cpp b/llvm/lib/Analysis/ValueTracking.cpp index 1418e01d7c8..d245783ec65 100644 --- a/llvm/lib/Analysis/ValueTracking.cpp +++ b/llvm/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. /// |