|
|
|
@ -9,11 +9,17 @@ if TYPE_CHECKING: |
|
|
|
|
def intersection_predecessor(node: "Node") -> Set["Node"]: |
|
|
|
|
if not node.fathers: |
|
|
|
|
return set() |
|
|
|
|
ret = node.fathers[0].dominators |
|
|
|
|
for pred in node.fathers[1:]: |
|
|
|
|
ret = ret.intersection(pred.dominators) |
|
|
|
|
return ret |
|
|
|
|
if not any(father.is_reachable for father in node.fathers): |
|
|
|
|
return set() |
|
|
|
|
|
|
|
|
|
ret = set() |
|
|
|
|
for pred in node.fathers: |
|
|
|
|
ret = ret.union(pred.dominators) |
|
|
|
|
|
|
|
|
|
for pred in node.fathers: |
|
|
|
|
if pred.is_reachable: |
|
|
|
|
ret = ret.intersection(pred.dominators) |
|
|
|
|
return ret |
|
|
|
|
|
|
|
|
|
def _compute_dominators(nodes: List["Node"]) -> None: |
|
|
|
|
changed = True |
|
|
|
@ -84,6 +90,8 @@ def compute_dominance_frontier(nodes: List["Node"]) -> None: |
|
|
|
|
for node in nodes: |
|
|
|
|
if len(node.fathers) >= 2: |
|
|
|
|
for father in node.fathers: |
|
|
|
|
if not father.is_reachable: |
|
|
|
|
continue |
|
|
|
|
runner = father |
|
|
|
|
# Corner case: if there is a if without else |
|
|
|
|
# we need to add update the conditional node |
|
|
|
|