Skip to content

Commit 9088c69

Browse files
committed
cmd/compile: ensure temp register mask isn't empty
We need to avoid nospill registers at this point in regalloc. Make sure that we don't restrict our register set to avoid registers desired by other instructions, if the resulting set includes only nospill registers. Fixes #57846 Change-Id: I05478e4513c484755dc2e8621d73dac868e45a27 Reviewed-on: https://go-review.googlesource.com/c/go/+/461685 Reviewed-by: Keith Randall <[email protected]> Run-TryBot: Keith Randall <[email protected]> Reviewed-by: Cherry Mui <[email protected]> TryBot-Result: Gopher Robot <[email protected]>
1 parent c0799f7 commit 9088c69

File tree

2 files changed

+34
-1
lines changed

2 files changed

+34
-1
lines changed

src/cmd/compile/internal/ssa/regalloc.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1561,7 +1561,7 @@ func (s *regAllocState) regalloc(f *Func) {
15611561
// (Not all instructions need that distinct part, but it is conservative.)
15621562
if opcodeTable[v.Op].needIntTemp {
15631563
m := s.allocatable & s.f.Config.gpRegMask
1564-
if m&^desired.avoid != 0 {
1564+
if m&^desired.avoid&^s.nospill != 0 {
15651565
m &^= desired.avoid
15661566
}
15671567
tmpReg = s.allocReg(m, &tmpVal)

test/fixedbugs/issue57846.go

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
// compile
2+
3+
// Copyright 2023 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+
package main
8+
9+
func Float64D3(list [][][]float64, value float64) int {
10+
valueCount := 0
11+
for _, listValue := range list {
12+
valueCount += Float64D2(listValue, value)
13+
}
14+
return valueCount
15+
}
16+
17+
func Float64(list []float64, value float64) int {
18+
valueCount := 0
19+
for _, listValue := range list {
20+
if listValue == value {
21+
valueCount++
22+
}
23+
}
24+
return valueCount
25+
}
26+
27+
func Float64D2(list [][]float64, value float64) int {
28+
valueCount := 0
29+
for _, listValue := range list {
30+
valueCount += Float64(listValue, value)
31+
}
32+
return valueCount
33+
}

0 commit comments

Comments
 (0)