Skip to content

Commit f421643

Browse files
committed
Debugging cleanup
1 parent 69b5fa1 commit f421643

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

ir.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -300,9 +300,14 @@ def name(self) -> str:
300300

301301
def terminator(self) -> Control:
302302
result = self.instrs[-1]
303-
assert isinstance(result, Control)
303+
assert isinstance(result, Control), f"Expected Control but found {result}"
304304
return result
305305

306+
def succs(self) -> tuple[Block, ...]:
307+
if not self.instrs:
308+
return ()
309+
return self.terminator().succs()
310+
306311

307312
@dataclasses.dataclass(eq=False)
308313
class Jump(Control):
@@ -388,8 +393,7 @@ def rpo(self) -> list[Block]:
388393

389394
def po_from(self, block: Block, result: list[Block], visited: set[Block]) -> None:
390395
visited.add(block)
391-
terminator = block.terminator()
392-
for succ in terminator.succs():
396+
for succ in block.succs():
393397
if succ not in visited:
394398
self.po_from(succ, result, visited)
395399
result.append(block)
@@ -398,7 +402,7 @@ def preds(self) -> dict[Block, set[Block]]:
398402
rpo = self.rpo()
399403
result: dict[Block, set[Block]] = {block: set() for block in rpo}
400404
for block in rpo:
401-
for succ in block.terminator().succs():
405+
for succ in block.succs():
402406
result[succ].add(block)
403407
return result
404408

0 commit comments

Comments
 (0)