Simplify the interface to local DCE and Constant prop
authorChris Lattner <sabre@nondot.org>
Sun, 26 May 2002 20:18:18 +0000 (20:18 +0000)
committerChris Lattner <sabre@nondot.org>
Sun, 26 May 2002 20:18:18 +0000 (20:18 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@2749 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Transforms/LevelRaise.cpp
lib/Transforms/Scalar/DCE.cpp
lib/Transforms/Scalar/LICM.cpp
lib/Transforms/Utils/Local.cpp

index 8703b928b4cf711a9644d069d9427a32dd35b74d..b0bae9755844024a1e9f359b7270692757ccf4bf 100644 (file)
@@ -443,7 +443,7 @@ static bool DoRaisePass(Function *F) {
 
     for (BasicBlock::iterator BI = BB->begin(); BI != BB->end();) {
       DEBUG(cerr << "Processing: " << *BI);
-      if (dceInstruction(BIL, BI) || doConstantPropogation(BB, BI)) {
+      if (dceInstruction(BI) || doConstantPropogation(BI)) {
         Changed = true; 
         ++NumDCEorCP;
         DEBUG(cerr << "***\t\t^^-- DeadCode Elinated!\n");
index 2c9c8b3b0d5fcc848dcf965d1c65b62915158b51..fa2392fbb4248b0f44e8fe235d3158bf09857566 100644 (file)
@@ -32,7 +32,7 @@ namespace {
       BasicBlock::InstListType &Vals = BB->getInstList();
       bool Changed = false;
       for (BasicBlock::iterator DI = Vals.begin(); DI != Vals.end(); )
-        if (dceInstruction(Vals, DI)) {
+        if (dceInstruction(DI)) {
           Changed = true;
           ++DIEEliminated;
         } else
index 3be163ce412b92c7febe2603807c9af99176ecdf..2e5adf6f7a87615027f988891e1837acd5e3254f 100644 (file)
@@ -184,7 +184,7 @@ void LICM::visitBasicBlock(BasicBlock *BB) {
     visit(BB->begin()[i]);
     
     BasicBlock::iterator It = BB->begin()+i;
-    if (dceInstruction(BB->getInstList(), It))
+    if (dceInstruction(It))
       Changed = true;
     else
       ++i;
index eb06a5b1f928aa4ff416e9a38de128db94dbf0e4..cc152c6c09434e6d3d3e7a34da7c0925ec456d9b 100644 (file)
 // ConstantFoldInstruction - If an instruction references constants, try to fold
 // them together...
 //
-bool doConstantPropogation(BasicBlock *BB, BasicBlock::iterator &II) {
+bool doConstantPropogation(BasicBlock::iterator &II) {
   Instruction *Inst = *II;
   if (Constant *C = ConstantFoldInstruction(Inst)) {
     // Replaces all of the uses of a variable with uses of the constant.
     Inst->replaceAllUsesWith(C);
     
     // Remove the instruction from the basic block...
-    delete BB->getInstList().remove(II);
+    delete Inst->getParent()->getInstList().remove(II);
     return true;
   }
 
@@ -100,11 +100,11 @@ bool isInstructionTriviallyDead(Instruction *I) {
 // to point to the instruction that immediately succeeded the original
 // instruction.
 //
-bool dceInstruction(BasicBlock::InstListType &BBIL,
-                    BasicBlock::iterator &BBI) {
+bool dceInstruction(BasicBlock::iterator &BBI) {
   // Look for un"used" definitions...
-  if (isInstructionTriviallyDead(*BBI)) {
-    delete BBIL.remove(BBI);   // Bye bye
+  Instruction *I = *BBI;
+  if (isInstructionTriviallyDead(I)) {
+    delete I->getParent()->getInstList().remove(BBI);   // Bye bye
     return true;
   }
   return false;