mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2025-01-31 12:41:49 +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);
|
||||
|
||||
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.
|
||||
|
@ -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();
|
||||
|
@ -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();
|
||||
|
||||
|
@ -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));
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user