diff options
author | Chris Lattner <sabre@nondot.org> | 2002-02-12 21:07:25 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2002-02-12 21:07:25 +0000 |
commit | 221d688a5ef21a22c2368c9fff0e92d7966c95e5 (patch) | |
tree | d2dc21b19341a39bdc0a47f4736d76839d9ad73b /lib/Transforms | |
parent | 3c34a46c7e51ab290b208248461542eb83c469b0 (diff) |
Method.h no longer includes BasicBlock.h
Method::inst_* is now in llvm/Support/InstIterator.h
GraphTraits specializations for BasicBlock and Methods are now in llvm/Support/CFG.h
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@1746 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Transforms')
-rw-r--r-- | lib/Transforms/Scalar/ADCE.cpp | 11 | ||||
-rw-r--r-- | lib/Transforms/Scalar/IndVarSimplify.cpp | 1 | ||||
-rw-r--r-- | lib/Transforms/Scalar/InductionVars.cpp | 1 | ||||
-rw-r--r-- | lib/Transforms/Scalar/InstructionCombining.cpp | 3 | ||||
-rw-r--r-- | lib/Transforms/Scalar/SCCP.cpp | 61 | ||||
-rw-r--r-- | lib/Transforms/Utils/Linker.cpp | 18 |
6 files changed, 51 insertions, 44 deletions
diff --git a/lib/Transforms/Scalar/ADCE.cpp b/lib/Transforms/Scalar/ADCE.cpp index 71c50674f4..7f71cf1850 100644 --- a/lib/Transforms/Scalar/ADCE.cpp +++ b/lib/Transforms/Scalar/ADCE.cpp @@ -13,6 +13,7 @@ #include "llvm/Analysis/Writer.h" #include "llvm/iTerminators.h" #include "llvm/iPHINode.h" +#include "llvm/Support/CFG.h" #include "Support/STLExtras.h" #include "Support/DepthFirstIterator.h" #include <algorithm> @@ -156,10 +157,12 @@ bool ADCE::doADCE(cfg::DominanceFrontier &CDG) { #ifdef DEBUG_ADCE cerr << "Current Method: X = Live\n"; - for (Method::inst_iterator IL = M->inst_begin(); IL != M->inst_end(); ++IL) { - if (LiveSet.count(*IL)) cerr << "X "; - cerr << *IL; - } + for (Method::iterator I = M->begin(), E = M->end(); I != E; ++I) + for (BasicBlock::iterator BI = (*I)->begin(), BE = (*I)->end(); + BI != BE; ++BI) { + if (LiveSet.count(*BI)) cerr << "X "; + cerr << *BI; + } #endif // After the worklist is processed, recursively walk the CFG in depth first diff --git a/lib/Transforms/Scalar/IndVarSimplify.cpp b/lib/Transforms/Scalar/IndVarSimplify.cpp index d06c19787f..59442ea277 100644 --- a/lib/Transforms/Scalar/IndVarSimplify.cpp +++ b/lib/Transforms/Scalar/IndVarSimplify.cpp @@ -11,6 +11,7 @@ #include "llvm/iPHINode.h" #include "llvm/iOther.h" #include "llvm/Type.h" +#include "llvm/BasicBlock.h" #include "llvm/ConstantVals.h" #include "Support/STLExtras.h" diff --git a/lib/Transforms/Scalar/InductionVars.cpp b/lib/Transforms/Scalar/InductionVars.cpp index 48982f4773..bc130f0faf 100644 --- a/lib/Transforms/Scalar/InductionVars.cpp +++ b/lib/Transforms/Scalar/InductionVars.cpp @@ -26,6 +26,7 @@ #include "llvm/SymbolTable.h" #include "llvm/iPHINode.h" #include "llvm/Method.h" +#include "llvm/BasicBlock.h" #include "Support/STLExtras.h" #include <algorithm> #include <iostream> diff --git a/lib/Transforms/Scalar/InstructionCombining.cpp b/lib/Transforms/Scalar/InstructionCombining.cpp index 25590661b7..962ca97dec 100644 --- a/lib/Transforms/Scalar/InstructionCombining.cpp +++ b/lib/Transforms/Scalar/InstructionCombining.cpp @@ -18,6 +18,7 @@ #include "llvm/Transforms/Scalar/ConstantHandling.h" #include "llvm/Method.h" #include "llvm/iMemory.h" +#include "llvm/Support/InstIterator.h" #include "../TransformInternals.h" static Instruction *CombineBinOp(BinaryOperator *I) { @@ -126,7 +127,7 @@ bool InstructionCombining::CombineInstruction(Instruction *I) { bool InstructionCombining::doit(Method *M) { // Start the worklist out with all of the instructions in the method in it. - std::vector<Instruction*> WorkList(M->inst_begin(), M->inst_end()); + std::vector<Instruction*> WorkList(inst_begin(M), inst_end(M)); while (!WorkList.empty()) { Instruction *I = WorkList.back(); // Get an instruction from the worklist diff --git a/lib/Transforms/Scalar/SCCP.cpp b/lib/Transforms/Scalar/SCCP.cpp index d6b7c40f34..ada670deb8 100644 --- a/lib/Transforms/Scalar/SCCP.cpp +++ b/lib/Transforms/Scalar/SCCP.cpp @@ -244,39 +244,36 @@ bool SCCP::doSCCP() { // constants if we have found them to be of constant values. // bool MadeChanges = false; - for (Method::inst_iterator II = M->inst_begin(); II != M->inst_end(); ) { - Instruction *Inst = *II; - InstVal &IV = ValueState[Inst]; - if (IV.isConstant()) { - Constant *Const = IV.getConstant(); - // cerr << "Constant: " << Inst << " is: " << Const; - - // Replaces all of the uses of a variable with uses of the constant. - Inst->replaceAllUsesWith(Const); - - // Remove the operator from the list of definitions... - Inst->getParent()->getInstList().remove(II.getInstructionIterator()); - - // The new constant inherits the old name of the operator... - if (Inst->hasName() && !Const->hasName()) - Const->setName(Inst->getName(), M->getSymbolTableSure()); - - // Delete the operator now... - delete Inst; - - // Incrementing the iterator in an unchecked manner could mess up the - // internals of 'II'. To make sure everything is happy, tell it we might - // have broken it. - II.resyncInstructionIterator(); - - // Hey, we just changed something! - MadeChanges = true; - continue; // Skip the ++II at the end of the loop here... - } else if (Inst->isTerminator()) { - MadeChanges |= ConstantFoldTerminator(cast<TerminatorInst>(Inst)); - } + for (Method::iterator MI = M->begin(), ME = M->end(); MI != ME; ++MI) { + BasicBlock *BB = *MI; + for (BasicBlock::iterator BI = BB->begin(); BI != BB->end();) { + Instruction *Inst = *BI; + InstVal &IV = ValueState[Inst]; + if (IV.isConstant()) { + Constant *Const = IV.getConstant(); + // cerr << "Constant: " << Inst << " is: " << Const; + + // Replaces all of the uses of a variable with uses of the constant. + Inst->replaceAllUsesWith(Const); + + // Remove the operator from the list of definitions... + BB->getInstList().remove(BI); + + // The new constant inherits the old name of the operator... + if (Inst->hasName() && !Const->hasName()) + Const->setName(Inst->getName(), M->getSymbolTableSure()); + + // Delete the operator now... + delete Inst; + + // Hey, we just changed something! + MadeChanges = true; + } else if (TerminatorInst *TI = dyn_cast<TerminatorInst>(Inst)) { + MadeChanges |= ConstantFoldTerminator(TI); + } - ++II; + ++BI; + } } // Merge identical constants last: this is important because we may have just diff --git a/lib/Transforms/Utils/Linker.cpp b/lib/Transforms/Utils/Linker.cpp index e1622529c2..f265bb05d1 100644 --- a/lib/Transforms/Utils/Linker.cpp +++ b/lib/Transforms/Utils/Linker.cpp @@ -12,6 +12,7 @@ #include "llvm/Transforms/Linker.h" #include "llvm/Module.h" #include "llvm/Method.h" +#include "llvm/BasicBlock.h" #include "llvm/GlobalVariable.h" #include "llvm/SymbolTable.h" #include "llvm/DerivedTypes.h" @@ -337,13 +338,16 @@ static bool LinkMethodBody(Method *Dest, const Method *Src, // in the Source method as operands. Loop through all of the operands of the // methods and patch them up to point to the local versions... // - for (Method::inst_iterator I = Dest->inst_begin(), E = Dest->inst_end(); - I != E; ++I) { - Instruction *Inst = *I; - - for (Instruction::op_iterator OI = Inst->op_begin(), OE = Inst->op_end(); - OI != OE; ++OI) - *OI = RemapOperand(*OI, LocalMap, &GlobalMap); + for (Method::iterator BI = Dest->begin(), BE = Dest->end(); + BI != BE; ++BI) { + BasicBlock *BB = *BI; + for (BasicBlock::iterator I = BB->begin(), E = BB->end(); I != E; ++I) { + Instruction *Inst = *I; + + for (Instruction::op_iterator OI = Inst->op_begin(), OE = Inst->op_end(); + OI != OE; ++OI) + *OI = RemapOperand(*OI, LocalMap, &GlobalMap); + } } return false; |