summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Transforms/LevelRaise.cpp
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2002-03-11 22:19:48 +0000
committerChris Lattner <sabre@nondot.org>2002-03-11 22:19:48 +0000
commit7287d698bffca1da85f9837f2c7025ff44e6c695 (patch)
treeaf4f834f226003e3a15702f53c711846c43454bb /llvm/lib/Transforms/LevelRaise.cpp
parentfbc26f3be9ece3dd5f8b2aac6a4d849ff39f32f6 (diff)
downloadbcm5719-llvm-7287d698bffca1da85f9837f2c7025ff44e6c695.tar.gz
bcm5719-llvm-7287d698bffca1da85f9837f2c7025ff44e6c695.zip
* Fix bug: test/Regression/Other/2002-03-11-LevelRaiseIterInvalidate.ll
* Use more concise form of ReplaceInstWithInst to make code simpler * Output nicer message for dead code eliminated when debugging llvm-svn: 1861
Diffstat (limited to 'llvm/lib/Transforms/LevelRaise.cpp')
-rw-r--r--llvm/lib/Transforms/LevelRaise.cpp14
1 files changed, 4 insertions, 10 deletions
diff --git a/llvm/lib/Transforms/LevelRaise.cpp b/llvm/lib/Transforms/LevelRaise.cpp
index 2826e9f216c..630ee0fa50a 100644
--- a/llvm/lib/Transforms/LevelRaise.cpp
+++ b/llvm/lib/Transforms/LevelRaise.cpp
@@ -85,25 +85,19 @@ static bool HandleCastToPointer(BasicBlock::iterator BI,
// If we have a getelementptr capability... transform all of the
// add instruction uses into getelementptr's.
- for (Value::use_iterator UI = CI->use_begin(), E = CI->use_end();
- UI != E; ++UI) {
- Instruction *I = cast<Instruction>(*UI);
+ while (!CI->use_empty()) {
+ Instruction *I = cast<Instruction>(*CI->use_begin());
assert(I->getOpcode() == Instruction::Add && I->getNumOperands() == 2 &&
"Use is not a valid add instruction!");
// Get the value added to the cast result pointer...
Value *OtherPtr = I->getOperand((I->getOperand(0) == CI) ? 1 : 0);
- BasicBlock *BB = I->getParent();
- BasicBlock::iterator AddIt = find(BB->getInstList().begin(),
- BB->getInstList().end(), I);
-
GetElementPtrInst *GEP = new GetElementPtrInst(OtherPtr, Indices);
-
PRINT_PEEPHOLE1("cast-add-to-gep:i", I);
// Replace the old add instruction with the shiny new GEP inst
- ReplaceInstWithInst(BB->getInstList(), AddIt, GEP);
+ ReplaceInstWithInst(I, GEP);
PRINT_PEEPHOLE1("cast-add-to-gep:o", GEP);
}
return true;
@@ -417,7 +411,7 @@ static bool DoRaisePass(Method *M) {
if (dceInstruction(BIL, BI) || doConstantPropogation(BB, BI)) {
Changed = true;
#ifdef DEBUG_PEEPHOLE_INSTS
- cerr << "DeadCode Elinated!\n";
+ cerr << "***\t\t^^-- DeadCode Elinated!\n";
#endif
} else if (PeepholeOptimize(BB, BI))
Changed = true;
OpenPOWER on IntegriCloud