-
Notifications
You must be signed in to change notification settings - Fork 322
Open
Description
Line 52 in 57877b1
| nodes = list(reversed(postorder(succ, entry))) # Reverse postorder. |
Take this program for example (modified from interp test):
@print(n: int): int {
}
@main: int {
v: int = const 4;
jmp .somewhere;
v: int = const 2;
.somewhere:
tmp: int = call @print v;
ret v;
}
Applying to_ssa creates this wrong output
@print(n: int): int {
}
@main: int {
.b1:
v.0: int = const 4;
jmp .somewhere;
.b2:
v.1: int = const 2;
jmp .somewhere;
.somewhere:
tmp.0: int = phi __undefined tmp.1 .b1 .b2;
tmp.1: int = call @print v.0;
ret v.0;
}
Note the garbage phi instruction tmp.0. This happens because dominators are computed as follows in dom.py (which is then used by to_ssa.py)
{'b1': {'b1'}, 'b2': {'somewhere', 'b1'}, 'somewhere': {'somewhere', 'b1'}}
This is obviously wrong. This happens because get_dom algorithm fails when there's a node/basic block that doesn't have any predecessor that is not reachable from entry.
Metadata
Metadata
Assignees
Labels
No labels