aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2002-02-14 18:55:22 +0000
committerChris Lattner <sabre@nondot.org>2002-02-14 18:55:22 +0000
commit9750b61e69718494dd8b2b2b8115ce9c7bc78b8b (patch)
tree65e15a084cd5948d50d727d3539365e6de0834fa
parent9ab91af48604ca4a500823b677434e0796073d18 (diff)
* Check in fix for: llvm/test/Regression/Other/2002-02-14-LevelRaiseInstDelete.ll
* Minor reformatting. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@1760 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--lib/Transforms/ExprTypeConvert.cpp12
1 files changed, 7 insertions, 5 deletions
diff --git a/lib/Transforms/ExprTypeConvert.cpp b/lib/Transforms/ExprTypeConvert.cpp
index d75a8ac68c..b61903578d 100644
--- a/lib/Transforms/ExprTypeConvert.cpp
+++ b/lib/Transforms/ExprTypeConvert.cpp
@@ -357,6 +357,10 @@ Value *ConvertExpressionToType(Value *V, const Type *Ty, ValueMapCache &VMC) {
ValueMapCache::ExprMapTy::iterator VMCI = VMC.ExprMap.find(V);
if (VMCI != VMC.ExprMap.end()) {
assert(VMCI->second->getType() == Ty);
+
+ if (Instruction *I = dyn_cast<Instruction>(V))
+ ValueHandle IHandle(VMC, I); // Remove I if it is unused now!
+
return VMCI->second;
}
@@ -1084,13 +1088,11 @@ static void RecursiveDelete(ValueMapCache &Cache, Instruction *I) {
#endif
for (User::op_iterator OI = I->op_begin(), OE = I->op_end();
- OI != OE; ++OI) {
- Instruction *U = dyn_cast<Instruction>(*OI);
- if (U) {
+ OI != OE; ++OI)
+ if (Instruction *U = dyn_cast<Instruction>(*OI)) {
*OI = 0;
- RecursiveDelete(Cache, dyn_cast<Instruction>(U));
+ RecursiveDelete(Cache, U);
}
- }
I->getParent()->getInstList().remove(I);