Simplify the interface to local DCE and Constant prop

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@2749 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Chris Lattner 2002-05-26 20:18:18 +00:00
parent 9e77f77687
commit 16da494c81
4 changed files with 9 additions and 9 deletions

View File

@ -443,7 +443,7 @@ static bool DoRaisePass(Function *F) {
for (BasicBlock::iterator BI = BB->begin(); BI != BB->end();) { for (BasicBlock::iterator BI = BB->begin(); BI != BB->end();) {
DEBUG(cerr << "Processing: " << *BI); DEBUG(cerr << "Processing: " << *BI);
if (dceInstruction(BIL, BI) || doConstantPropogation(BB, BI)) { if (dceInstruction(BI) || doConstantPropogation(BI)) {
Changed = true; Changed = true;
++NumDCEorCP; ++NumDCEorCP;
DEBUG(cerr << "***\t\t^^-- DeadCode Elinated!\n"); DEBUG(cerr << "***\t\t^^-- DeadCode Elinated!\n");

View File

@ -32,7 +32,7 @@ namespace {
BasicBlock::InstListType &Vals = BB->getInstList(); BasicBlock::InstListType &Vals = BB->getInstList();
bool Changed = false; bool Changed = false;
for (BasicBlock::iterator DI = Vals.begin(); DI != Vals.end(); ) for (BasicBlock::iterator DI = Vals.begin(); DI != Vals.end(); )
if (dceInstruction(Vals, DI)) { if (dceInstruction(DI)) {
Changed = true; Changed = true;
++DIEEliminated; ++DIEEliminated;
} else } else

View File

@ -184,7 +184,7 @@ void LICM::visitBasicBlock(BasicBlock *BB) {
visit(BB->begin()[i]); visit(BB->begin()[i]);
BasicBlock::iterator It = BB->begin()+i; BasicBlock::iterator It = BB->begin()+i;
if (dceInstruction(BB->getInstList(), It)) if (dceInstruction(It))
Changed = true; Changed = true;
else else
++i; ++i;

View File

@ -16,14 +16,14 @@
// ConstantFoldInstruction - If an instruction references constants, try to fold // ConstantFoldInstruction - If an instruction references constants, try to fold
// them together... // them together...
// //
bool doConstantPropogation(BasicBlock *BB, BasicBlock::iterator &II) { bool doConstantPropogation(BasicBlock::iterator &II) {
Instruction *Inst = *II; Instruction *Inst = *II;
if (Constant *C = ConstantFoldInstruction(Inst)) { if (Constant *C = ConstantFoldInstruction(Inst)) {
// Replaces all of the uses of a variable with uses of the constant. // Replaces all of the uses of a variable with uses of the constant.
Inst->replaceAllUsesWith(C); Inst->replaceAllUsesWith(C);
// Remove the instruction from the basic block... // Remove the instruction from the basic block...
delete BB->getInstList().remove(II); delete Inst->getParent()->getInstList().remove(II);
return true; return true;
} }
@ -100,11 +100,11 @@ bool isInstructionTriviallyDead(Instruction *I) {
// to point to the instruction that immediately succeeded the original // to point to the instruction that immediately succeeded the original
// instruction. // instruction.
// //
bool dceInstruction(BasicBlock::InstListType &BBIL, bool dceInstruction(BasicBlock::iterator &BBI) {
BasicBlock::iterator &BBI) {
// Look for un"used" definitions... // Look for un"used" definitions...
if (isInstructionTriviallyDead(*BBI)) { Instruction *I = *BBI;
delete BBIL.remove(BBI); // Bye bye if (isInstructionTriviallyDead(I)) {
delete I->getParent()->getInstList().remove(BBI); // Bye bye
return true; return true;
} }
return false; return false;