From 18961504fc2b299578dba817900a0696cf3ccc4d Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Tue, 25 Jun 2002 16:12:52 +0000 Subject: *** empty log message *** git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@2777 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Transforms/Utils/Local.cpp | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) (limited to 'lib/Transforms/Utils/Local.cpp') diff --git a/lib/Transforms/Utils/Local.cpp b/lib/Transforms/Utils/Local.cpp index cc152c6c09..10028bacec 100644 --- a/lib/Transforms/Utils/Local.cpp +++ b/lib/Transforms/Utils/Local.cpp @@ -17,13 +17,12 @@ // them together... // bool doConstantPropogation(BasicBlock::iterator &II) { - Instruction *Inst = *II; - if (Constant *C = ConstantFoldInstruction(Inst)) { + if (Constant *C = ConstantFoldInstruction(II)) { // Replaces all of the uses of a variable with uses of the constant. - Inst->replaceAllUsesWith(C); + II->replaceAllUsesWith(C); // Remove the instruction from the basic block... - delete Inst->getParent()->getInstList().remove(II); + II = II->getParent()->getInstList().erase(II); return true; } @@ -102,9 +101,8 @@ bool isInstructionTriviallyDead(Instruction *I) { // bool dceInstruction(BasicBlock::iterator &BBI) { // Look for un"used" definitions... - Instruction *I = *BBI; - if (isInstructionTriviallyDead(I)) { - delete I->getParent()->getInstList().remove(BBI); // Bye bye + if (isInstructionTriviallyDead(BBI)) { + BBI = BBI->getParent()->getInstList().erase(BBI); // Bye bye return true; } return false; -- cgit v1.2.3-18-g5258