[dev.ssa] cmd/compile/ssa: handle nested dead blocks
removePredecessor can change which blocks are live. However, it cannot remove dead blocks from the function's slice of blocks because removePredecessor may have been called from within a function doing a walk of the blocks. CL 11879 did not handle this correctly and broke the build. To fix this, mark the block as dead but leave its actual removal for a deadcode pass. Blocks that are dead must have no successors, predecessors, values, or control values, so they will generally be ignored by other passes. To be safe, we add a deadcode pass after the opt pass, which is the only other pass that calls removePredecessor. Two alternatives that I considered and discarded: (1) Make all call sites aware of the fact that removePrecessor might make arbitrary changes to the list of blocks. This will needlessly complicate callers. (2) Handle the things that can go wrong in practice when we encounter a dead-but-not-removed block. CL 11930 takes this approach (and the tests are stolen from that CL). However, this is just patching over the problem. Change-Id: Icf0687b0a8148ce5e96b2988b668804411b05bd8 Reviewed-on: https://go-review.googlesource.com/12004Reviewed-by: Todd Neal <todd@tneal.org> Reviewed-by: Michael Matloob <michaelmatloob@gmail.com>
Showing
Please
register
or
sign in
to comment