[LCG] Add the really, *really* boring edge insertion case: adding an

edge entirely within an existing SCC. Shockingly, making the connected
component more connected is ... a total snooze fest. =]

Anyways, its wired up, and I even added a test case to make sure it
pretty much sorta works. =D

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@207631 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Chandler Carruth
2014-04-30 10:48:36 +00:00
parent 0a78097774
commit 491f476b8b
3 changed files with 74 additions and 4 deletions

View File

@@ -386,6 +386,52 @@ TEST(LazyCallGraphTest, InterSCCEdgeRemoval) {
EXPECT_EQ(BC.parent_end(), BC.parent_begin());
}
TEST(LazyCallGraphTest, IntraSCCEdgeInsertion) {
std::unique_ptr<Module> M1 = parseAssembly(
"define void @a() {\n"
"entry:\n"
" call void @b()\n"
" ret void\n"
"}\n"
"define void @b() {\n"
"entry:\n"
" call void @c()\n"
" ret void\n"
"}\n"
"define void @c() {\n"
"entry:\n"
" call void @a()\n"
" ret void\n"
"}\n");
LazyCallGraph CG1(*M1);
// Force the graph to be fully expanded.
auto SCCI = CG1.postorder_scc_begin();
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));
// Insert an edge from 'a' to 'c'. Nothing changes about the SCCs.
SCC.insertIntraSCCEdge(A, C);
EXPECT_EQ(2, std::distance(A.begin(), A.end()));
EXPECT_EQ(&SCC, CG1.lookupSCC(A));
EXPECT_EQ(&SCC, CG1.lookupSCC(B));
EXPECT_EQ(&SCC, CG1.lookupSCC(C));
// Insert a self edge from 'a' back to 'a'.
SCC.insertIntraSCCEdge(A, A);
EXPECT_EQ(3, std::distance(A.begin(), A.end()));
EXPECT_EQ(&SCC, CG1.lookupSCC(A));
EXPECT_EQ(&SCC, CG1.lookupSCC(B));
EXPECT_EQ(&SCC, CG1.lookupSCC(C));
}
TEST(LazyCallGraphTest, IntraSCCEdgeRemoval) {
// A nice fully connected (including self-edges) SCC.
std::unique_ptr<Module> M1 = parseAssembly(