From a298d27808ecb8ffb574d6e50f56601db2ec5fda Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Sun, 28 Apr 2002 00:15:57 +0000 Subject: Change the Dominator info and LoopInfo classes to keep track of BasicBlock's, not const BasicBlocks git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@2337 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Analysis/InductionVariable.cpp | 4 ++-- lib/Analysis/LoopInfo.cpp | 18 +++++++-------- lib/Analysis/PostDominators.cpp | 28 ++++++++++++------------ lib/Analysis/Writer.cpp | 4 ++-- lib/Transforms/Utils/PromoteMemoryToRegister.cpp | 8 +++---- lib/VMCore/Dominators.cpp | 28 ++++++++++++------------ 6 files changed, 45 insertions(+), 45 deletions(-) (limited to 'lib') diff --git a/lib/Analysis/InductionVariable.cpp b/lib/Analysis/InductionVariable.cpp index 8c02dfa..4d4306b 100644 --- a/lib/Analysis/InductionVariable.cpp +++ b/lib/Analysis/InductionVariable.cpp @@ -31,8 +31,8 @@ static bool isLoopInvariant(const Value *V, const cfg::Loop *L) { if (isa(V) || isa(V) || isa(V)) return true; - const Instruction *I = cast(V); - const BasicBlock *BB = I->getParent(); + Instruction *I = cast(V); + BasicBlock *BB = I->getParent(); return !L->contains(BB); } diff --git a/lib/Analysis/LoopInfo.cpp b/lib/Analysis/LoopInfo.cpp index c34aef7..bf69172 100644 --- a/lib/Analysis/LoopInfo.cpp +++ b/lib/Analysis/LoopInfo.cpp @@ -18,7 +18,7 @@ AnalysisID cfg::LoopInfo::ID(AnalysisID::create()); //===----------------------------------------------------------------------===// // cfg::Loop implementation // -bool cfg::Loop::contains(const BasicBlock *BB) const { +bool cfg::Loop::contains(BasicBlock *BB) const { return find(Blocks.begin(), Blocks.end(), BB) != Blocks.end(); } @@ -42,9 +42,9 @@ bool cfg::LoopInfo::runOnFunction(Function *F) { } void cfg::LoopInfo::Calculate(const DominatorSet &DS) { - const BasicBlock *RootNode = DS.getRoot(); + BasicBlock *RootNode = DS.getRoot(); - for (df_iterator NI = df_begin(RootNode), + for (df_iterator NI = df_begin(RootNode), NE = df_end(RootNode); NI != NE; ++NI) if (Loop *L = ConsiderForLoop(*NI, DS)) TopLevelLoops.push_back(L); @@ -60,15 +60,15 @@ void cfg::LoopInfo::getAnalysisUsage(AnalysisUsage &AU) const { } -cfg::Loop *cfg::LoopInfo::ConsiderForLoop(const BasicBlock *BB, - const DominatorSet &DS) { +cfg::Loop *cfg::LoopInfo::ConsiderForLoop(BasicBlock *BB, + const DominatorSet &DS) { if (BBMap.find(BB) != BBMap.end()) return 0; // Havn't processed this node? - std::vector TodoStack; + std::vector TodoStack; // Scan the predecessors of BB, checking to see if BB dominates any of // them. - for (pred_const_iterator I = pred_begin(BB), E = pred_end(BB); I != E; ++I) + for (pred_iterator I = pred_begin(BB), E = pred_end(BB); I != E; ++I) if (DS.dominates(BB, *I)) // If BB dominates it's predecessor... TodoStack.push_back(*I); @@ -79,7 +79,7 @@ cfg::Loop *cfg::LoopInfo::ConsiderForLoop(const BasicBlock *BB, BBMap[BB] = L; while (!TodoStack.empty()) { // Process all the nodes in the loop - const BasicBlock *X = TodoStack.back(); + BasicBlock *X = TodoStack.back(); TodoStack.pop_back(); if (!L->contains(X)) { // As of yet unprocessed?? @@ -94,7 +94,7 @@ cfg::Loop *cfg::LoopInfo::ConsiderForLoop(const BasicBlock *BB, // loop can be found for them. Also check subsidary basic blocks to see if // they start subloops of their own. // - for (std::vector::reverse_iterator I = L->Blocks.rbegin(), + for (std::vector::reverse_iterator I = L->Blocks.rbegin(), E = L->Blocks.rend(); I != E; ++I) { // Check to see if this block starts a new loop diff --git a/lib/Analysis/PostDominators.cpp b/lib/Analysis/PostDominators.cpp index cf55ab5..a126083 100644 --- a/lib/Analysis/PostDominators.cpp +++ b/lib/Analysis/PostDominators.cpp @@ -48,8 +48,8 @@ void cfg::DominatorSet::calcForwardDominatorSet(Function *M) { DomSetType WorkingSet; df_iterator 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 *BB = *It; + pred_iterator PI = pred_begin(BB), PEnd = pred_end(BB); 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 @@ -80,7 +80,7 @@ void cfg::DominatorSet::calcForwardDominatorSet(Function *M) { // only have a single exit node (return stmt), then calculates the post // dominance sets for the function. // -void cfg::DominatorSet::calcPostDominatorSet(Function *M) { +void cfg::DominatorSet::calcPostDominatorSet(Function *F) { // Since we require that the unify all exit nodes pass has been run, we know // that there can be at most one return instruction in the function left. // Get it. @@ -88,8 +88,8 @@ void cfg::DominatorSet::calcPostDominatorSet(Function *M) { Root = getAnalysis().getExitNode(); if (Root == 0) { // No exit node for the function? Postdomsets are all empty - for (Function::const_iterator MI = M->begin(), ME = M->end(); MI!=ME; ++MI) - Doms[*MI] = DomSetType(); + for (Function::iterator FI = F->begin(), FE = F->end(); FI != FE; ++FI) + Doms[*FI] = DomSetType(); return; } @@ -101,8 +101,8 @@ void cfg::DominatorSet::calcPostDominatorSet(Function *M) { DomSetType WorkingSet; idf_iterator 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 *BB = *It; + succ_iterator PI = succ_begin(BB), PEnd = succ_end(BB); 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 @@ -158,7 +158,7 @@ void cfg::ImmediateDominators::calcIDoms(const DominatorSet &DS) { // for (DominatorSet::const_iterator DI = DS.begin(), DEnd = DS.end(); DI != DEnd; ++DI) { - const BasicBlock *BB = DI->first; + BasicBlock *BB = DI->first; const DominatorSet::DomSetType &Dominators = DI->second; unsigned DomSetSize = Dominators.size(); if (DomSetSize == 1) continue; // Root node... IDom = null @@ -237,7 +237,7 @@ void cfg::DominatorTree::calculate(const DominatorSet &DS) { // Iterate over all nodes in depth first order... for (df_iterator I = df_begin(Root), E = df_end(Root); I != E; ++I) { - const BasicBlock *BB = *I; + BasicBlock *BB = *I; const DominatorSet::DomSetType &Dominators = DS.getDominators(BB); unsigned DomSetSize = Dominators.size(); if (DomSetSize == 1) continue; // Root node... IDom = null @@ -278,7 +278,7 @@ void cfg::DominatorTree::calculate(const DominatorSet &DS) { // Iterate over all nodes in depth first order... for (idf_iterator I = idf_begin(Root), E = idf_end(Root); I != E; ++I) { - const BasicBlock *BB = *I; + BasicBlock *BB = *I; const DominatorSet::DomSetType &Dominators = DS.getDominators(BB); unsigned DomSetSize = Dominators.size(); if (DomSetSize == 1) continue; // Root node... IDom = null @@ -332,10 +332,10 @@ const cfg::DominanceFrontier::DomSetType & cfg::DominanceFrontier::calcDomFrontier(const DominatorTree &DT, const DominatorTree::Node *Node) { // Loop over CFG successors to calculate DFlocal[Node] - const BasicBlock *BB = Node->getNode(); + 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); + for (succ_iterator SI = succ_begin(BB), SE = succ_end(BB); SI != SE; ++SI) { // Does Node immediately dominate this successor? if (DT[*SI]->getIDom() != Node) @@ -365,11 +365,11 @@ const cfg::DominanceFrontier::DomSetType & cfg::DominanceFrontier::calcPostDomFrontier(const DominatorTree &DT, const DominatorTree::Node *Node) { // Loop over CFG successors to calculate DFlocal[Node] - const BasicBlock *BB = Node->getNode(); + BasicBlock *BB = Node->getNode(); 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); + for (pred_iterator SI = pred_begin(BB), SE = pred_end(BB); SI != SE; ++SI) { // Does Node immediately dominate this predeccessor? if (DT[*SI]->getIDom() != Node) diff --git a/lib/Analysis/Writer.cpp b/lib/Analysis/Writer.cpp index b4d5375..05bd770 100644 --- a/lib/Analysis/Writer.cpp +++ b/lib/Analysis/Writer.cpp @@ -50,8 +50,8 @@ void cfg::WriteToOutput(const IntervalPartition &IP, ostream &o) { // Dominator Printing Routines //===----------------------------------------------------------------------===// -ostream &operator<<(ostream &o, const set &BBs) { - copy(BBs.begin(),BBs.end(), std::ostream_iterator(o,"\n")); +ostream &operator<<(ostream &o, const set &BBs) { + copy(BBs.begin(),BBs.end(), std::ostream_iterator(o, "\n")); return o; } diff --git a/lib/Transforms/Utils/PromoteMemoryToRegister.cpp b/lib/Transforms/Utils/PromoteMemoryToRegister.cpp index 8726ed4..c3ed142 100644 --- a/lib/Transforms/Utils/PromoteMemoryToRegister.cpp +++ b/lib/Transforms/Utils/PromoteMemoryToRegister.cpp @@ -141,8 +141,8 @@ bool PromoteInstance::PromoteFunction(Function *F, DominanceFrontier & DF) { DominanceFrontier::DomSetType s = (*it).second; for (DominanceFrontier::DomSetType::iterator p = s.begin();p!=s.end(); ++p) { - if (queuePhiNode((BasicBlock *)*p, i)) - PhiNodes[i].push_back((BasicBlock *)*p); + if (queuePhiNode(*p, i)) + PhiNodes[i].push_back(*p); } } // perform iterative step @@ -152,8 +152,8 @@ bool PromoteInstance::PromoteFunction(Function *F, DominanceFrontier & DF) { DominanceFrontier::DomSetType s = it->second; for (DominanceFrontier::DomSetType::iterator p = s.begin(); p!=s.end(); ++p) { - if (queuePhiNode((BasicBlock *)*p,i)) - PhiNodes[i].push_back((BasicBlock*)*p); + if (queuePhiNode(*p,i)) + PhiNodes[i].push_back(*p); } } } diff --git a/lib/VMCore/Dominators.cpp b/lib/VMCore/Dominators.cpp index cf55ab5..a126083 100644 --- a/lib/VMCore/Dominators.cpp +++ b/lib/VMCore/Dominators.cpp @@ -48,8 +48,8 @@ void cfg::DominatorSet::calcForwardDominatorSet(Function *M) { DomSetType WorkingSet; df_iterator 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 *BB = *It; + pred_iterator PI = pred_begin(BB), PEnd = pred_end(BB); 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 @@ -80,7 +80,7 @@ void cfg::DominatorSet::calcForwardDominatorSet(Function *M) { // only have a single exit node (return stmt), then calculates the post // dominance sets for the function. // -void cfg::DominatorSet::calcPostDominatorSet(Function *M) { +void cfg::DominatorSet::calcPostDominatorSet(Function *F) { // Since we require that the unify all exit nodes pass has been run, we know // that there can be at most one return instruction in the function left. // Get it. @@ -88,8 +88,8 @@ void cfg::DominatorSet::calcPostDominatorSet(Function *M) { Root = getAnalysis().getExitNode(); if (Root == 0) { // No exit node for the function? Postdomsets are all empty - for (Function::const_iterator MI = M->begin(), ME = M->end(); MI!=ME; ++MI) - Doms[*MI] = DomSetType(); + for (Function::iterator FI = F->begin(), FE = F->end(); FI != FE; ++FI) + Doms[*FI] = DomSetType(); return; } @@ -101,8 +101,8 @@ void cfg::DominatorSet::calcPostDominatorSet(Function *M) { DomSetType WorkingSet; idf_iterator 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 *BB = *It; + succ_iterator PI = succ_begin(BB), PEnd = succ_end(BB); 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 @@ -158,7 +158,7 @@ void cfg::ImmediateDominators::calcIDoms(const DominatorSet &DS) { // for (DominatorSet::const_iterator DI = DS.begin(), DEnd = DS.end(); DI != DEnd; ++DI) { - const BasicBlock *BB = DI->first; + BasicBlock *BB = DI->first; const DominatorSet::DomSetType &Dominators = DI->second; unsigned DomSetSize = Dominators.size(); if (DomSetSize == 1) continue; // Root node... IDom = null @@ -237,7 +237,7 @@ void cfg::DominatorTree::calculate(const DominatorSet &DS) { // Iterate over all nodes in depth first order... for (df_iterator I = df_begin(Root), E = df_end(Root); I != E; ++I) { - const BasicBlock *BB = *I; + BasicBlock *BB = *I; const DominatorSet::DomSetType &Dominators = DS.getDominators(BB); unsigned DomSetSize = Dominators.size(); if (DomSetSize == 1) continue; // Root node... IDom = null @@ -278,7 +278,7 @@ void cfg::DominatorTree::calculate(const DominatorSet &DS) { // Iterate over all nodes in depth first order... for (idf_iterator I = idf_begin(Root), E = idf_end(Root); I != E; ++I) { - const BasicBlock *BB = *I; + BasicBlock *BB = *I; const DominatorSet::DomSetType &Dominators = DS.getDominators(BB); unsigned DomSetSize = Dominators.size(); if (DomSetSize == 1) continue; // Root node... IDom = null @@ -332,10 +332,10 @@ const cfg::DominanceFrontier::DomSetType & cfg::DominanceFrontier::calcDomFrontier(const DominatorTree &DT, const DominatorTree::Node *Node) { // Loop over CFG successors to calculate DFlocal[Node] - const BasicBlock *BB = Node->getNode(); + 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); + for (succ_iterator SI = succ_begin(BB), SE = succ_end(BB); SI != SE; ++SI) { // Does Node immediately dominate this successor? if (DT[*SI]->getIDom() != Node) @@ -365,11 +365,11 @@ const cfg::DominanceFrontier::DomSetType & cfg::DominanceFrontier::calcPostDomFrontier(const DominatorTree &DT, const DominatorTree::Node *Node) { // Loop over CFG successors to calculate DFlocal[Node] - const BasicBlock *BB = Node->getNode(); + BasicBlock *BB = Node->getNode(); 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); + for (pred_iterator SI = pred_begin(BB), SE = pred_end(BB); SI != SE; ++SI) { // Does Node immediately dominate this predeccessor? if (DT[*SI]->getIDom() != Node) -- cgit v1.1