mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2025-01-31 20:51:52 +01:00
[LCG] Normalize the post-order SCC iterator to just iterate over the SCC
values rather than having pointers in weird places. llvm-svn: 207053
This commit is contained in:
parent
1729fb332d
commit
a18f590cc4
@ -334,8 +334,8 @@ public:
|
|||||||
LazyCallGraph &CG = AM->getResult<LazyCallGraphAnalysis>(M);
|
LazyCallGraph &CG = AM->getResult<LazyCallGraphAnalysis>(M);
|
||||||
|
|
||||||
PreservedAnalyses PA = PreservedAnalyses::all();
|
PreservedAnalyses PA = PreservedAnalyses::all();
|
||||||
for (LazyCallGraph::SCC *C : CG.postorder_sccs()) {
|
for (LazyCallGraph::SCC &C : CG.postorder_sccs()) {
|
||||||
PreservedAnalyses PassPA = Pass.run(C, &CGAM);
|
PreservedAnalyses PassPA = Pass.run(&C, &CGAM);
|
||||||
|
|
||||||
// We know that the CGSCC pass couldn't have invalidated any other
|
// We know that the CGSCC pass couldn't have invalidated any other
|
||||||
// SCC's analyses (that's the contract of a CGSCC pass), so
|
// 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
|
// 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
|
// pass updated the CG, particularly some child of the current SCC, and
|
||||||
// invalidate its analyses.
|
// invalidate its analyses.
|
||||||
CGAM.invalidate(C, PassPA);
|
CGAM.invalidate(&C, PassPA);
|
||||||
|
|
||||||
// Then intersect the preserved set so that invalidation of module
|
// Then intersect the preserved set so that invalidation of module
|
||||||
// analyses will eventually occur when the module pass completes.
|
// analyses will eventually occur when the module pass completes.
|
||||||
|
@ -248,8 +248,7 @@ public:
|
|||||||
/// always visits SCCs for a callee prior to visiting the SCC for a caller
|
/// always visits SCCs for a callee prior to visiting the SCC for a caller
|
||||||
/// (when they are in different SCCs).
|
/// (when they are in different SCCs).
|
||||||
class postorder_scc_iterator
|
class postorder_scc_iterator
|
||||||
: public std::iterator<std::forward_iterator_tag, SCC *, ptrdiff_t, SCC *,
|
: public std::iterator<std::forward_iterator_tag, SCC> {
|
||||||
SCC *> {
|
|
||||||
friend class LazyCallGraph;
|
friend class LazyCallGraph;
|
||||||
friend class LazyCallGraph::Node;
|
friend class LazyCallGraph::Node;
|
||||||
|
|
||||||
@ -276,8 +275,8 @@ public:
|
|||||||
return !operator==(Arg);
|
return !operator==(Arg);
|
||||||
}
|
}
|
||||||
|
|
||||||
reference operator*() const { return C; }
|
reference operator*() const { return *C; }
|
||||||
pointer operator->() const { return operator*(); }
|
pointer operator->() const { return &operator*(); }
|
||||||
|
|
||||||
postorder_scc_iterator &operator++() {
|
postorder_scc_iterator &operator++() {
|
||||||
C = G->getNextSCCInPostOrder();
|
C = G->getNextSCCInPostOrder();
|
||||||
|
@ -518,8 +518,8 @@ PreservedAnalyses LazyCallGraphPrinterPass::run(Module *M,
|
|||||||
if (Printed.insert(&N))
|
if (Printed.insert(&N))
|
||||||
printNodes(OS, N, Printed);
|
printNodes(OS, N, Printed);
|
||||||
|
|
||||||
for (LazyCallGraph::SCC *SCC : G.postorder_sccs())
|
for (LazyCallGraph::SCC &SCC : G.postorder_sccs())
|
||||||
printSCC(OS, *SCC);
|
printSCC(OS, SCC);
|
||||||
|
|
||||||
return PreservedAnalyses::all();
|
return PreservedAnalyses::all();
|
||||||
|
|
||||||
|
@ -205,8 +205,8 @@ TEST(LazyCallGraphTest, BasicGraphFormation) {
|
|||||||
// Now lets look at the SCCs.
|
// Now lets look at the SCCs.
|
||||||
auto SCCI = CG.postorder_scc_begin();
|
auto SCCI = CG.postorder_scc_begin();
|
||||||
|
|
||||||
LazyCallGraph::SCC *D = *SCCI++;
|
LazyCallGraph::SCC &D = *SCCI++;
|
||||||
for (LazyCallGraph::Node *N : *D)
|
for (LazyCallGraph::Node *N : D)
|
||||||
Nodes.push_back(N->getFunction().getName());
|
Nodes.push_back(N->getFunction().getName());
|
||||||
std::sort(Nodes.begin(), Nodes.end());
|
std::sort(Nodes.begin(), Nodes.end());
|
||||||
EXPECT_EQ("d1", Nodes[0]);
|
EXPECT_EQ("d1", Nodes[0]);
|
||||||
@ -215,8 +215,8 @@ TEST(LazyCallGraphTest, BasicGraphFormation) {
|
|||||||
EXPECT_EQ(3u, Nodes.size());
|
EXPECT_EQ(3u, Nodes.size());
|
||||||
Nodes.clear();
|
Nodes.clear();
|
||||||
|
|
||||||
LazyCallGraph::SCC *C = *SCCI++;
|
LazyCallGraph::SCC &C = *SCCI++;
|
||||||
for (LazyCallGraph::Node *N : *C)
|
for (LazyCallGraph::Node *N : C)
|
||||||
Nodes.push_back(N->getFunction().getName());
|
Nodes.push_back(N->getFunction().getName());
|
||||||
std::sort(Nodes.begin(), Nodes.end());
|
std::sort(Nodes.begin(), Nodes.end());
|
||||||
EXPECT_EQ("c1", Nodes[0]);
|
EXPECT_EQ("c1", Nodes[0]);
|
||||||
@ -225,8 +225,8 @@ TEST(LazyCallGraphTest, BasicGraphFormation) {
|
|||||||
EXPECT_EQ(3u, Nodes.size());
|
EXPECT_EQ(3u, Nodes.size());
|
||||||
Nodes.clear();
|
Nodes.clear();
|
||||||
|
|
||||||
LazyCallGraph::SCC *B = *SCCI++;
|
LazyCallGraph::SCC &B = *SCCI++;
|
||||||
for (LazyCallGraph::Node *N : *B)
|
for (LazyCallGraph::Node *N : B)
|
||||||
Nodes.push_back(N->getFunction().getName());
|
Nodes.push_back(N->getFunction().getName());
|
||||||
std::sort(Nodes.begin(), Nodes.end());
|
std::sort(Nodes.begin(), Nodes.end());
|
||||||
EXPECT_EQ("b1", Nodes[0]);
|
EXPECT_EQ("b1", Nodes[0]);
|
||||||
@ -235,8 +235,8 @@ TEST(LazyCallGraphTest, BasicGraphFormation) {
|
|||||||
EXPECT_EQ(3u, Nodes.size());
|
EXPECT_EQ(3u, Nodes.size());
|
||||||
Nodes.clear();
|
Nodes.clear();
|
||||||
|
|
||||||
LazyCallGraph::SCC *A = *SCCI++;
|
LazyCallGraph::SCC &A = *SCCI++;
|
||||||
for (LazyCallGraph::Node *N : *A)
|
for (LazyCallGraph::Node *N : A)
|
||||||
Nodes.push_back(N->getFunction().getName());
|
Nodes.push_back(N->getFunction().getName());
|
||||||
std::sort(Nodes.begin(), Nodes.end());
|
std::sort(Nodes.begin(), Nodes.end());
|
||||||
EXPECT_EQ("a1", Nodes[0]);
|
EXPECT_EQ("a1", Nodes[0]);
|
||||||
@ -290,7 +290,7 @@ TEST(LazyCallGraphTest, MultiArmSCC) {
|
|||||||
|
|
||||||
// Force the graph to be fully expanded.
|
// Force the graph to be fully expanded.
|
||||||
auto SCCI = CG.postorder_scc_begin();
|
auto SCCI = CG.postorder_scc_begin();
|
||||||
LazyCallGraph::SCC *SCC = *SCCI++;
|
LazyCallGraph::SCC &SCC = *SCCI++;
|
||||||
EXPECT_EQ(CG.postorder_scc_end(), SCCI);
|
EXPECT_EQ(CG.postorder_scc_end(), SCCI);
|
||||||
|
|
||||||
LazyCallGraph::Node &A = *CG.lookup(lookupFunction(*M, "a"));
|
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 &C = *CG.lookup(lookupFunction(*M, "c"));
|
||||||
LazyCallGraph::Node &D = *CG.lookup(lookupFunction(*M, "d"));
|
LazyCallGraph::Node &D = *CG.lookup(lookupFunction(*M, "d"));
|
||||||
LazyCallGraph::Node &E = *CG.lookup(lookupFunction(*M, "e"));
|
LazyCallGraph::Node &E = *CG.lookup(lookupFunction(*M, "e"));
|
||||||
EXPECT_EQ(SCC, CG.lookupSCC(A));
|
EXPECT_EQ(&SCC, CG.lookupSCC(A));
|
||||||
EXPECT_EQ(SCC, CG.lookupSCC(B));
|
EXPECT_EQ(&SCC, CG.lookupSCC(B));
|
||||||
EXPECT_EQ(SCC, CG.lookupSCC(C));
|
EXPECT_EQ(&SCC, CG.lookupSCC(C));
|
||||||
EXPECT_EQ(SCC, CG.lookupSCC(D));
|
EXPECT_EQ(&SCC, CG.lookupSCC(D));
|
||||||
EXPECT_EQ(SCC, CG.lookupSCC(E));
|
EXPECT_EQ(&SCC, CG.lookupSCC(E));
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(LazyCallGraphTest, InterSCCEdgeRemoval) {
|
TEST(LazyCallGraphTest, InterSCCEdgeRemoval) {
|
||||||
@ -319,7 +319,7 @@ TEST(LazyCallGraphTest, InterSCCEdgeRemoval) {
|
|||||||
LazyCallGraph CG(*M);
|
LazyCallGraph CG(*M);
|
||||||
|
|
||||||
// Force the graph to be fully expanded.
|
// Force the graph to be fully expanded.
|
||||||
for (LazyCallGraph::SCC *C : CG.postorder_sccs())
|
for (LazyCallGraph::SCC &C : CG.postorder_sccs())
|
||||||
(void)C;
|
(void)C;
|
||||||
|
|
||||||
LazyCallGraph::Node &A = *CG.lookup(lookupFunction(*M, "a"));
|
LazyCallGraph::Node &A = *CG.lookup(lookupFunction(*M, "a"));
|
||||||
@ -366,28 +366,28 @@ TEST(LazyCallGraphTest, IntraSCCEdgeRemoval) {
|
|||||||
|
|
||||||
// Force the graph to be fully expanded.
|
// Force the graph to be fully expanded.
|
||||||
auto SCCI = CG1.postorder_scc_begin();
|
auto SCCI = CG1.postorder_scc_begin();
|
||||||
LazyCallGraph::SCC *SCC = *SCCI++;
|
LazyCallGraph::SCC &SCC = *SCCI++;
|
||||||
EXPECT_EQ(CG1.postorder_scc_end(), SCCI);
|
EXPECT_EQ(CG1.postorder_scc_end(), SCCI);
|
||||||
|
|
||||||
LazyCallGraph::Node &A = *CG1.lookup(lookupFunction(*M1, "a"));
|
LazyCallGraph::Node &A = *CG1.lookup(lookupFunction(*M1, "a"));
|
||||||
LazyCallGraph::Node &B = *CG1.lookup(lookupFunction(*M1, "b"));
|
LazyCallGraph::Node &B = *CG1.lookup(lookupFunction(*M1, "b"));
|
||||||
LazyCallGraph::Node &C = *CG1.lookup(lookupFunction(*M1, "c"));
|
LazyCallGraph::Node &C = *CG1.lookup(lookupFunction(*M1, "c"));
|
||||||
EXPECT_EQ(SCC, CG1.lookupSCC(A));
|
EXPECT_EQ(&SCC, CG1.lookupSCC(A));
|
||||||
EXPECT_EQ(SCC, CG1.lookupSCC(B));
|
EXPECT_EQ(&SCC, CG1.lookupSCC(B));
|
||||||
EXPECT_EQ(SCC, CG1.lookupSCC(C));
|
EXPECT_EQ(&SCC, CG1.lookupSCC(C));
|
||||||
|
|
||||||
// Remove the edge from b -> a, which should leave the 3 functions still in
|
// Remove the edge from b -> a, which should leave the 3 functions still in
|
||||||
// a single connected component because of a -> b -> c -> a.
|
// a single connected component because of a -> b -> c -> a.
|
||||||
CG1.removeEdge(B, A.getFunction());
|
CG1.removeEdge(B, A.getFunction());
|
||||||
EXPECT_EQ(SCC, CG1.lookupSCC(A));
|
EXPECT_EQ(&SCC, CG1.lookupSCC(A));
|
||||||
EXPECT_EQ(SCC, CG1.lookupSCC(B));
|
EXPECT_EQ(&SCC, CG1.lookupSCC(B));
|
||||||
EXPECT_EQ(SCC, CG1.lookupSCC(C));
|
EXPECT_EQ(&SCC, CG1.lookupSCC(C));
|
||||||
|
|
||||||
// Remove the edge from c -> a, which should leave 'a' in the original SCC
|
// Remove the edge from c -> a, which should leave 'a' in the original SCC
|
||||||
// and form a new SCC for 'b' and 'c'.
|
// and form a new SCC for 'b' and 'c'.
|
||||||
CG1.removeEdge(C, A.getFunction());
|
CG1.removeEdge(C, A.getFunction());
|
||||||
EXPECT_EQ(SCC, CG1.lookupSCC(A));
|
EXPECT_EQ(&SCC, CG1.lookupSCC(A));
|
||||||
EXPECT_EQ(1, std::distance(SCC->begin(), SCC->end()));
|
EXPECT_EQ(1, std::distance(SCC.begin(), SCC.end()));
|
||||||
LazyCallGraph::SCC *SCC2 = CG1.lookupSCC(B);
|
LazyCallGraph::SCC *SCC2 = CG1.lookupSCC(B);
|
||||||
EXPECT_EQ(SCC2, CG1.lookupSCC(C));
|
EXPECT_EQ(SCC2, CG1.lookupSCC(C));
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user