mirror of
https://github.com/golang/go
synced 2024-11-24 11:40:16 -07:00
04903476fe
One CFGs that shortcircuit looks for is: p q \ / b / \ t u The test case creates a CFG like that in which p == t. That caused the compiler to generate a (short-lived) invalid phi value. Fix this with a relatively big hammer: Disallow single-length loops entirely. This is probably overkill, but it such loops are very rare. This doesn't change the generated code for anything in std. It generates worse code for the test case: It no longer compiles the entire function away. Fixes #44465 Change-Id: Ib8cdcd6cc9d7f48b4dab253652038ace24eae152 Reviewed-on: https://go-review.googlesource.com/c/go/+/295130 Trust: Josh Bleecher Snyder <josharian@gmail.com> Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com> Reviewed-by: Keith Randall <khr@golang.org>
22 lines
375 B
Go
22 lines
375 B
Go
// compile -d=ssa/check/seed
|
|
|
|
// Copyright 2021 The Go Authors. All rights reserved.
|
|
// Use of this source code is governed by a BSD-style
|
|
// license that can be found in the LICENSE file.
|
|
|
|
// This code caused an internal consistency error due to a bad shortcircuit optimization.
|
|
|
|
package p
|
|
|
|
func f() {
|
|
var b bool
|
|
if b {
|
|
b = true
|
|
}
|
|
l:
|
|
for !b {
|
|
b = true
|
|
goto l
|
|
}
|
|
}
|