summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Transforms/Utils/PromoteMemoryToRegister.cpp
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2004-10-18 01:21:17 +0000
committerChris Lattner <sabre@nondot.org>2004-10-18 01:21:17 +0000
commit34ae67070664d9100ee4706f16bb3a6872dc05bd (patch)
tree6150e4b4f49cd5e10651e9bcffff855c36ef2375 /llvm/lib/Transforms/Utils/PromoteMemoryToRegister.cpp
parent53058663aa6023f2b017146f5bac9c405579ded3 (diff)
downloadbcm5719-llvm-34ae67070664d9100ee4706f16bb3a6872dc05bd.tar.gz
bcm5719-llvm-34ae67070664d9100ee4706f16bb3a6872dc05bd.zip
Fix a bug that occurs when the constant value is the result of an invoke. In
particular, invoke ret values are only live in the normal dest of the invoke not in the unwind dest. llvm-svn: 17108
Diffstat (limited to 'llvm/lib/Transforms/Utils/PromoteMemoryToRegister.cpp')
-rw-r--r--llvm/lib/Transforms/Utils/PromoteMemoryToRegister.cpp11
1 files changed, 6 insertions, 5 deletions
diff --git a/llvm/lib/Transforms/Utils/PromoteMemoryToRegister.cpp b/llvm/lib/Transforms/Utils/PromoteMemoryToRegister.cpp
index 49499c65e0d..3311bd1c20b 100644
--- a/llvm/lib/Transforms/Utils/PromoteMemoryToRegister.cpp
+++ b/llvm/lib/Transforms/Utils/PromoteMemoryToRegister.cpp
@@ -95,10 +95,12 @@ namespace {
void run();
- /// dominates - Return true if BB1 dominates BB2 using the DT.
+ /// dominates - Return true if I1 dominates I2 using the DominatorTree.
///
- bool dominates(BasicBlock *BB1, BasicBlock *BB2) const {
- return DT[BB1]->dominates(DT[BB2]);
+ bool dominates(Instruction *I1, Instruction *I2) const {
+ if (InvokeInst *II = dyn_cast<InvokeInst>(I1))
+ I1 = II->getNormalDest()->begin();
+ return DT[I1->getParent()]->dominates(DT[I2->getParent()]);
}
private:
@@ -339,8 +341,7 @@ void PromoteMem2Reg::run() {
for (unsigned i = 0, e = PNs.size(); i != e; ++i)
if (PNs[i]) {
if (Value *V = hasConstantValue(PNs[i])) {
- if (!isa<Instruction>(V) ||
- dominates(cast<Instruction>(V)->getParent(), I->first)) {
+ if (!isa<Instruction>(V) || dominates(cast<Instruction>(V), PNs[i])) {
PNs[i]->replaceAllUsesWith(V);
PNs[i]->eraseFromParent();
PNs[i] = 0;
OpenPOWER on IntegriCloud