diff options
author | Chris Lattner <sabre@nondot.org> | 2004-10-18 01:21:17 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2004-10-18 01:21:17 +0000 |
commit | 28e792c2323a878e6a4661f043f10affc804cca2 (patch) | |
tree | 777454176bf1b9797bc7192cef10e305c1860a90 | |
parent | 963869e41af4f0f180cd13d3ad50f778f336c3b0 (diff) | |
download | external_llvm-28e792c2323a878e6a4661f043f10affc804cca2.zip external_llvm-28e792c2323a878e6a4661f043f10affc804cca2.tar.gz external_llvm-28e792c2323a878e6a4661f043f10affc804cca2.tar.bz2 |
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.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@17108 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | lib/Transforms/Utils/PromoteMemoryToRegister.cpp | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/lib/Transforms/Utils/PromoteMemoryToRegister.cpp b/lib/Transforms/Utils/PromoteMemoryToRegister.cpp index 49499c6..3311bd1 100644 --- a/lib/Transforms/Utils/PromoteMemoryToRegister.cpp +++ b/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; |