From: Josh Bleecher Snyder Date: Wed, 11 Mar 2020 21:49:37 +0000 (-0700) Subject: cmd/compile: guard against invalid phis in shortcircuit X-Git-Tag: go1.15beta1~591 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=64dcef3045161022d69f32b69d23f771b53c0922;p=gostls13.git cmd/compile: guard against invalid phis in shortcircuit In the review of CL 222923, Keith expressed concern that we could end up with invalid phis. We have some code to handle this, but on further reflection, I think it might not handle some cases in which phis get moved. I can't create a failing case, but guard against it nevertheless. Change-Id: Ib3a07ac1d36a674c72dcb9cc9261ccfcb716b5a3 Reviewed-on: https://go-review.googlesource.com/c/go/+/227697 Run-TryBot: Josh Bleecher Snyder TryBot-Result: Gobot Gobot Reviewed-by: Keith Randall --- diff --git a/src/cmd/compile/internal/ssa/shortcircuit.go b/src/cmd/compile/internal/ssa/shortcircuit.go index 0faaa5a309..9f18117066 100644 --- a/src/cmd/compile/internal/ssa/shortcircuit.go +++ b/src/cmd/compile/internal/ssa/shortcircuit.go @@ -237,7 +237,11 @@ func shortcircuitBlock(b *Block) bool { } } } - phielimValue(phi) + if phi.Uses != 0 { + phielimValue(phi) + } else { + phi.reset(OpInvalid) + } i-- // v.moveTo put a new value at index i; reprocess }