Skip to content

Commit

Permalink
analyses.domination: consider unreachable blocks dominated by any other.
Browse files Browse the repository at this point in the history
As a result, the dominator tree can now process arbitrary (reducible)
CFGs and we do not run DCE before analyses, risking loss of
correspondence to the AST, which would arbitrarily silence analyses.
whitequark committed Dec 18, 2015
1 parent 59a3ea4 commit 3fbee27
Showing 2 changed files with 9 additions and 4 deletions.
10 changes: 8 additions & 2 deletions artiq/compiler/analyses/domination.py
Original file line number Diff line number Diff line change
@@ -74,7 +74,11 @@ def immediate_dominator(self, block):
return self._block_of_name[self._doms[self._name_of_block[block]]]

def dominators(self, block):
yield block
# Blocks that are statically unreachable from entry are considered
# dominated by every other block.
if block not in self._name_of_block:
yield from self._block_of_name
return

block_name = self._name_of_block[block]
while block_name != self._doms[block_name]:
@@ -103,7 +107,9 @@ def visit(block):

def _prev_block_names(self, block_name):
for block in self._block_of_name[block_name].predecessors():
yield self._name_of_block[block]
# Only return predecessors that are statically reachable from entry.
if block in self._name_of_block:
yield self._name_of_block[block]

class PostDominatorTree(GenericDominatorTree):
def __init__(self, function):
3 changes: 1 addition & 2 deletions artiq/compiler/module.py
Original file line number Diff line number Diff line change
@@ -70,10 +70,9 @@ def __init__(self, src, ref_period=1e-6):
devirtualization.visit(src.typedtree)
self.artiq_ir = artiq_ir_generator.visit(src.typedtree)
artiq_ir_generator.annotate_calls(devirtualization)
dead_code_eliminator.process(self.artiq_ir)
local_access_validator.process(self.artiq_ir)
interleaver.process(self.artiq_ir)
dead_code_eliminator.process(self.artiq_ir)
interleaver.process(self.artiq_ir)

def build_llvm_ir(self, target):
"""Compile the module to LLVM IR for the specified target."""

0 comments on commit 3fbee27

Please sign in to comment.