]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/compile: guard against invalid phis in shortcircuit
authorJosh Bleecher Snyder <josharian@gmail.com>
Wed, 11 Mar 2020 21:49:37 +0000 (14:49 -0700)
committerJosh Bleecher Snyder <josharian@gmail.com>
Sat, 11 Apr 2020 17:33:35 +0000 (17:33 +0000)
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 <josharian@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
src/cmd/compile/internal/ssa/shortcircuit.go

index 0faaa5a309c4c570fb946f7661f68a0509f4f5dd..9f181170663dc9ca9bfc1c756c5248553aa922d4 100644 (file)
@@ -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
                }