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