From 25188f0ca9e2a0851709863e6827045b5e195d2a Mon Sep 17 00:00:00 2001 From: whitequark Date: Mon, 21 Dec 2015 21:32:29 +0800 Subject: [PATCH] transforms.interleaver: correctly handle degenerate `with parallel:` blocks. --- artiq/compiler/transforms/interleaver.py | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/artiq/compiler/transforms/interleaver.py b/artiq/compiler/transforms/interleaver.py index d1f292979..d235ad4ce 100644 --- a/artiq/compiler/transforms/interleaver.py +++ b/artiq/compiler/transforms/interleaver.py @@ -73,14 +73,23 @@ class Interleaver: if postdom_tree is None: postdom_tree = domination.PostDominatorTree(func) - interleave_until = postdom_tree.immediate_dominator(insn.basic_block) - assert (interleave_until is not None) # no nonlocal flow in `with parallel` - target_block = insn.basic_block target_time = 0 source_blocks = insn.basic_block.successors() source_times = [0 for _ in source_blocks] + if len(source_blocks) == 1: + # Immediate dominator for a parallel instruction with one successor + # is the first instruction in the body of the statement which created + # it, but below we expect that it would be the first instruction after + # the statement itself. + insn.replace_with(ir.Branch(source_blocks[0])) + continue + + interleave_until = postdom_tree.immediate_dominator(insn.basic_block) + assert interleave_until is not None # no nonlocal flow in `with parallel` + assert interleave_until not in source_blocks + while len(source_blocks) > 0: def time_after_block(pair): index, block = pair