File tree Expand file tree Collapse file tree 2 files changed +24
-2
lines changed
src/cmd/compile/internal/ssa Expand file tree Collapse file tree 2 files changed +24
-2
lines changed Original file line number Diff line number Diff line change @@ -50,7 +50,7 @@ func shortcircuit(f *Func) {
50
50
}
51
51
}
52
52
53
- // Step 3 : Redirect control flow around known branches.
53
+ // Step 2 : Redirect control flow around known branches.
54
54
// p:
55
55
// ... goto b ...
56
56
// b: <- p ...
@@ -124,7 +124,6 @@ func shortcircuitBlock(b *Block) bool {
124
124
if a .Op != OpConstBool {
125
125
continue
126
126
}
127
- changed = true
128
127
// The predecessor we come in from.
129
128
e1 := b .Preds [i ]
130
129
p := e1 .b
@@ -138,8 +137,15 @@ func shortcircuitBlock(b *Block) bool {
138
137
}
139
138
e2 := b .Succs [si ]
140
139
t := e2 .b
140
+ if p == b || t == b {
141
+ // This is an infinite loop; we can't remove it. See issue 33903.
142
+ continue
143
+ }
141
144
ti := e2 .i
142
145
146
+ // Update CFG and Phis.
147
+ changed = true
148
+
143
149
// Remove b's incoming edge from p.
144
150
b .removePred (i )
145
151
n := len (b .Preds )
Original file line number Diff line number Diff line change
1
+ // compile
2
+
3
+ // Copyright 2019 The Go Authors. All rights reserved.
4
+ // Use of this source code is governed by a BSD-style
5
+ // license that can be found in the LICENSE file.
6
+
7
+ // Check that the shortcircuit pass correctly handles infinite loops.
8
+
9
+ package p
10
+
11
+ func f () {
12
+ var p , q bool
13
+ for {
14
+ p = p && q
15
+ }
16
+ }
You can’t perform that action at this time.
0 commit comments