diff options
author | David Chase <drchase@google.com> | 2021-04-07 09:58:02 -0400 |
---|---|---|
committer | David Chase <drchase@google.com> | 2021-04-09 14:33:44 +0000 |
commit | a690a5d75fee3b23e9ab80bd7b48cafb52ce4615 (patch) | |
tree | 7e27ad30c71c35eaffc2b2170936650b91e55656 /src/cmd/compile/internal/ssa/stackalloc.go | |
parent | d138ee2cfbd2be3edde22ad8a69da7657d0b0b7a (diff) | |
download | go-a690a5d75fee3b23e9ab80bd7b48cafb52ce4615.tar.gz go-a690a5d75fee3b23e9ab80bd7b48cafb52ce4615.zip |
cmd/compile: ensure spills of int/float reg args land in abi slots
We noticed a while ago that register argument spills were not always
landing where they should.
Updates #40724.
Change-Id: I0b7c3279a2f6270577481c252bae4568cbb6e796
Reviewed-on: https://go-review.googlesource.com/c/go/+/308510
Trust: David Chase <drchase@google.com>
Run-TryBot: David Chase <drchase@google.com>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
Diffstat (limited to 'src/cmd/compile/internal/ssa/stackalloc.go')
-rw-r--r-- | src/cmd/compile/internal/ssa/stackalloc.go | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/src/cmd/compile/internal/ssa/stackalloc.go b/src/cmd/compile/internal/ssa/stackalloc.go index 45058d4e72..025396f335 100644 --- a/src/cmd/compile/internal/ssa/stackalloc.go +++ b/src/cmd/compile/internal/ssa/stackalloc.go @@ -218,8 +218,15 @@ func (s *stackAllocState) stackalloc() { // If this is a named value, try to use the name as // the spill location. var name LocalSlot + interfere := false if v.Op == OpStoreReg { - name = names[v.Args[0].ID] + a := v.Args[0] + name = names[a.ID] + if name.N == nil && (a.Op == OpArgIntReg || a.Op == OpArgFloatReg) { + // Try harder to spill to the abi-provided spill slot, even if the names are messed up. + nameOff := a.Aux.(*AuxNameOffset) + name = LocalSlot{N: nameOff.Name, Type: v.Type, Off: nameOff.Offset} + } } else { name = names[v.ID] } @@ -230,6 +237,7 @@ func (s *stackAllocState) stackalloc() { // A variable can interfere with itself. // It is rare, but it can happen. s.nSelfInterfere++ + interfere = true goto noname } } @@ -271,7 +279,11 @@ func (s *stackAllocState) stackalloc() { // Use the stack variable at that index for v. loc := locs[i] if f.pass.debug > stackDebug { - fmt.Printf("stackalloc %s to %s\n", v, loc) + reason := "noname" + if interfere { + reason = "interfere" + } + fmt.Printf("stackalloc (%s) %s to %s\n", reason, v, loc) } f.setHome(v, loc) slots[v.ID] = i |