The newly upgraded shortcircuit pass attempted to remove infinite loops.
Stop doing that.
Fixes #33903
Change-Id: I0fc9c1b5f2427e54ce650806602ef5e3ad65aca5
Reviewed-on: https://go-review.googlesource.com/c/go/+/192144
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
}
}
- // Step 3: Redirect control flow around known branches.
+ // Step 2: Redirect control flow around known branches.
// p:
// ... goto b ...
// b: <- p ...
if a.Op != OpConstBool {
continue
}
- changed = true
// The predecessor we come in from.
e1 := b.Preds[i]
p := e1.b
}
e2 := b.Succs[si]
t := e2.b
+ if p == b || t == b {
+ // This is an infinite loop; we can't remove it. See issue 33903.
+ continue
+ }
ti := e2.i
+ // Update CFG and Phis.
+ changed = true
+
// Remove b's incoming edge from p.
b.removePred(i)
n := len(b.Preds)
--- /dev/null
+// compile
+
+// Copyright 2019 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.
+
+// Check that the shortcircuit pass correctly handles infinite loops.
+
+package p
+
+func f() {
+ var p, q bool
+ for {
+ p = p && q
+ }
+}