aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/Analysis/IPA/CallGraph.cpp7
-rw-r--r--lib/Analysis/IPA/FindUnsafePointerTypes.cpp4
-rw-r--r--lib/Analysis/IPA/FindUsedTypes.cpp3
-rw-r--r--lib/Analysis/LiveVar/FunctionLiveVarInfo.cpp1
-rw-r--r--lib/Analysis/LoopInfo.cpp2
-rw-r--r--lib/Analysis/PostDominators.cpp1
-rw-r--r--lib/Bytecode/Reader/ReaderInternals.h1
-rw-r--r--lib/Bytecode/Writer/SlotCalculator.cpp2
-rw-r--r--lib/CodeGen/InstrSched/SchedPriorities.cpp1
-rw-r--r--lib/CodeGen/InstrSelection/InstrForest.cpp9
-rw-r--r--lib/CodeGen/MachineFunction.cpp13
-rw-r--r--lib/CodeGen/RegAlloc/LiveRangeInfo.cpp1
-rw-r--r--lib/CodeGen/RegAlloc/PhyRegAlloc.cpp1
-rw-r--r--lib/ExecutionEngine/Interpreter/Execution.cpp10
-rw-r--r--lib/ExecutionEngine/Interpreter/Interpreter.h1
-rw-r--r--lib/Linker/LinkModules.cpp18
-rw-r--r--lib/Target/SparcV9/InstrSched/SchedPriorities.cpp1
-rw-r--r--lib/Target/SparcV9/InstrSelection/InstrForest.cpp9
-rw-r--r--lib/Target/SparcV9/LiveVar/FunctionLiveVarInfo.cpp1
-rw-r--r--lib/Target/SparcV9/RegAlloc/LiveRangeInfo.cpp1
-rw-r--r--lib/Target/SparcV9/RegAlloc/PhyRegAlloc.cpp1
-rw-r--r--lib/Target/SparcV9/SparcV9TargetMachine.cpp7
-rw-r--r--lib/Transforms/Scalar/ADCE.cpp11
-rw-r--r--lib/Transforms/Scalar/IndVarSimplify.cpp1
-rw-r--r--lib/Transforms/Scalar/InductionVars.cpp1
-rw-r--r--lib/Transforms/Scalar/InstructionCombining.cpp3
-rw-r--r--lib/Transforms/Scalar/SCCP.cpp61
-rw-r--r--lib/Transforms/Utils/Linker.cpp18
-rw-r--r--lib/VMCore/Dominators.cpp1
-rw-r--r--lib/VMCore/Instruction.cpp1
-rw-r--r--lib/VMCore/Linker.cpp18
-rw-r--r--lib/VMCore/Pass.cpp1
-rw-r--r--lib/VMCore/SlotCalculator.cpp2
-rw-r--r--tools/analyze/analyze.cpp7
-rw-r--r--tools/dis/dis.cpp1
-rw-r--r--tools/llvm-dis/dis.cpp1
-rw-r--r--tools/llvm-dis/llvm-dis.cpp1
37 files changed, 134 insertions, 89 deletions
diff --git a/lib/Analysis/IPA/CallGraph.cpp b/lib/Analysis/IPA/CallGraph.cpp
index 244c35ea46..04b8c2d6bc 100644
--- a/lib/Analysis/IPA/CallGraph.cpp
+++ b/lib/Analysis/IPA/CallGraph.cpp
@@ -16,6 +16,7 @@
#include "llvm/Method.h"
#include "llvm/iOther.h"
#include "llvm/iTerminators.h"
+#include "llvm/Support/InstIterator.h"// FIXME: CallGraph should use method uses
#include "Support/STLExtras.h"
#include <algorithm>
@@ -46,8 +47,7 @@ void cfg::CallGraph::addToCallGraph(Method *M) {
if (!M->hasInternalLinkage())
Root->addCalledMethod(Node);
- for (Method::inst_iterator I = M->inst_begin(), E = M->inst_end();
- I != E; ++I) {
+ for (inst_iterator I = inst_begin(M), E = inst_end(M); I != E; ++I) {
// Dynamic calls will cause Null nodes to be created
if (CallInst *CI = dyn_cast<CallInst>(*I))
Node->addCalledMethod(getNodeFor(CI->getCalledMethod()));
@@ -138,8 +138,7 @@ bool IsLeafMethod(const Method* M, const cfg::CallGraph* CG) {
return (cgn->begin() == cgn->end());
}
- for (Method::const_inst_iterator I = M->inst_begin(), E = M->inst_end();
- I != E; ++I)
+ for (const_inst_iterator I = inst_begin(M), E = inst_end(M); I != E; ++I)
if ((*I)->getOpcode() == Instruction::Call)
return false;
return true;
diff --git a/lib/Analysis/IPA/FindUnsafePointerTypes.cpp b/lib/Analysis/IPA/FindUnsafePointerTypes.cpp
index bc09292090..0179cbb74c 100644
--- a/lib/Analysis/IPA/FindUnsafePointerTypes.cpp
+++ b/lib/Analysis/IPA/FindUnsafePointerTypes.cpp
@@ -22,6 +22,7 @@
#include "llvm/Instruction.h"
#include "llvm/Method.h"
#include "llvm/Module.h"
+#include "llvm/Support/InstIterator.h"
#include "Support/CommandLine.h"
AnalysisID FindUnsafePointerTypes::ID(AnalysisID::create<FindUnsafePointerTypes>());
@@ -58,8 +59,7 @@ bool FindUnsafePointerTypes::run(Module *Mod) {
for (Module::iterator MI = Mod->begin(), ME = Mod->end();
MI != ME; ++MI) {
const Method *M = *MI; // We don't need/want write access
- for (Method::const_inst_iterator I = M->inst_begin(), E = M->inst_end();
- I != E; ++I) {
+ for (const_inst_iterator I = inst_begin(M), E = inst_end(M); I != E; ++I) {
const Instruction *Inst = *I;
const Type *ITy = Inst->getType();
if (ITy->isPointerType() && !UnsafeTypes.count((PointerType*)ITy))
diff --git a/lib/Analysis/IPA/FindUsedTypes.cpp b/lib/Analysis/IPA/FindUsedTypes.cpp
index b876e5e68d..e02429ab97 100644
--- a/lib/Analysis/IPA/FindUsedTypes.cpp
+++ b/lib/Analysis/IPA/FindUsedTypes.cpp
@@ -11,6 +11,7 @@
#include "llvm/DerivedTypes.h"
#include "llvm/Module.h"
#include "llvm/Method.h"
+#include "llvm/Support/InstIterator.h"
AnalysisID FindUsedTypes::ID(AnalysisID::create<FindUsedTypes>());
AnalysisID FindUsedTypes::IncludeSymbolTableID(AnalysisID::create<FindUsedTypes>());
@@ -59,7 +60,7 @@ bool FindUsedTypes::run(Module *m) {
// Loop over all of the instructions in the method, adding their return type
// as well as the types of their operands.
//
- for (Method::const_inst_iterator II = M->inst_begin(), IE = M->inst_end();
+ for (const_inst_iterator II = inst_begin(M), IE = inst_end(M);
II != IE; ++II) {
const Instruction *I = *II;
const Type *Ty = I->getType();
diff --git a/lib/Analysis/LiveVar/FunctionLiveVarInfo.cpp b/lib/Analysis/LiveVar/FunctionLiveVarInfo.cpp
index a1a2dba9fb..b83359f94b 100644
--- a/lib/Analysis/LiveVar/FunctionLiveVarInfo.cpp
+++ b/lib/Analysis/LiveVar/FunctionLiveVarInfo.cpp
@@ -9,6 +9,7 @@
#include "BBLiveVar.h"
#include "llvm/CodeGen/MachineInstr.h"
#include "llvm/BasicBlock.h"
+#include "llvm/Support/CFG.h"
#include "Support/PostOrderIterator.h"
#include "Support/SetOperations.h"
#include <iostream>
diff --git a/lib/Analysis/LoopInfo.cpp b/lib/Analysis/LoopInfo.cpp
index 9b34095e4f..876161d34f 100644
--- a/lib/Analysis/LoopInfo.cpp
+++ b/lib/Analysis/LoopInfo.cpp
@@ -9,7 +9,7 @@
#include "llvm/Analysis/LoopInfo.h"
#include "llvm/Analysis/Dominators.h"
-#include "llvm/BasicBlock.h"
+#include "llvm/Support/CFG.h"
#include "Support/DepthFirstIterator.h"
#include <algorithm>
diff --git a/lib/Analysis/PostDominators.cpp b/lib/Analysis/PostDominators.cpp
index aad6e1cb38..33e14e9fc5 100644
--- a/lib/Analysis/PostDominators.cpp
+++ b/lib/Analysis/PostDominators.cpp
@@ -7,6 +7,7 @@
#include "llvm/Analysis/Dominators.h"
#include "llvm/Transforms/UnifyMethodExitNodes.h"
#include "llvm/Method.h"
+#include "llvm/Support/CFG.h"
#include "Support/DepthFirstIterator.h"
#include "Support/STLExtras.h"
#include "Support/SetOperations.h"
diff --git a/lib/Bytecode/Reader/ReaderInternals.h b/lib/Bytecode/Reader/ReaderInternals.h
index 8a7297a8b3..a5b3b7acfd 100644
--- a/lib/Bytecode/Reader/ReaderInternals.h
+++ b/lib/Bytecode/Reader/ReaderInternals.h
@@ -10,6 +10,7 @@
#include "llvm/Bytecode/Primitives.h"
#include "llvm/SymTabValue.h"
#include "llvm/Method.h"
+#include "llvm/BasicBlock.h"
#include "llvm/Instruction.h"
#include "llvm/DerivedTypes.h"
#include <map>
diff --git a/lib/Bytecode/Writer/SlotCalculator.cpp b/lib/Bytecode/Writer/SlotCalculator.cpp
index 4738f712a1..43a4591cb8 100644
--- a/lib/Bytecode/Writer/SlotCalculator.cpp
+++ b/lib/Bytecode/Writer/SlotCalculator.cpp
@@ -171,7 +171,7 @@ void SlotCalculator::incorporateMethod(const Method *M) {
SC_DEBUG("Inserting Instructions:\n");
// Add all of the instructions to the type planes...
- for_each(M->inst_begin(), M->inst_end(),
+ for_each(inst_begin(M), inst_end(M),
bind_obj(this, &SlotCalculator::insertValue));
if (M->hasSymbolTable() && !IgnoreNamedNodes) {
diff --git a/lib/CodeGen/InstrSched/SchedPriorities.cpp b/lib/CodeGen/InstrSched/SchedPriorities.cpp
index 1d4983130e..ef9f9e4599 100644
--- a/lib/CodeGen/InstrSched/SchedPriorities.cpp
+++ b/lib/CodeGen/InstrSched/SchedPriorities.cpp
@@ -20,6 +20,7 @@
#include "SchedPriorities.h"
#include "llvm/Analysis/LiveVar/MethodLiveVarInfo.h"
+#include "llvm/Support/CFG.h"
#include "Support/PostOrderIterator.h"
#include <iostream>
using std::cerr;
diff --git a/lib/CodeGen/InstrSelection/InstrForest.cpp b/lib/CodeGen/InstrSelection/InstrForest.cpp
index 29090e06cc..b11d71e1f6 100644
--- a/lib/CodeGen/InstrSelection/InstrForest.cpp
+++ b/lib/CodeGen/InstrSelection/InstrForest.cpp
@@ -189,15 +189,18 @@ LabelNode::dumpNode(int indent) const
InstrForest::InstrForest(Method *M)
{
- for (Method::inst_iterator I = M->inst_begin(); I != M->inst_end(); ++I)
- this->buildTreeForInstruction(*I);
+ for (Method::iterator MI = M->begin(), ME = M->end(); MI != ME; ++MI) {
+ BasicBlock *BB = *MI;
+ for (BasicBlock::iterator I = BB->begin(), E = BB->end(); I != E; ++I)
+ buildTreeForInstruction(*I);
+ }
}
InstrForest::~InstrForest()
{
for (std::hash_map<const Instruction*,InstructionNode*>::iterator I = begin();
I != end(); ++I)
- delete (*I).second;
+ delete I->second;
}
void
diff --git a/lib/CodeGen/MachineFunction.cpp b/lib/CodeGen/MachineFunction.cpp
index 3ff3e8ceea..4bb17f15fe 100644
--- a/lib/CodeGen/MachineFunction.cpp
+++ b/lib/CodeGen/MachineFunction.cpp
@@ -12,6 +12,7 @@
#include "llvm/Target/MachineFrameInfo.h"
#include "llvm/Target/MachineCacheInfo.h"
#include "llvm/Method.h"
+#include "llvm/BasicBlock.h"
#include "llvm/iOther.h"
#include <limits.h>
@@ -56,11 +57,11 @@ ComputeMaxOptionalArgsSize(const TargetMachine& target, const Method* method)
unsigned int maxSize = 0;
- for (Method::const_inst_iterator I=method->inst_begin(),E=method->inst_end();
- I != E; ++I)
- if ((*I)->getOpcode() == Instruction::Call)
- {
- CallInst* callInst = cast<CallInst>(*I);
+ for (Method::const_iterator MI=method->begin(), ME=method->end();
+ MI != ME; ++MI) {
+ const BasicBlock *BB = *MI;
+ for (BasicBlock::const_iterator I = BB->begin(), E = BB->end(); I != E; ++I)
+ if (CallInst *callInst = dyn_cast<CallInst>(*I)) {
unsigned int numOperands = callInst->getNumOperands() - 1;
int numExtra = (int) numOperands - frameInfo.getNumFixedOutgoingArgs();
if (numExtra <= 0)
@@ -84,7 +85,7 @@ ComputeMaxOptionalArgsSize(const TargetMachine& target, const Method* method)
if (maxSize < sizeForThisCall)
maxSize = sizeForThisCall;
}
-
+ }
return maxSize;
}
diff --git a/lib/CodeGen/RegAlloc/LiveRangeInfo.cpp b/lib/CodeGen/RegAlloc/LiveRangeInfo.cpp
index 7302baa286..32951769e0 100644
--- a/lib/CodeGen/RegAlloc/LiveRangeInfo.cpp
+++ b/lib/CodeGen/RegAlloc/LiveRangeInfo.cpp
@@ -3,6 +3,7 @@
#include "llvm/CodeGen/MachineInstr.h"
#include "llvm/Target/TargetMachine.h"
#include "llvm/Method.h"
+#include "llvm/BasicBlock.h"
#include "Support/SetOperations.h"
#include <iostream>
using std::cerr;
diff --git a/lib/CodeGen/RegAlloc/PhyRegAlloc.cpp b/lib/CodeGen/RegAlloc/PhyRegAlloc.cpp
index 18d019e8f4..c78b971e79 100644
--- a/lib/CodeGen/RegAlloc/PhyRegAlloc.cpp
+++ b/lib/CodeGen/RegAlloc/PhyRegAlloc.cpp
@@ -18,6 +18,7 @@
#include "llvm/Analysis/LoopInfo.h"
#include "llvm/Target/TargetMachine.h"
#include "llvm/Target/MachineFrameInfo.h"
+#include "llvm/BasicBlock.h"
#include "llvm/Method.h"
#include "llvm/Type.h"
#include <iostream>
diff --git a/lib/ExecutionEngine/Interpreter/Execution.cpp b/lib/ExecutionEngine/Interpreter/Execution.cpp
index 0fad82964d..9f6317fd39 100644
--- a/lib/ExecutionEngine/Interpreter/Execution.cpp
+++ b/lib/ExecutionEngine/Interpreter/Execution.cpp
@@ -1034,10 +1034,12 @@ MethodInfo::MethodInfo(Method *M) : Annotation(MethodInfoAID) {
// Iterate over all of the instructions...
unsigned InstNum = 0;
- for (Method::inst_iterator MI = M->inst_begin(), ME = M->inst_end();
- MI != ME; ++MI) {
- Instruction *I = *MI; // For each instruction...
- I->addAnnotation(new InstNumber(++InstNum, getValueSlot(I))); // Add Annote
+ for (Method::iterator MI = M->begin(), ME = M->end(); MI != ME; ++MI) {
+ BasicBlock *BB = *MI;
+ for (BasicBlock::iterator II = BB->begin(), IE = BB->end(); II != IE; ++II){
+ Instruction *I = *II; // For each instruction... Add Annote
+ I->addAnnotation(new InstNumber(++InstNum, getValueSlot(I)));
+ }
}
}
diff --git a/lib/ExecutionEngine/Interpreter/Interpreter.h b/lib/ExecutionEngine/Interpreter/Interpreter.h
index ffe1001597..050b7d332d 100644
--- a/lib/ExecutionEngine/Interpreter/Interpreter.h
+++ b/lib/ExecutionEngine/Interpreter/Interpreter.h
@@ -13,6 +13,7 @@
#include "llvm/Module.h"
#include "llvm/Method.h"
+#include "llvm/BasicBlock.h"
#include "Support/DataTypes.h"
#include "llvm/Assembly/CachedWriter.h"
diff --git a/lib/Linker/LinkModules.cpp b/lib/Linker/LinkModules.cpp
index e1622529c2..f265bb05d1 100644
--- a/lib/Linker/LinkModules.cpp
+++ b/lib/Linker/LinkModules.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;
diff --git a/lib/Target/SparcV9/InstrSched/SchedPriorities.cpp b/lib/Target/SparcV9/InstrSched/SchedPriorities.cpp
index 1d4983130e..ef9f9e4599 100644
--- a/lib/Target/SparcV9/InstrSched/SchedPriorities.cpp
+++ b/lib/Target/SparcV9/InstrSched/SchedPriorities.cpp
@@ -20,6 +20,7 @@
#include "SchedPriorities.h"
#include "llvm/Analysis/LiveVar/MethodLiveVarInfo.h"
+#include "llvm/Support/CFG.h"
#include "Support/PostOrderIterator.h"
#include <iostream>
using std::cerr;
diff --git a/lib/Target/SparcV9/InstrSelection/InstrForest.cpp b/lib/Target/SparcV9/InstrSelection/InstrForest.cpp
index 29090e06cc..b11d71e1f6 100644
--- a/lib/Target/SparcV9/InstrSelection/InstrForest.cpp
+++ b/lib/Target/SparcV9/InstrSelection/InstrForest.cpp
@@ -189,15 +189,18 @@ LabelNode::dumpNode(int indent) const
InstrForest::InstrForest(Method *M)
{
- for (Method::inst_iterator I = M->inst_begin(); I != M->inst_end(); ++I)
- this->buildTreeForInstruction(*I);
+ for (Method::iterator MI = M->begin(), ME = M->end(); MI != ME; ++MI) {
+ BasicBlock *BB = *MI;
+ for (BasicBlock::iterator I = BB->begin(), E = BB->end(); I != E; ++I)
+ buildTreeForInstruction(*I);
+ }
}
InstrForest::~InstrForest()
{
for (std::hash_map<const Instruction*,InstructionNode*>::iterator I = begin();
I != end(); ++I)
- delete (*I).second;
+ delete I->second;
}
void
diff --git a/lib/Target/SparcV9/LiveVar/FunctionLiveVarInfo.cpp b/lib/Target/SparcV9/LiveVar/FunctionLiveVarInfo.cpp
index a1a2dba9fb..b83359f94b 100644
--- a/lib/Target/SparcV9/LiveVar/FunctionLiveVarInfo.cpp
+++ b/lib/Target/SparcV9/LiveVar/FunctionLiveVarInfo.cpp
@@ -9,6 +9,7 @@
#include "BBLiveVar.h"
#include "llvm/CodeGen/MachineInstr.h"
#include "llvm/BasicBlock.h"
+#include "llvm/Support/CFG.h"
#include "Support/PostOrderIterator.h"
#include "Support/SetOperations.h"
#include <iostream>
diff --git a/lib/Target/SparcV9/RegAlloc/LiveRangeInfo.cpp b/lib/Target/SparcV9/RegAlloc/LiveRangeInfo.cpp
index 7302baa286..32951769e0 100644
--- a/lib/Target/SparcV9/RegAlloc/LiveRangeInfo.cpp
+++ b/lib/Target/SparcV9/RegAlloc/LiveRangeInfo.cpp
@@ -3,6 +3,7 @@
#include "llvm/CodeGen/MachineInstr.h"
#include "llvm/Target/TargetMachine.h"
#include "llvm/Method.h"
+#include "llvm/BasicBlock.h"
#include "Support/SetOperations.h"
#include <iostream>
using std::cerr;
diff --git a/lib/Target/SparcV9/RegAlloc/PhyRegAlloc.cpp b/lib/Target/SparcV9/RegAlloc/PhyRegAlloc.cpp
index 18d019e8f4..c78b971e79 100644
--- a/lib/Target/SparcV9/RegAlloc/PhyRegAlloc.cpp
+++ b/lib/Target/SparcV9/RegAlloc/PhyRegAlloc.cpp
@@ -18,6 +18,7 @@
#include "llvm/Analysis/LoopInfo.h"
#include "llvm/Target/TargetMachine.h"
#include "llvm/Target/MachineFrameInfo.h"
+#include "llvm/BasicBlock.h"
#include "llvm/Method.h"
#include "llvm/Type.h"
#include <iostream>
diff --git a/lib/Target/SparcV9/SparcV9TargetMachine.cpp b/lib/Target/SparcV9/SparcV9TargetMachine.cpp
index 14be992315..b026ccd67a 100644
--- a/lib/Target/SparcV9/SparcV9TargetMachine.cpp
+++ b/lib/Target/SparcV9/SparcV9TargetMachine.cpp
@@ -19,6 +19,7 @@
#include "llvm/CodeGen/RegisterAllocation.h"
#include "llvm/CodeGen/MachineInstr.h"
#include "llvm/Method.h"
+#include "llvm/BasicBlock.h"
#include "llvm/PassManager.h"
#include <iostream>
using std::cerr;
@@ -229,7 +230,11 @@ struct FreeMachineCodeForMethod : public MethodPass {
}
bool runOnMethod(Method *M) {
- for_each(M->inst_begin(), M->inst_end(), freeMachineCode);
+ for (Method::iterator MI = M->begin(), ME = M->end(); MI != ME; ++MI)
+ for (BasicBlock::iterator I = (*MI)->begin(), E = (*MI)->end();
+ I != E; ++I)
+ freeMachineCode(*I);
+
// Don't destruct MachineCodeForMethod - The global printer needs it
//MachineCodeForMethod::destruct(M);
return false;
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;
diff --git a/lib/VMCore/Dominators.cpp b/lib/VMCore/Dominators.cpp
index aad6e1cb38..33e14e9fc5 100644
--- a/lib/VMCore/Dominators.cpp
+++ b/lib/VMCore/Dominators.cpp
@@ -7,6 +7,7 @@
#include "llvm/Analysis/Dominators.h"
#include "llvm/Transforms/UnifyMethodExitNodes.h"
#include "llvm/Method.h"
+#include "llvm/Support/CFG.h"
#include "Support/DepthFirstIterator.h"
#include "Support/STLExtras.h"
#include "Support/SetOperations.h"
diff --git a/lib/VMCore/Instruction.cpp b/lib/VMCore/Instruction.cpp
index 50fdd44227..e729a65a38 100644
--- a/lib/VMCore/Instruction.cpp
+++ b/lib/VMCore/Instruction.cpp
@@ -5,6 +5,7 @@
//===----------------------------------------------------------------------===//
#include "llvm/Instruction.h"
+#include "llvm/BasicBlock.h"
#include "ll