Skip to content

Commit 18cd4a1

Browse files
committed
cmd/compile: use the right type for spill slot
Currently, when shuffling registers, if we need to spill a register, we always create a spill slot of type int64. The type doesn't actually matter, as long as it is wide enough to hold the registers. This is no longer true with SIMD registers, which could be wider than a int64. Create the slot with the proper type instead. Cherry-picked from the dev.simd branch. This CL is not necessarily SIMD specific. Apply early to reduce risk. Test is SIMD specific so not included for now. Change-Id: I85c82e2532001bfdefe98c9446f2dd18583d49b4 Reviewed-on: https://go-review.googlesource.com/c/go/+/704055 TryBot-Bypass: Cherry Mui <[email protected]> Reviewed-by: David Chase <[email protected]> Reviewed-by: Junyang Shao <[email protected]> Reviewed-on: https://go-review.googlesource.com/c/go/+/708860 LUCI-TryBot-Result: Go LUCI <[email protected]>
1 parent 1caa95a commit 18cd4a1

File tree

2 files changed

+2
-5
lines changed

2 files changed

+2
-5
lines changed

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

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2690,7 +2690,6 @@ func (e *edgeState) erase(loc Location) {
26902690
// findRegFor finds a register we can use to make a temp copy of type typ.
26912691
func (e *edgeState) findRegFor(typ *types.Type) Location {
26922692
// Which registers are possibilities.
2693-
types := &e.s.f.Config.Types
26942693
m := e.s.compatRegs(typ)
26952694

26962695
// Pick a register. In priority order:
@@ -2724,9 +2723,7 @@ func (e *edgeState) findRegFor(typ *types.Type) Location {
27242723
if !c.rematerializeable() {
27252724
x := e.p.NewValue1(c.Pos, OpStoreReg, c.Type, c)
27262725
// Allocate a temp location to spill a register to.
2727-
// The type of the slot is immaterial - it will not be live across
2728-
// any safepoint. Just use a type big enough to hold any register.
2729-
t := LocalSlot{N: e.s.f.NewLocal(c.Pos, types.Int64), Type: types.Int64}
2726+
t := LocalSlot{N: e.s.f.NewLocal(c.Pos, c.Type), Type: c.Type}
27302727
// TODO: reuse these slots. They'll need to be erased first.
27312728
e.set(t, vid, x, false, c.Pos)
27322729
if e.s.f.pass.debug > regDebug {

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -600,7 +600,7 @@ func (v *Value) removeable() bool {
600600
func AutoVar(v *Value) (*ir.Name, int64) {
601601
if loc, ok := v.Block.Func.RegAlloc[v.ID].(LocalSlot); ok {
602602
if v.Type.Size() > loc.Type.Size() {
603-
v.Fatalf("spill/restore type %s doesn't fit in slot type %s", v.Type, loc.Type)
603+
v.Fatalf("v%d: spill/restore type %v doesn't fit in slot type %v", v.ID, v.Type, loc.Type)
604604
}
605605
return loc.N, loc.Off
606606
}

0 commit comments

Comments
 (0)