summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: e3273c5)
raw | patch | inline | side by side (parent: e3273c5)
author | Chandler Carruth <chandlerc@gmail.com> | |
Wed, 23 Apr 2014 23:51:07 +0000 (23:51 +0000) | ||
committer | Chandler Carruth <chandlerc@gmail.com> | |
Wed, 23 Apr 2014 23:51:07 +0000 (23:51 +0000) |
values rather than having pointers in weird places.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@207053 91177308-0d34-0410-b5e6-96231b3b80d8
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@207053 91177308-0d34-0410-b5e6-96231b3b80d8
index 618fee153c18f841ab01953b62549ee4ec01a87a..09101ae6d0d12b4f8f86057993f897c34e525559 100644 (file)
LazyCallGraph &CG = AM->getResult<LazyCallGraphAnalysis>(M);
PreservedAnalyses PA = PreservedAnalyses::all();
- for (LazyCallGraph::SCC *C : CG.postorder_sccs()) {
- PreservedAnalyses PassPA = Pass.run(C, &CGAM);
+ for (LazyCallGraph::SCC &C : CG.postorder_sccs()) {
+ PreservedAnalyses PassPA = Pass.run(&C, &CGAM);
// We know that the CGSCC pass couldn't have invalidated any other
// SCC's analyses (that's the contract of a CGSCC pass), so
// FIXME: This isn't quite correct. We need to handle the case where the
// pass updated the CG, particularly some child of the current SCC, and
// invalidate its analyses.
- CGAM.invalidate(C, PassPA);
+ CGAM.invalidate(&C, PassPA);
// Then intersect the preserved set so that invalidation of module
// analyses will eventually occur when the module pass completes.
index d0de2aab10b5086d0374b5e165dd7cdba82d4a56..039b8d77521fc826f70044031e82788cadeb5c4e 100644 (file)
/// always visits SCCs for a callee prior to visiting the SCC for a caller
/// (when they are in different SCCs).
class postorder_scc_iterator
- : public std::iterator<std::forward_iterator_tag, SCC *, ptrdiff_t, SCC *,
- SCC *> {
+ : public std::iterator<std::forward_iterator_tag, SCC> {
friend class LazyCallGraph;
friend class LazyCallGraph::Node;
return !operator==(Arg);
}
- reference operator*() const { return C; }
- pointer operator->() const { return operator*(); }
+ reference operator*() const { return *C; }
+ pointer operator->() const { return &operator*(); }
postorder_scc_iterator &operator++() {
C = G->getNextSCCInPostOrder();
index 2da67227c3e1088bad7a00d798a8ea241ff02773..db6aed3b7a574ae7082b9b26a965eb8d70f1d810 100644 (file)
if (Printed.insert(&N))
printNodes(OS, N, Printed);
- for (LazyCallGraph::SCC *SCC : G.postorder_sccs())
- printSCC(OS, *SCC);
+ for (LazyCallGraph::SCC &SCC : G.postorder_sccs())
+ printSCC(OS, SCC);
return PreservedAnalyses::all();
index ff6919091c844c93ba0493bde7dc0ed695c44e64..22a95563fb4eeb94abdcdf91b232b8ae79bf4b52 100644 (file)
// Now lets look at the SCCs.
auto SCCI = CG.postorder_scc_begin();
- LazyCallGraph::SCC *D = *SCCI++;
- for (LazyCallGraph::Node *N : *D)
+ LazyCallGraph::SCC &D = *SCCI++;
+ for (LazyCallGraph::Node *N : D)
Nodes.push_back(N->getFunction().getName());
std::sort(Nodes.begin(), Nodes.end());
EXPECT_EQ("d1", Nodes[0]);
EXPECT_EQ(3u, Nodes.size());
Nodes.clear();
- LazyCallGraph::SCC *C = *SCCI++;
- for (LazyCallGraph::Node *N : *C)
+ LazyCallGraph::SCC &C = *SCCI++;
+ for (LazyCallGraph::Node *N : C)
Nodes.push_back(N->getFunction().getName());
std::sort(Nodes.begin(), Nodes.end());
EXPECT_EQ("c1", Nodes[0]);
EXPECT_EQ(3u, Nodes.size());
Nodes.clear();
- LazyCallGraph::SCC *B = *SCCI++;
- for (LazyCallGraph::Node *N : *B)
+ LazyCallGraph::SCC &B = *SCCI++;
+ for (LazyCallGraph::Node *N : B)
Nodes.push_back(N->getFunction().getName());
std::sort(Nodes.begin(), Nodes.end());
EXPECT_EQ("b1", Nodes[0]);
EXPECT_EQ(3u, Nodes.size());
Nodes.clear();
- LazyCallGraph::SCC *A = *SCCI++;
- for (LazyCallGraph::Node *N : *A)
+ LazyCallGraph::SCC &A = *SCCI++;
+ for (LazyCallGraph::Node *N : A)
Nodes.push_back(N->getFunction().getName());
std::sort(Nodes.begin(), Nodes.end());
EXPECT_EQ("a1", Nodes[0]);
// Force the graph to be fully expanded.
auto SCCI = CG.postorder_scc_begin();
- LazyCallGraph::SCC *SCC = *SCCI++;
+ LazyCallGraph::SCC &SCC = *SCCI++;
EXPECT_EQ(CG.postorder_scc_end(), SCCI);
LazyCallGraph::Node &A = *CG.lookup(lookupFunction(*M, "a"));
LazyCallGraph::Node &C = *CG.lookup(lookupFunction(*M, "c"));
LazyCallGraph::Node &D = *CG.lookup(lookupFunction(*M, "d"));
LazyCallGraph::Node &E = *CG.lookup(lookupFunction(*M, "e"));
- EXPECT_EQ(SCC, CG.lookupSCC(A));
- EXPECT_EQ(SCC, CG.lookupSCC(B));
- EXPECT_EQ(SCC, CG.lookupSCC(C));
- EXPECT_EQ(SCC, CG.lookupSCC(D));
- EXPECT_EQ(SCC, CG.lookupSCC(E));
+ EXPECT_EQ(&SCC, CG.lookupSCC(A));
+ EXPECT_EQ(&SCC, CG.lookupSCC(B));
+ EXPECT_EQ(&SCC, CG.lookupSCC(C));
+ EXPECT_EQ(&SCC, CG.lookupSCC(D));
+ EXPECT_EQ(&SCC, CG.lookupSCC(E));
}
TEST(LazyCallGraphTest, InterSCCEdgeRemoval) {
LazyCallGraph CG(*M);
// Force the graph to be fully expanded.
- for (LazyCallGraph::SCC *C : CG.postorder_sccs())
+ for (LazyCallGraph::SCC &C : CG.postorder_sccs())
(void)C;
LazyCallGraph::Node &A = *CG.lookup(lookupFunction(*M, "a"));
// Force the graph to be fully expanded.
auto SCCI = CG1.postorder_scc_begin();
- LazyCallGraph::SCC *SCC = *SCCI++;
+ LazyCallGraph::SCC &SCC = *SCCI++;
EXPECT_EQ(CG1.postorder_scc_end(), SCCI);
LazyCallGraph::Node &A = *CG1.lookup(lookupFunction(*M1, "a"));
LazyCallGraph::Node &B = *CG1.lookup(lookupFunction(*M1, "b"));
LazyCallGraph::Node &C = *CG1.lookup(lookupFunction(*M1, "c"));
- EXPECT_EQ(SCC, CG1.lookupSCC(A));
- EXPECT_EQ(SCC, CG1.lookupSCC(B));
- EXPECT_EQ(SCC, CG1.lookupSCC(C));
+ EXPECT_EQ(&SCC, CG1.lookupSCC(A));
+ EXPECT_EQ(&SCC, CG1.lookupSCC(B));
+ EXPECT_EQ(&SCC, CG1.lookupSCC(C));
// Remove the edge from b -> a, which should leave the 3 functions still in
// a single connected component because of a -> b -> c -> a.
CG1.removeEdge(B, A.getFunction());
- EXPECT_EQ(SCC, CG1.lookupSCC(A));
- EXPECT_EQ(SCC, CG1.lookupSCC(B));
- EXPECT_EQ(SCC, CG1.lookupSCC(C));
+ EXPECT_EQ(&SCC, CG1.lookupSCC(A));
+ EXPECT_EQ(&SCC, CG1.lookupSCC(B));
+ EXPECT_EQ(&SCC, CG1.lookupSCC(C));
// Remove the edge from c -> a, which should leave 'a' in the original SCC
// and form a new SCC for 'b' and 'c'.
CG1.removeEdge(C, A.getFunction());
- EXPECT_EQ(SCC, CG1.lookupSCC(A));
- EXPECT_EQ(1, std::distance(SCC->begin(), SCC->end()));
+ EXPECT_EQ(&SCC, CG1.lookupSCC(A));
+ EXPECT_EQ(1, std::distance(SCC.begin(), SCC.end()));
LazyCallGraph::SCC *SCC2 = CG1.lookupSCC(B);
EXPECT_EQ(SCC2, CG1.lookupSCC(C));
}