llvm.org GIT mirror llvm / 62cfc59
[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. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@287698 91177308-0d34-0410-b5e6-96231b3b80d8 Chandler Carruth 2 years ago
1 changed file(s) with 26 addition(s) and 2 deletion(s). Raw diff Collapse all Expand all
593593 LazyCallGraph::RefSCC &CRC = *CG.lookupRefSCC(C);
594594 LazyCallGraph::RefSCC &DRC = *CG.lookupRefSCC(D);
595595 EXPECT_TRUE(ARC.isParentOf(BRC));
596 EXPECT_TRUE(AC.isParentOf(BC));
596597 EXPECT_TRUE(ARC.isParentOf(CRC));
598 EXPECT_TRUE(AC.isParentOf(CC));
597599 EXPECT_FALSE(ARC.isParentOf(DRC));
600 EXPECT_FALSE(AC.isParentOf(DC));
598601 EXPECT_TRUE(ARC.isAncestorOf(DRC));
602 EXPECT_TRUE(AC.isAncestorOf(DC));
599603 EXPECT_FALSE(DRC.isChildOf(ARC));
604 EXPECT_FALSE(DC.isChildOf(AC));
600605 EXPECT_TRUE(DRC.isDescendantOf(ARC));
606 EXPECT_TRUE(DC.isDescendantOf(AC));
601607 EXPECT_TRUE(DRC.isChildOf(BRC));
608 EXPECT_TRUE(DC.isChildOf(BC));
602609 EXPECT_TRUE(DRC.isChildOf(CRC));
610 EXPECT_TRUE(DC.isChildOf(CC));
603611
604612 EXPECT_EQ(2, std::distance(A.begin(), A.end()));
605613 ARC.insertOutgoingEdge(A, D, LazyCallGraph::Edge::Call);
612620 // Only the parent and child tests sholud have changed. The rest of the graph
613621 // remains the same.
614622 EXPECT_TRUE(ARC.isParentOf(DRC));
623 EXPECT_TRUE(AC.isParentOf(DC));
615624 EXPECT_TRUE(ARC.isAncestorOf(DRC));
625 EXPECT_TRUE(AC.isAncestorOf(DC));
616626 EXPECT_TRUE(DRC.isChildOf(ARC));
627 EXPECT_TRUE(DC.isChildOf(AC));
617628 EXPECT_TRUE(DRC.isDescendantOf(ARC));
629 EXPECT_TRUE(DC.isDescendantOf(AC));
618630 EXPECT_EQ(&AC, CG.lookupSCC(A));
619631 EXPECT_EQ(&BC, CG.lookupSCC(B));
620632 EXPECT_EQ(&CC, CG.lookupSCC(C));
627639 ARC.switchOutgoingEdgeToRef(A, D);
628640 EXPECT_FALSE(NewE.isCall());
629641
630 // Verify the graph remains the same.
642 // Verify the reference graph remains the same but the SCC graph is updated.
631643 EXPECT_TRUE(ARC.isParentOf(DRC));
644 EXPECT_FALSE(AC.isParentOf(DC));
632645 EXPECT_TRUE(ARC.isAncestorOf(DRC));
646 EXPECT_TRUE(AC.isAncestorOf(DC));
633647 EXPECT_TRUE(DRC.isChildOf(ARC));
648 EXPECT_FALSE(DC.isChildOf(AC));
634649 EXPECT_TRUE(DRC.isDescendantOf(ARC));
650 EXPECT_TRUE(DC.isDescendantOf(AC));
635651 EXPECT_EQ(&AC, CG.lookupSCC(A));
636652 EXPECT_EQ(&BC, CG.lookupSCC(B));
637653 EXPECT_EQ(&CC, CG.lookupSCC(C));
644660 ARC.switchOutgoingEdgeToCall(A, D);
645661 EXPECT_TRUE(NewE.isCall());
646662
647 // Verify the graph remains the same.
663 // Verify the reference graph remains the same but the SCC graph is updated.
648664 EXPECT_TRUE(ARC.isParentOf(DRC));
665 EXPECT_TRUE(AC.isParentOf(DC));
649666 EXPECT_TRUE(ARC.isAncestorOf(DRC));
667 EXPECT_TRUE(AC.isAncestorOf(DC));
650668 EXPECT_TRUE(DRC.isChildOf(ARC));
669 EXPECT_TRUE(DC.isChildOf(AC));
651670 EXPECT_TRUE(DRC.isDescendantOf(ARC));
671 EXPECT_TRUE(DC.isDescendantOf(AC));
652672 EXPECT_EQ(&AC, CG.lookupSCC(A));
653673 EXPECT_EQ(&BC, CG.lookupSCC(B));
654674 EXPECT_EQ(&CC, CG.lookupSCC(C));
663683
664684 // Now the parent and child tests fail again but the rest remains the same.
665685 EXPECT_FALSE(ARC.isParentOf(DRC));
686 EXPECT_FALSE(AC.isParentOf(DC));
666687 EXPECT_TRUE(ARC.isAncestorOf(DRC));
688 EXPECT_TRUE(AC.isAncestorOf(DC));
667689 EXPECT_FALSE(DRC.isChildOf(ARC));
690 EXPECT_FALSE(DC.isChildOf(AC));
668691 EXPECT_TRUE(DRC.isDescendantOf(ARC));
692 EXPECT_TRUE(DC.isDescendantOf(AC));
669693 EXPECT_EQ(&AC, CG.lookupSCC(A));
670694 EXPECT_EQ(&BC, CG.lookupSCC(B));
671695 EXPECT_EQ(&CC, CG.lookupSCC(C));