aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/Analysis/Interval.cpp8
-rw-r--r--lib/Analysis/LiveVar/BBLiveVar.cpp4
-rw-r--r--lib/Analysis/LiveVar/BBLiveVar.h3
-rw-r--r--lib/Analysis/PostDominators.cpp14
-rw-r--r--lib/Target/SparcV9/LiveVar/BBLiveVar.cpp4
-rw-r--r--lib/Target/SparcV9/LiveVar/BBLiveVar.h3
-rw-r--r--lib/Transforms/Scalar/ADCE.cpp4
-rw-r--r--lib/Transforms/Scalar/DCE.cpp33
-rw-r--r--lib/Transforms/Scalar/InductionVars.cpp9
-rw-r--r--lib/VMCore/BasicBlock.cpp6
-rw-r--r--lib/VMCore/Dominators.cpp14
11 files changed, 48 insertions, 54 deletions
diff --git a/lib/Analysis/Interval.cpp b/lib/Analysis/Interval.cpp
index 97fa34ea7a..5c68be9c2e 100644
--- a/lib/Analysis/Interval.cpp
+++ b/lib/Analysis/Interval.cpp
@@ -8,19 +8,17 @@
#include "llvm/Analysis/Interval.h"
#include "llvm/BasicBlock.h"
-using namespace cfg;
-
//===----------------------------------------------------------------------===//
// Interval Implementation
//===----------------------------------------------------------------------===//
// isLoop - Find out if there is a back edge in this interval...
//
-bool Interval::isLoop() const {
+bool cfg::Interval::isLoop() const {
// There is a loop in this interval iff one of the predecessors of the header
// node lives in the interval.
- for (BasicBlock::pred_iterator I = pred_begin(HeaderNode),
- E = pred_end(HeaderNode); I != E; ++I) {
+ for (BasicBlock::pred_iterator I = HeaderNode->pred_begin(),
+ E = HeaderNode->pred_end(); I != E; ++I) {
if (contains(*I)) return true;
}
return false;
diff --git a/lib/Analysis/LiveVar/BBLiveVar.cpp b/lib/Analysis/LiveVar/BBLiveVar.cpp
index 210a24bd09..80fde4e157 100644
--- a/lib/Analysis/LiveVar/BBLiveVar.cpp
+++ b/lib/Analysis/LiveVar/BBLiveVar.cpp
@@ -162,9 +162,9 @@ bool BBLiveVar::applyFlowFunc(BBToBBLiveVarMapType LVMap)
// whose POId is lower
- cfg::pred_const_iterator PredBBI = cfg::pred_begin(BaseBB);
+ BasicBlock::pred_const_iterator PredBBI = BaseBB->pred_begin();
- for( ; PredBBI != cfg::pred_end(BaseBB) ; PredBBI++) {
+ for( ; PredBBI != BaseBB->pred_end() ; PredBBI++) {
assert( *PredBBI ); // assert that the predecessor is valid
BBLiveVar *PredLVBB = LVMap[*PredBBI];
diff --git a/lib/Analysis/LiveVar/BBLiveVar.h b/lib/Analysis/LiveVar/BBLiveVar.h
index e4d5804489..55a6c3abd5 100644
--- a/lib/Analysis/LiveVar/BBLiveVar.h
+++ b/lib/Analysis/LiveVar/BBLiveVar.h
@@ -1,4 +1,4 @@
-/* Title: BBLiveVar.h
+/* Title: BBLiveVar.h -*- C++ -*-
Author: Ruchira Sasanka
Date: Jun 30, 01
Purpose: This is a wrapper class for BasicBlock which is used by live
@@ -13,7 +13,6 @@
#include "llvm/BasicBlock.h"
#include "llvm/Instruction.h"
-#include "llvm/CFG.h"
#include "llvm/Type.h"
#include "llvm/iOther.h"
diff --git a/lib/Analysis/PostDominators.cpp b/lib/Analysis/PostDominators.cpp
index 0372141505..c241646b63 100644
--- a/lib/Analysis/PostDominators.cpp
+++ b/lib/Analysis/PostDominators.cpp
@@ -63,7 +63,8 @@ void cfg::DominatorSet::calcForwardDominatorSet(const Method *M) {
df_iterator<const Method*> It = df_begin(M), End = df_end(M);
for ( ; It != End; ++It) {
const BasicBlock *BB = *It;
- pred_const_iterator PI = pred_begin(BB), PEnd = pred_end(BB);
+ BasicBlock::pred_const_iterator PI = BB->pred_begin(),
+ PEnd = BB->pred_end();
if (PI != PEnd) { // Is there SOME predecessor?
// Loop until we get to a predecessor that has had it's dom set filled
// in at least once. We are guaranteed to have this because we are
@@ -114,7 +115,8 @@ cfg::DominatorSet::DominatorSet(Method *M, bool PostDomSet)
idf_iterator<const BasicBlock*> It = idf_begin(Root), End = idf_end(Root);
for ( ; It != End; ++It) {
const BasicBlock *BB = *It;
- succ_const_iterator PI = succ_begin(BB), PEnd = succ_end(BB);
+ BasicBlock::succ_const_iterator PI = BB->succ_begin(),
+ PEnd = BB->succ_end();
if (PI != PEnd) { // Is there SOME predecessor?
// Loop until we get to a successor that has had it's dom set filled
// in at least once. We are guaranteed to have this because we are
@@ -320,8 +322,8 @@ cfg::DominanceFrontier::calcDomFrontier(const DominatorTree &DT,
const BasicBlock *BB = Node->getNode();
DomSetType &S = Frontiers[BB]; // The new set to fill in...
- for (succ_const_iterator SI = succ_begin(BB), SE = succ_end(BB);
- SI != SE; ++SI) {
+ for (BasicBlock::succ_const_iterator SI = BB->succ_begin(),
+ SE = BB->succ_end(); SI != SE; ++SI) {
// Does Node immediately dominate this successor?
if (DT[*SI]->getIDom() != Node)
S.insert(*SI);
@@ -354,8 +356,8 @@ cfg::DominanceFrontier::calcPostDomFrontier(const DominatorTree &DT,
DomSetType &S = Frontiers[BB]; // The new set to fill in...
if (!Root) return S;
- for (pred_const_iterator SI = pred_begin(BB), SE = pred_end(BB);
- SI != SE; ++SI) {
+ for (BasicBlock::pred_const_iterator SI = BB->pred_begin(),
+ SE = BB->pred_end(); SI != SE; ++SI) {
// Does Node immediately dominate this predeccessor?
if (DT[*SI]->getIDom() != Node)
S.insert(*SI);
diff --git a/lib/Target/SparcV9/LiveVar/BBLiveVar.cpp b/lib/Target/SparcV9/LiveVar/BBLiveVar.cpp
index 210a24bd09..80fde4e157 100644
--- a/lib/Target/SparcV9/LiveVar/BBLiveVar.cpp
+++ b/lib/Target/SparcV9/LiveVar/BBLiveVar.cpp
@@ -162,9 +162,9 @@ bool BBLiveVar::applyFlowFunc(BBToBBLiveVarMapType LVMap)
// whose POId is lower
- cfg::pred_const_iterator PredBBI = cfg::pred_begin(BaseBB);
+ BasicBlock::pred_const_iterator PredBBI = BaseBB->pred_begin();
- for( ; PredBBI != cfg::pred_end(BaseBB) ; PredBBI++) {
+ for( ; PredBBI != BaseBB->pred_end() ; PredBBI++) {
assert( *PredBBI ); // assert that the predecessor is valid
BBLiveVar *PredLVBB = LVMap[*PredBBI];
diff --git a/lib/Target/SparcV9/LiveVar/BBLiveVar.h b/lib/Target/SparcV9/LiveVar/BBLiveVar.h
index e4d5804489..55a6c3abd5 100644
--- a/lib/Target/SparcV9/LiveVar/BBLiveVar.h
+++ b/lib/Target/SparcV9/LiveVar/BBLiveVar.h
@@ -1,4 +1,4 @@
-/* Title: BBLiveVar.h
+/* Title: BBLiveVar.h -*- C++ -*-
Author: Ruchira Sasanka
Date: Jun 30, 01
Purpose: This is a wrapper class for BasicBlock which is used by live
@@ -13,7 +13,6 @@
#include "llvm/BasicBlock.h"
#include "llvm/Instruction.h"
-#include "llvm/CFG.h"
#include "llvm/Type.h"
#include "llvm/iOther.h"
diff --git a/lib/Transforms/Scalar/ADCE.cpp b/lib/Transforms/Scalar/ADCE.cpp
index 446b95afe0..480a2696b5 100644
--- a/lib/Transforms/Scalar/ADCE.cpp
+++ b/lib/Transforms/Scalar/ADCE.cpp
@@ -264,7 +264,7 @@ BasicBlock *ADCE::fixupCFG(BasicBlock *BB, set<BasicBlock*> &VisitedBlocks,
}
// Recursively traverse successors of this basic block.
- cfg::succ_iterator SI = cfg::succ_begin(BB), SE = cfg::succ_end(BB);
+ BasicBlock::succ_iterator SI = BB->succ_begin(), SE = BB->succ_end();
for (; SI != SE; ++SI) {
BasicBlock *Succ = *SI;
BasicBlock *Repl = fixupCFG(Succ, VisitedBlocks, AliveBlocks);
@@ -278,7 +278,7 @@ BasicBlock *ADCE::fixupCFG(BasicBlock *BB, set<BasicBlock*> &VisitedBlocks,
BasicBlock *ReturnBB = 0; // Default to nothing live down here
// Recursively traverse successors of this basic block.
- cfg::succ_iterator SI = cfg::succ_begin(BB), SE = cfg::succ_end(BB);
+ BasicBlock::succ_iterator SI = BB->succ_begin(), SE = BB->succ_end();
for (; SI != SE; ++SI) {
BasicBlock *RetBB = fixupCFG(*SI, VisitedBlocks, AliveBlocks);
if (RetBB) {
diff --git a/lib/Transforms/Scalar/DCE.cpp b/lib/Transforms/Scalar/DCE.cpp
index 119f92bae4..ba3db99279 100644
--- a/lib/Transforms/Scalar/DCE.cpp
+++ b/lib/Transforms/Scalar/DCE.cpp
@@ -31,11 +31,8 @@
#include "llvm/iTerminators.h"
#include "llvm/iOther.h"
#include "llvm/Assembly/Writer.h"
-#include "llvm/CFG.h"
#include <algorithm>
-using namespace cfg;
-
struct ConstPoolDCE {
enum { EndOffs = 0 };
static bool isDCEable(const ConstPoolVal *CPV) {
@@ -82,15 +79,15 @@ static bool RemoveUnusedDefs(Container &Vals, DCEController DCEControl) {
// things in a basic block, if they are present.
//
static bool RemoveSingularPHIs(BasicBlock *BB) {
- pred_iterator PI(pred_begin(BB));
- if (PI == pred_end(BB) || ++PI != pred_end(BB))
+ BasicBlock::pred_iterator PI(BB->pred_begin());
+ if (PI == BB->pred_end() || ++PI != BB->pred_end())
return false; // More than one predecessor...
Instruction *I = BB->front();
if (!I->isPHINode()) return false; // No PHI nodes
//cerr << "Killing PHIs from " << BB;
- //cerr << "Pred #0 = " << *pred_begin(BB);
+ //cerr << "Pred #0 = " << *BB->pred_begin();
//cerr << "Method == " << BB->getParent();
@@ -128,7 +125,7 @@ static void PropogatePredecessorsForPHIs(BasicBlock *BB, BasicBlock *Succ) {
// If there is more than one predecessor, and there are PHI nodes in
// the successor, then we need to add incoming edges for the PHI nodes
//
- const vector<BasicBlock*> BBPreds(pred_begin(BB), pred_end(BB));
+ const vector<BasicBlock*> BBPreds(BB->pred_begin(), BB->pred_end());
BasicBlock::iterator I = Succ->begin();
do { // Loop over all of the PHI nodes in the successor BB
@@ -166,13 +163,13 @@ bool opt::SimplifyCFG(Method::iterator &BBIt) {
// Remove basic blocks that have no predecessors... which are unreachable.
- if (pred_begin(BB) == pred_end(BB) &&
+ if (BB->pred_begin() == BB->pred_end() &&
!BB->hasConstantPoolReferences()) {
//cerr << "Removing BB: \n" << BB;
// Loop through all of our successors and make sure they know that one
// of their predecessors is going away.
- for_each(succ_begin(BB), succ_end(BB),
+ for_each(BB->succ_begin(), BB->succ_end(),
std::bind2nd(std::mem_fun(&BasicBlock::removePredecessor), BB));
while (!BB->empty()) {
@@ -193,11 +190,11 @@ bool opt::SimplifyCFG(Method::iterator &BBIt) {
// Check to see if this block has no instructions and only a single
// successor. If so, replace block references with successor.
- succ_iterator SI(succ_begin(BB));
- if (SI != succ_end(BB) && ++SI == succ_end(BB)) { // One succ?
+ BasicBlock::succ_iterator SI(BB->succ_begin());
+ if (SI != BB->succ_end() && ++SI == BB->succ_end()) { // One succ?
Instruction *I = BB->front();
if (I->isTerminator()) { // Terminator is the only instruction!
- BasicBlock *Succ = *succ_begin(BB); // There is exactly one successor
+ BasicBlock *Succ = *BB->succ_begin(); // There is exactly one successor
//cerr << "Killing Trivial BB: \n" << BB;
if (Succ != BB) { // Arg, don't hurt infinite loops!
@@ -223,16 +220,16 @@ bool opt::SimplifyCFG(Method::iterator &BBIt) {
// Merge basic blocks into their predecessor if there is only one pred,
// and if there is only one successor of the predecessor.
- pred_iterator PI(pred_begin(BB));
- if (PI != pred_end(BB) && *PI != BB && // Not empty? Not same BB?
- ++PI == pred_end(BB) && !BB->hasConstantPoolReferences()) {
- BasicBlock *Pred = *pred_begin(BB);
+ BasicBlock::pred_iterator PI(BB->pred_begin());
+ if (PI != BB->pred_end() && *PI != BB && // Not empty? Not same BB?
+ ++PI == BB->pred_end() && !BB->hasConstantPoolReferences()) {
+ BasicBlock *Pred = *BB->pred_begin();
TerminatorInst *Term = Pred->getTerminator();
assert(Term != 0 && "malformed basic block without terminator!");
// Does the predecessor block only have a single successor?
- succ_iterator SI(succ_begin(Pred));
- if (++SI == succ_end(Pred)) {
+ BasicBlock::succ_iterator SI(Pred->succ_begin());
+ if (++SI == Pred->succ_end()) {
//cerr << "Merging: " << BB << "into: " << Pred;
// Delete the unconditianal branch from the predecessor...
diff --git a/lib/Transforms/Scalar/InductionVars.cpp b/lib/Transforms/Scalar/InductionVars.cpp
index b78eab8ad2..69521d6c8b 100644
--- a/lib/Transforms/Scalar/InductionVars.cpp
+++ b/lib/Transforms/Scalar/InductionVars.cpp
@@ -26,7 +26,6 @@
#include "llvm/Support/STLExtras.h"
#include "llvm/SymbolTable.h"
#include "llvm/iOther.h"
-#include "llvm/CFG.h"
#include <algorithm>
#include "llvm/Analysis/LoopDepth.h"
@@ -199,12 +198,12 @@ static PHINode *InjectSimpleInductionVariable(cfg::Interval *Int) {
// Figure out which predecessors I have to play with... there should be
// exactly two... one of which is a loop predecessor, and one of which is not.
//
- cfg::pred_iterator PI = cfg::pred_begin(Header);
- assert(PI != cfg::pred_end(Header) && "Header node should have 2 preds!");
+ BasicBlock::pred_iterator PI = Header->pred_begin();
+ assert(PI != Header->pred_end() && "Header node should have 2 preds!");
BasicBlock *Pred1 = *PI; ++PI;
- assert(PI != cfg::pred_end(Header) && "Header node should have 2 preds!");
+ assert(PI != Header->pred_end() && "Header node should have 2 preds!");
BasicBlock *Pred2 = *PI;
- assert(++PI == cfg::pred_end(Header) && "Header node should have 2 preds!");
+ assert(++PI == Header->pred_end() && "Header node should have 2 preds!");
// Make Pred1 be the loop entrance predecessor, Pred2 be the Loop predecessor
if (Int->contains(Pred1)) swap(Pred1, Pred2);
diff --git a/lib/VMCore/BasicBlock.cpp b/lib/VMCore/BasicBlock.cpp
index 4c480db631..7d97c85f7d 100644
--- a/lib/VMCore/BasicBlock.cpp
+++ b/lib/VMCore/BasicBlock.cpp
@@ -10,7 +10,6 @@
#include "llvm/Method.h"
#include "llvm/SymbolTable.h"
#include "llvm/Type.h"
-#include "llvm/CFG.h"
#include "llvm/iOther.h"
#include "llvm/CodeGen/MachineInstr.h"
@@ -91,12 +90,11 @@ bool BasicBlock::hasConstantPoolReferences() const {
// called while the predecessor still refers to this block.
//
void BasicBlock::removePredecessor(BasicBlock *Pred) {
- using cfg::pred_begin; using cfg::pred_end; using cfg::pred_iterator;
- assert(find(pred_begin(this), pred_end(this), Pred) != pred_end(this) &&
+ assert(find(pred_begin(), pred_end(), Pred) != pred_end() &&
"removePredecessor: BB is not a predecessor!");
if (!front()->isPHINode()) return; // Quick exit.
- pred_iterator PI(pred_begin(this)), EI(pred_end(this));
+ pred_iterator PI(pred_begin()), EI(pred_end());
unsigned max_idx;
// Loop over the rest of the predecessors until we run out, or until we find
diff --git a/lib/VMCore/Dominators.cpp b/lib/VMCore/Dominators.cpp
index 0372141505..c241646b63 100644
--- a/lib/VMCore/Dominators.cpp
+++ b/lib/VMCore/Dominators.cpp
@@ -63,7 +63,8 @@ void cfg::DominatorSet::calcForwardDominatorSet(const Method *M) {
df_iterator<const Method*> It = df_begin(M), End = df_end(M);
for ( ; It != End; ++It) {
const BasicBlock *BB = *It;
- pred_const_iterator PI = pred_begin(BB), PEnd = pred_end(BB);
+ BasicBlock::pred_const_iterator PI = BB->pred_begin(),
+ PEnd = BB->pred_end();
if (PI != PEnd) { // Is there SOME predecessor?
// Loop until we get to a predecessor that has had it's dom set filled
// in at least once. We are guaranteed to have this because we are
@@ -114,7 +115,8 @@ cfg::DominatorSet::DominatorSet(Method *M, bool PostDomSet)
idf_iterator<const BasicBlock*> It = idf_begin(Root), End = idf_end(Root);
for ( ; It != End; ++It) {
const BasicBlock *BB = *It;
- succ_const_iterator PI = succ_begin(BB), PEnd = succ_end(BB);
+ BasicBlock::succ_const_iterator PI = BB->succ_begin(),
+ PEnd = BB->succ_end();
if (PI != PEnd) { // Is there SOME predecessor?
// Loop until we get to a successor that has had it's dom set filled
// in at least once. We are guaranteed to have this because we are
@@ -320,8 +322,8 @@ cfg::DominanceFrontier::calcDomFrontier(const DominatorTree &DT,
const BasicBlock *BB = Node->getNode();
DomSetType &S = Frontiers[BB]; // The new set to fill in...
- for (succ_const_iterator SI = succ_begin(BB), SE = succ_end(BB);
- SI != SE; ++SI) {
+ for (BasicBlock::succ_const_iterator SI = BB->succ_begin(),
+ SE = BB->succ_end(); SI != SE; ++SI) {
// Does Node immediately dominate this successor?
if (DT[*SI]->getIDom() != Node)
S.insert(*SI);
@@ -354,8 +356,8 @@ cfg::DominanceFrontier::calcPostDomFrontier(const DominatorTree &DT,
DomSetType &S = Frontiers[BB]; // The new set to fill in...
if (!Root) return S;
- for (pred_const_iterator SI = pred_begin(BB), SE = pred_end(BB);
- SI != SE; ++SI) {
+ for (BasicBlock::pred_const_iterator SI = BB->pred_begin(),
+ SE = BB->pred_end(); SI != SE; ++SI) {
// Does Node immediately dominate this predeccessor?
if (DT[*SI]->getIDom() != Node)
S.insert(*SI);