]> Cypherpunks repositories - gostls13.git/commitdiff
[dev.regabi] cmd/compile: fix noopt builder
authorMatthew Dempsky <mdempsky@google.com>
Fri, 11 Dec 2020 05:04:41 +0000 (21:04 -0800)
committerAlexander Rakoczy <alex@golang.org>
Mon, 14 Dec 2020 16:43:58 +0000 (11:43 -0500)
The non-simple, phi-insertion algorithm can leave OpFwdRefs in the SSA
graph unresolved if they're in dead blocks. Normally, these would be
harmlessly removed later during SSA dead-code elimination, but those
passes are omitted for -N builds. And so they reach zcse, where the
Value.Aux is used within a hash map.

This became a problem after golang.org/cl/275788, which added
FwdRefAux to wrap OpFwdRef's ir.Node, and to ensure that it's not
compared for equality / used as a map key.

This CL adds a simple fix: if there are any OpFwdRefs remaining after
resolveFwdRef, then they must be dead code and we can simply replace
them with OpUnknown.

Change-Id: I72e4116d52d3f6441ebb0bf6160906617cd59513
Reviewed-on: https://go-review.googlesource.com/c/go/+/277075
Trust: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Keith Randall <khr@golang.org>
src/cmd/compile/internal/gc/phi.go

index def11e1be0cb287752bedd0d736660b9761b7cba..32c330b584a7684fed8d98332dc0d3b479c5cbb8 100644 (file)
@@ -188,6 +188,11 @@ levels:
                        if v.Op == ssa.OpPhi {
                                v.AuxInt = 0
                        }
+                       // Any remaining FwdRefs are dead code.
+                       if v.Op == ssa.OpFwdRef {
+                               v.Op = ssa.OpUnknown
+                               v.Aux = nil
+                       }
                }
        }
 }