From 64dcef3045161022d69f32b69d23f771b53c0922 Mon Sep 17 00:00:00 2001 From: Josh Bleecher Snyder Date: Wed, 11 Mar 2020 14:49:37 -0700 Subject: [PATCH] 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 --- src/cmd/compile/internal/ssa/shortcircuit.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) 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 }