mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-02-28 09:31:03 +00:00
[LCG] Make the return of the IntraSCC removal method actually match its
contract (and be much more useful). It now provides exactly the post-order traversal a caller might need to perform on newly formed SCCs. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@207410 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
55eab086e3
commit
e52aad4202
@ -284,10 +284,8 @@ LazyCallGraph::SCC::removeIntraSCCEdge(Node &CallerN,
|
|||||||
// First remove it from the node.
|
// First remove it from the node.
|
||||||
CallerN.removeEdgeInternal(CalleeN.getFunction());
|
CallerN.removeEdgeInternal(CalleeN.getFunction());
|
||||||
|
|
||||||
// We return a list of the resulting SCCs, where 'this' is always the first
|
// We return a list of the resulting *new* SCCs in postorder.
|
||||||
// element.
|
|
||||||
SmallVector<SCC *, 1> ResultSCCs;
|
SmallVector<SCC *, 1> ResultSCCs;
|
||||||
ResultSCCs.push_back(this);
|
|
||||||
|
|
||||||
// Direct recursion doesn't impact the SCC graph at all.
|
// Direct recursion doesn't impact the SCC graph at all.
|
||||||
if (&CallerN == &CalleeN)
|
if (&CallerN == &CalleeN)
|
||||||
@ -337,7 +335,7 @@ LazyCallGraph::SCC::removeIntraSCCEdge(Node &CallerN,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
#ifndef NDEBUG
|
#ifndef NDEBUG
|
||||||
if (ResultSCCs.size() > 1)
|
if (!ResultSCCs.empty())
|
||||||
assert(!IsLeafSCC && "This SCC cannot be a leaf as we have split out new "
|
assert(!IsLeafSCC && "This SCC cannot be a leaf as we have split out new "
|
||||||
"SCCs by removing this edge.");
|
"SCCs by removing this edge.");
|
||||||
if (!std::any_of(G->LeafSCCs.begin(), G->LeafSCCs.end(),
|
if (!std::any_of(G->LeafSCCs.begin(), G->LeafSCCs.end(),
|
||||||
@ -347,7 +345,7 @@ LazyCallGraph::SCC::removeIntraSCCEdge(Node &CallerN,
|
|||||||
#endif
|
#endif
|
||||||
// If this SCC stopped being a leaf through this edge removal, remove it from
|
// If this SCC stopped being a leaf through this edge removal, remove it from
|
||||||
// the leaf SCC list.
|
// the leaf SCC list.
|
||||||
if (!IsLeafSCC && ResultSCCs.size() > 1)
|
if (!IsLeafSCC && !ResultSCCs.empty())
|
||||||
G->LeafSCCs.erase(std::remove(G->LeafSCCs.begin(), G->LeafSCCs.end(), this),
|
G->LeafSCCs.erase(std::remove(G->LeafSCCs.begin(), G->LeafSCCs.end(), this),
|
||||||
G->LeafSCCs.end());
|
G->LeafSCCs.end());
|
||||||
|
|
||||||
|
@ -378,18 +378,21 @@ TEST(LazyCallGraphTest, IntraSCCEdgeRemoval) {
|
|||||||
|
|
||||||
// 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.
|
||||||
SCC.removeIntraSCCEdge(B, A);
|
SmallVector<LazyCallGraph::SCC *, 1> NewSCCs = SCC.removeIntraSCCEdge(B, A);
|
||||||
|
EXPECT_EQ(0u, NewSCCs.size());
|
||||||
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'.
|
||||||
SCC.removeIntraSCCEdge(C, A);
|
NewSCCs = SCC.removeIntraSCCEdge(C, A);
|
||||||
|
EXPECT_EQ(1u, NewSCCs.size());
|
||||||
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));
|
||||||
|
EXPECT_EQ(SCC2, NewSCCs[0]);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user