diff options
author | Chandler Carruth <chandlerc@gmail.com> | 2016-11-22 20:35:32 +0000 |
---|---|---|
committer | Chandler Carruth <chandlerc@gmail.com> | 2016-11-22 20:35:32 +0000 |
commit | f8c09d63b01a3f7011fcabc7a05c20286383df25 (patch) | |
tree | 89ff9e8a2411c5c1946d2174f83105e6715e36d8 /llvm/unittests/Analysis/LazyCallGraphTest.cpp | |
parent | 2b4ba04d57b35d638e15d71ec6d1e8622e1ea49a (diff) | |
download | llvm-f8c09d63b01a3f7011fcabc7a05c20286383df25.zip llvm-f8c09d63b01a3f7011fcabc7a05c20286383df25.tar.gz llvm-f8c09d63b01a3f7011fcabc7a05c20286383df25.tar.bz2 |
[LCG] Start using SCC relationship predicates in the unittest.
This mostly gives us nice unittesting of the predicates themselves. I'll
start using them further in subsequent commits to help test the actual
operations performed on the graph.
llvm-svn: 287698
Diffstat (limited to 'llvm/unittests/Analysis/LazyCallGraphTest.cpp')
-rw-r--r-- | llvm/unittests/Analysis/LazyCallGraphTest.cpp | 28 |
1 files changed, 26 insertions, 2 deletions
diff --git a/llvm/unittests/Analysis/LazyCallGraphTest.cpp b/llvm/unittests/Analysis/LazyCallGraphTest.cpp index 66cd9a1..d302251 100644 --- a/llvm/unittests/Analysis/LazyCallGraphTest.cpp +++ b/llvm/unittests/Analysis/LazyCallGraphTest.cpp @@ -594,13 +594,21 @@ TEST(LazyCallGraphTest, OutgoingEdgeMutation) { LazyCallGraph::RefSCC &CRC = *CG.lookupRefSCC(C); LazyCallGraph::RefSCC &DRC = *CG.lookupRefSCC(D); EXPECT_TRUE(ARC.isParentOf(BRC)); + EXPECT_TRUE(AC.isParentOf(BC)); EXPECT_TRUE(ARC.isParentOf(CRC)); + EXPECT_TRUE(AC.isParentOf(CC)); EXPECT_FALSE(ARC.isParentOf(DRC)); + EXPECT_FALSE(AC.isParentOf(DC)); EXPECT_TRUE(ARC.isAncestorOf(DRC)); + EXPECT_TRUE(AC.isAncestorOf(DC)); EXPECT_FALSE(DRC.isChildOf(ARC)); + EXPECT_FALSE(DC.isChildOf(AC)); EXPECT_TRUE(DRC.isDescendantOf(ARC)); + EXPECT_TRUE(DC.isDescendantOf(AC)); EXPECT_TRUE(DRC.isChildOf(BRC)); + EXPECT_TRUE(DC.isChildOf(BC)); EXPECT_TRUE(DRC.isChildOf(CRC)); + EXPECT_TRUE(DC.isChildOf(CC)); EXPECT_EQ(2, std::distance(A.begin(), A.end())); ARC.insertOutgoingEdge(A, D, LazyCallGraph::Edge::Call); @@ -613,9 +621,13 @@ TEST(LazyCallGraphTest, OutgoingEdgeMutation) { // Only the parent and child tests sholud have changed. The rest of the graph // remains the same. EXPECT_TRUE(ARC.isParentOf(DRC)); + EXPECT_TRUE(AC.isParentOf(DC)); EXPECT_TRUE(ARC.isAncestorOf(DRC)); + EXPECT_TRUE(AC.isAncestorOf(DC)); EXPECT_TRUE(DRC.isChildOf(ARC)); + EXPECT_TRUE(DC.isChildOf(AC)); EXPECT_TRUE(DRC.isDescendantOf(ARC)); + EXPECT_TRUE(DC.isDescendantOf(AC)); EXPECT_EQ(&AC, CG.lookupSCC(A)); EXPECT_EQ(&BC, CG.lookupSCC(B)); EXPECT_EQ(&CC, CG.lookupSCC(C)); @@ -628,11 +640,15 @@ TEST(LazyCallGraphTest, OutgoingEdgeMutation) { ARC.switchOutgoingEdgeToRef(A, D); EXPECT_FALSE(NewE.isCall()); - // Verify the graph remains the same. + // Verify the reference graph remains the same but the SCC graph is updated. EXPECT_TRUE(ARC.isParentOf(DRC)); + EXPECT_FALSE(AC.isParentOf(DC)); EXPECT_TRUE(ARC.isAncestorOf(DRC)); + EXPECT_TRUE(AC.isAncestorOf(DC)); EXPECT_TRUE(DRC.isChildOf(ARC)); + EXPECT_FALSE(DC.isChildOf(AC)); EXPECT_TRUE(DRC.isDescendantOf(ARC)); + EXPECT_TRUE(DC.isDescendantOf(AC)); EXPECT_EQ(&AC, CG.lookupSCC(A)); EXPECT_EQ(&BC, CG.lookupSCC(B)); EXPECT_EQ(&CC, CG.lookupSCC(C)); @@ -645,11 +661,15 @@ TEST(LazyCallGraphTest, OutgoingEdgeMutation) { ARC.switchOutgoingEdgeToCall(A, D); EXPECT_TRUE(NewE.isCall()); - // Verify the graph remains the same. + // Verify the reference graph remains the same but the SCC graph is updated. EXPECT_TRUE(ARC.isParentOf(DRC)); + EXPECT_TRUE(AC.isParentOf(DC)); EXPECT_TRUE(ARC.isAncestorOf(DRC)); + EXPECT_TRUE(AC.isAncestorOf(DC)); EXPECT_TRUE(DRC.isChildOf(ARC)); + EXPECT_TRUE(DC.isChildOf(AC)); EXPECT_TRUE(DRC.isDescendantOf(ARC)); + EXPECT_TRUE(DC.isDescendantOf(AC)); EXPECT_EQ(&AC, CG.lookupSCC(A)); EXPECT_EQ(&BC, CG.lookupSCC(B)); EXPECT_EQ(&CC, CG.lookupSCC(C)); @@ -664,9 +684,13 @@ TEST(LazyCallGraphTest, OutgoingEdgeMutation) { // Now the parent and child tests fail again but the rest remains the same. EXPECT_FALSE(ARC.isParentOf(DRC)); + EXPECT_FALSE(AC.isParentOf(DC)); EXPECT_TRUE(ARC.isAncestorOf(DRC)); + EXPECT_TRUE(AC.isAncestorOf(DC)); EXPECT_FALSE(DRC.isChildOf(ARC)); + EXPECT_FALSE(DC.isChildOf(AC)); EXPECT_TRUE(DRC.isDescendantOf(ARC)); + EXPECT_TRUE(DC.isDescendantOf(AC)); EXPECT_EQ(&AC, CG.lookupSCC(A)); EXPECT_EQ(&BC, CG.lookupSCC(B)); EXPECT_EQ(&CC, CG.lookupSCC(C)); |