summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Transforms
diff options
context:
space:
mode:
Diffstat (limited to 'llvm/lib/Transforms')
-rw-r--r--llvm/lib/Transforms/Scalar/ADCE.cpp4
-rw-r--r--llvm/lib/Transforms/Scalar/DCE.cpp33
-rw-r--r--llvm/lib/Transforms/Scalar/InductionVars.cpp9
3 files changed, 21 insertions, 25 deletions
diff --git a/llvm/lib/Transforms/Scalar/ADCE.cpp b/llvm/lib/Transforms/Scalar/ADCE.cpp
index 446b95afe09..480a2696b56 100644
--- a/llvm/lib/Transforms/Scalar/ADCE.cpp
+++ b/llvm/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/llvm/lib/Transforms/Scalar/DCE.cpp b/llvm/lib/Transforms/Scalar/DCE.cpp
index 119f92bae4b..ba3db99279f 100644
--- a/llvm/lib/Transforms/Scalar/DCE.cpp
+++ b/llvm/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/llvm/lib/Transforms/Scalar/InductionVars.cpp b/llvm/lib/Transforms/Scalar/InductionVars.cpp
index b78eab8ad2e..69521d6c8b3 100644
--- a/llvm/lib/Transforms/Scalar/InductionVars.cpp
+++ b/llvm/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);
OpenPOWER on IntegriCloud