aboutsummaryrefslogtreecommitdiff
path: root/llvm/unittests/ADT/SCCIteratorTest.cpp
diff options
context:
space:
mode:
authorDuncan Sands <baldrick@free.fr>2011-07-28 14:33:01 +0000
committerDuncan Sands <baldrick@free.fr>2011-07-28 14:33:01 +0000
commit6d0f0ffe838a1c828a5136d3dfa1ba7b37bd530d (patch)
treed3998178f4e4aaaaf8d64a52007f0d1d1a5aeee3 /llvm/unittests/ADT/SCCIteratorTest.cpp
parentdc5c9586025a12bf46080782d96026a8e4b56bf0 (diff)
downloadllvm-6d0f0ffe838a1c828a5136d3dfa1ba7b37bd530d.zip
llvm-6d0f0ffe838a1c828a5136d3dfa1ba7b37bd530d.tar.gz
llvm-6d0f0ffe838a1c828a5136d3dfa1ba7b37bd530d.tar.bz2
Check an additional property specific to the way LLVM
iterates over SCC's. llvm-svn: 136353
Diffstat (limited to 'llvm/unittests/ADT/SCCIteratorTest.cpp')
-rw-r--r--llvm/unittests/ADT/SCCIteratorTest.cpp15
1 files changed, 15 insertions, 0 deletions
diff --git a/llvm/unittests/ADT/SCCIteratorTest.cpp b/llvm/unittests/ADT/SCCIteratorTest.cpp
index 8146e28..cf0ec01 100644
--- a/llvm/unittests/ADT/SCCIteratorTest.cpp
+++ b/llvm/unittests/ADT/SCCIteratorTest.cpp
@@ -322,6 +322,21 @@ TEST(SCCIteratorTest, AllSmallGraphs) {
EXPECT_TRUE(NodesInSomeSCC.Meet(NodesInThisSCC).isEmpty());
NodesInSomeSCC = NodesInSomeSCC.Join(NodesInThisSCC);
+
+ // Check a property that is specific to the LLVM SCC iterator and
+ // guaranteed by it: if a node in SCC S1 has an edge to a node in
+ // SCC S2, then S1 is visited *after* S2. This means that the set
+ // of nodes reachable from this SCC must be contained either in the
+ // union of this SCC and all previously visited SCC's.
+
+ for (unsigned i = 0; i != NUM_NODES; ++i)
+ if (NodesInThisSCC.count(i)) {
+ GT::NodeSubset NodesReachableFromSCC = G.NodesReachableFrom(i);
+ EXPECT_TRUE(NodesReachableFromSCC.isSubsetOf(NodesInSomeSCC));
+ // The result must be the same for all other nodes in this SCC, so
+ // there is no point in checking them.
+ break;
+ }
}
// Finally, check that the nodes in some SCC are exactly those that are