Open chsasank opened 5 months ago
One solution is to ignore unreachable nodes. i,e modify this line
https://github.com/sampsyo/bril/blob/57877b1ebcff5c704786199d7c8ee93a15933310/examples/dom.py#L54
to
dom = {v: set(nodes) for v in nodes}
This creates issues with other algorithms
Sorry, I am wrong about above solution. This doesn't work. To fix my issue of accurate SSA transformation, I deleted basic blocks are not reachable. Here's my solution: https://github.com/chsasank/llama.lisp/commit/7960abdb2a890c2dd3678d1861c41f40a41ef49d#diff-bbd860f50f670b11d6286871f98a63200c8929d51b33d2c4b1cc1494f1f3687b
https://github.com/sampsyo/bril/blob/57877b1ebcff5c704786199d7c8ee93a15933310/examples/dom.py#L52
Take this program for example (modified from interp test):
Applying
to_ssa
creates this wrong outputNote 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)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.