forked from M-Labs/artiq
1
0
Fork 0

transforms.interleaver: correctly handle degenerate `with parallel:` blocks.

This commit is contained in:
whitequark 2015-12-21 21:32:29 +08:00
parent ac5c86bfdc
commit 25188f0ca9
1 changed files with 12 additions and 3 deletions

View File

@ -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