summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/llvm/Analysis/CGSCCPassManager.h6
-rw-r--r--include/llvm/Analysis/LazyCallGraph.h7
-rw-r--r--lib/Analysis/LazyCallGraph.cpp4
-rw-r--r--unittests/Analysis/LazyCallGraphTest.cpp48
4 files changed, 32 insertions, 33 deletions
diff --git a/include/llvm/Analysis/CGSCCPassManager.h b/include/llvm/Analysis/CGSCCPassManager.h
index 618fee153c..09101ae6d0 100644
--- a/include/llvm/Analysis/CGSCCPassManager.h
+++ b/include/llvm/Analysis/CGSCCPassManager.h
@@ -334,8 +334,8 @@ public:
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
@@ -343,7 +343,7 @@ public:
// 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.
diff --git a/include/llvm/Analysis/LazyCallGraph.h b/include/llvm/Analysis/LazyCallGraph.h
index d0de2aab10..039b8d7752 100644
--- a/include/llvm/Analysis/LazyCallGraph.h
+++ b/include/llvm/Analysis/LazyCallGraph.h
@@ -248,8 +248,7 @@ public:
/// 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;
@@ -276,8 +275,8 @@ public:
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();
diff --git a/lib/Analysis/LazyCallGraph.cpp b/lib/Analysis/LazyCallGraph.cpp
index 2da67227c3..db6aed3b7a 100644
--- a/lib/Analysis/LazyCallGraph.cpp
+++ b/lib/Analysis/LazyCallGraph.cpp
@@ -518,8 +518,8 @@ PreservedAnalyses LazyCallGraphPrinterPass::run(Module *M,
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();
diff --git a/unittests/Analysis/LazyCallGraphTest.cpp b/unittests/Analysis/LazyCallGraphTest.cpp
index ff6919091c..22a95563fb 100644
--- a/unittests/Analysis/LazyCallGraphTest.cpp
+++ b/unittests/Analysis/LazyCallGraphTest.cpp
@@ -205,8 +205,8 @@ TEST(LazyCallGraphTest, BasicGraphFormation) {
// 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]);
@@ -215,8 +215,8 @@ TEST(LazyCallGraphTest, BasicGraphFormation) {
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]);
@@ -225,8 +225,8 @@ TEST(LazyCallGraphTest, BasicGraphFormation) {
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]);
@@ -235,8 +235,8 @@ TEST(LazyCallGraphTest, BasicGraphFormation) {
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]);
@@ -290,7 +290,7 @@ TEST(LazyCallGraphTest, MultiArmSCC) {
// 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"));
@@ -298,11 +298,11 @@ TEST(LazyCallGraphTest, MultiArmSCC) {
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) {
@@ -319,7 +319,7 @@ 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"));
@@ -366,28 +366,28 @@ TEST(LazyCallGraphTest, IntraSCCEdgeRemoval) {
// 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));
}