Skip to content

Commit f5cae7b

Browse files
authored
[ORC] Add unit test for simple cycle in WaitingOnGraph::emit. (#169281)
WaitingOnGraphTests.Emit_SingleContainerSimpleCycle tests a pair of emit operations where the second completes a simple cycle (1: A -> B, 2: B -> A). We already had a test of WaitingOnGraph::simplify's behavior in this case, but did not have one for WaitingOnGraph::emit.
1 parent 95f0fab commit f5cae7b

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

llvm/unittests/ExecutionEngine/Orc/WaitingOnGraphTest.cpp

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -399,6 +399,31 @@ TEST_F(WaitingOnGraphTest, Emit_TrivialSequence) {
399399
EXPECT_EQ(ER1.Failed.size(), 0U);
400400
}
401401

402+
TEST_F(WaitingOnGraphTest, Emit_SingleContainerSimpleCycle) {
403+
// Test an emit of two nodes with a dependence cycle within a single
404+
// container:
405+
// N0: (0, 0) -> (0, 1)
406+
// N1: (0, 1) -> (0, 0)
407+
// We expect intra-simplify cycle elimination to clear both dependence sets,
408+
// and coalescing to join them into one supernode covering both defs.
409+
SuperNodeBuilder B;
410+
ContainerElementsMap Defs0({{0, {0}}});
411+
ContainerElementsMap Deps0({{0, {1}}});
412+
B.add(Defs0, Deps0);
413+
414+
auto ER0 = emit(TestGraph::simplify(B.takeSuperNodes()));
415+
EXPECT_EQ(ER0.Ready.size(), 0U);
416+
EXPECT_EQ(ER0.Failed.size(), 0U);
417+
418+
ContainerElementsMap Defs1({{0, {1}}});
419+
ContainerElementsMap Deps1({{0, {0}}});
420+
B.add(Defs1, Deps1);
421+
auto ER1 = emit(TestGraph::simplify(B.takeSuperNodes()));
422+
423+
EXPECT_EQ(collapseDefs(ER1.Ready), merge(Defs0, Defs1));
424+
EXPECT_EQ(ER1.Failed.size(), 0U);
425+
}
426+
402427
TEST_F(WaitingOnGraphTest, Emit_TrivialReverseSequence) {
403428
// Perform a sequence of two emits where the first emit depends on the
404429
// second. Check that both nodes become ready after the second emit.

0 commit comments

Comments
 (0)