SCC: Change clients to use const, NFC

It's fishy to be changing the `std::vector<>` owned by the iterator, and
no one actual does it, so I'm going to remove the ability in a
subsequent commit.  First, update the users.

<rdar://problem/14292693>

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@207252 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Duncan P. N. Exon Smith 2014-04-25 18:24:50 +00:00
parent 5a6277a230
commit db8c1ae04e
7 changed files with 13 additions and 14 deletions

View File

@ -435,8 +435,8 @@ bool CGPassManager::runOnModule(Module &M) {
while (!CGI.isAtEnd()) {
// Copy the current SCC and increment past it so that the pass can hack
// on the SCC if it wants to without invalidating our iterator.
std::vector<CallGraphNode*> &NodeVec = *CGI;
CurSCC.initialize(&NodeVec[0], &NodeVec[0]+NodeVec.size());
const std::vector<CallGraphNode *> &NodeVec = *CGI;
CurSCC.initialize(NodeVec.data(), NodeVec.data() + NodeVec.size());
++CGI;
// At the top level, we run all the passes in this pass manager on the

View File

@ -359,7 +359,7 @@ void GlobalsModRef::AnalyzeCallGraph(CallGraph &CG, Module &M) {
// We do a bottom-up SCC traversal of the call graph. In other words, we
// visit all callees before callers (leaf-first).
for (scc_iterator<CallGraph*> I = scc_begin(&CG); !I.isAtEnd(); ++I) {
std::vector<CallGraphNode *> &SCC = *I;
const std::vector<CallGraphNode *> &SCC = *I;
assert(!SCC.empty() && "SCC with no functions?");
if (!SCC[0]->getFunction()) {

View File

@ -933,7 +933,7 @@ void AMDGPUCFGStructurizer::orderBlocks(MachineFunction *MF) {
MachineBasicBlock *MBB;
for (scc_iterator<MachineFunction *> It = scc_begin(MF); !It.isAtEnd();
++It, ++SccNum) {
std::vector<MachineBasicBlock *> &SccNext = *It;
const std::vector<MachineBasicBlock *> &SccNext = *It;
for (std::vector<MachineBasicBlock *>::const_iterator
blockIter = SccNext.begin(), blockEnd = SccNext.end();
blockIter != blockEnd; ++blockIter) {

View File

@ -601,7 +601,7 @@ bool FunctionAttrs::AddArgumentAttrs(const CallGraphSCC &SCC) {
// captures.
for (scc_iterator<ArgumentGraph*> I = scc_begin(&AG); !I.isAtEnd(); ++I) {
std::vector<ArgumentGraphNode*> &ArgumentSCC = *I;
const std::vector<ArgumentGraphNode *> &ArgumentSCC = *I;
if (ArgumentSCC.size() == 1) {
if (!ArgumentSCC[0]->Definition) continue; // synthetic root node
@ -617,8 +617,8 @@ bool FunctionAttrs::AddArgumentAttrs(const CallGraphSCC &SCC) {
}
bool SCCCaptured = false;
for (std::vector<ArgumentGraphNode*>::iterator I = ArgumentSCC.begin(),
E = ArgumentSCC.end(); I != E && !SCCCaptured; ++I) {
for (auto I = ArgumentSCC.begin(), E = ArgumentSCC.end();
I != E && !SCCCaptured; ++I) {
ArgumentGraphNode *Node = *I;
if (Node->Uses.empty()) {
if (!Node->Definition->hasNoCaptureAttr())
@ -630,13 +630,12 @@ bool FunctionAttrs::AddArgumentAttrs(const CallGraphSCC &SCC) {
SmallPtrSet<Argument*, 8> ArgumentSCCNodes;
// Fill ArgumentSCCNodes with the elements of the ArgumentSCC. Used for
// quickly looking up whether a given Argument is in this ArgumentSCC.
for (std::vector<ArgumentGraphNode*>::iterator I = ArgumentSCC.begin(),
E = ArgumentSCC.end(); I != E; ++I) {
for (auto I = ArgumentSCC.begin(), E = ArgumentSCC.end(); I != E; ++I) {
ArgumentSCCNodes.insert((*I)->Definition);
}
for (std::vector<ArgumentGraphNode*>::iterator I = ArgumentSCC.begin(),
E = ArgumentSCC.end(); I != E && !SCCCaptured; ++I) {
for (auto I = ArgumentSCC.begin(), E = ArgumentSCC.end();
I != E && !SCCCaptured; ++I) {
ArgumentGraphNode *N = *I;
for (SmallVectorImpl<ArgumentGraphNode*>::iterator UI = N->Uses.begin(),
UE = N->Uses.end(); UI != UE; ++UI) {

View File

@ -280,7 +280,7 @@ bool StructurizeCFG::doInitialization(Region *R, RGPassManager &RGM) {
void StructurizeCFG::orderNodes() {
scc_iterator<Region *> I = scc_begin(ParentRegion);
for (Order.clear(); !I.isAtEnd(); ++I) {
std::vector<RegionNode *> &Nodes = *I;
const std::vector<RegionNode *> &Nodes = *I;
Order.append(Nodes.begin(), Nodes.end());
}
}

View File

@ -75,7 +75,7 @@ bool CFGSCC::runOnFunction(Function &F) {
unsigned sccNum = 0;
errs() << "SCCs for Function " << F.getName() << " in PostOrder:";
for (scc_iterator<Function*> SCCI = scc_begin(&F); !SCCI.isAtEnd(); ++SCCI) {
std::vector<BasicBlock*> &nextSCC = *SCCI;
const std::vector<BasicBlock *> &nextSCC = *SCCI;
errs() << "\nSCC #" << ++sccNum << " : ";
for (std::vector<BasicBlock*>::const_iterator I = nextSCC.begin(),
E = nextSCC.end(); I != E; ++I)

View File

@ -277,7 +277,7 @@ TEST(SCCIteratorTest, AllSmallGraphs) {
GT::NodeSubset NodesInSomeSCC;
for (scc_iterator<GT> I = scc_begin(G), E = scc_end(G); I != E; ++I) {
std::vector<GT::NodeType*> &SCC = *I;
const std::vector<GT::NodeType *> &SCC = *I;
// Get the nodes in this SCC as a NodeSubset rather than a vector.
GT::NodeSubset NodesInThisSCC;