]> Cypherpunks repositories - gostls13.git/commit
[dev.ssa] cmd/compile/ssa: handle nested dead blocks
authorJosh Bleecher Snyder <josharian@gmail.com>
Fri, 10 Jul 2015 03:24:12 +0000 (21:24 -0600)
committerJosh Bleecher Snyder <josharian@gmail.com>
Sat, 11 Jul 2015 00:08:50 +0000 (00:08 +0000)
commit9b048527db4122732795211291a02357d995c898
tree30d729bdec88012ba4c0cbea344ea255969a39c7
parent9201c86b57b9dcbf3da09028a17be00263762967
[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/12004
Reviewed-by: Todd Neal <todd@tneal.org>
Reviewed-by: Michael Matloob <michaelmatloob@gmail.com>
src/cmd/compile/internal/ssa/check.go
src/cmd/compile/internal/ssa/compile.go
src/cmd/compile/internal/ssa/deadcode.go
src/cmd/compile/internal/ssa/deadcode_test.go
src/cmd/compile/internal/ssa/gen/genericOps.go
src/cmd/compile/internal/ssa/opGen.go
src/cmd/compile/internal/ssa/rewrite.go