diff options
author | David Chase <drchase@google.com> | 2021-03-12 13:37:24 -0500 |
---|---|---|
committer | David Chase <drchase@google.com> | 2021-03-22 18:42:15 +0000 |
commit | 196c33e92d86eb21fe1cb7d244ea61209b4a554e (patch) | |
tree | 4e45e3c3de287b7e46f63822c3ec55f258be2473 /src/cmd/compile/internal/abi/abiutils.go | |
parent | ba6b8e75ed16b3e9ecb305399e5ec2e29778e299 (diff) | |
download | go-196c33e92d86eb21fe1cb7d244ea61209b4a554e.tar.gz go-196c33e92d86eb21fe1cb7d244ea61209b4a554e.zip |
cmd/compile: fix WriteFuncMap for new ABI.
replaced old type-based logic with new abi-based logic;
earlier versions of this CL compared them for equality.
For not-in-a-register, they match everywhere tested.
also modified GetFrameOffset to make it more like the one it replaces;
the LocalsOffset is subtracted.
Change-Id: I65ce7f0646c493c277df6b6f46e4839a0d886ac9
Reviewed-on: https://go-review.googlesource.com/c/go/+/302072
Trust: David Chase <drchase@google.com>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
Diffstat (limited to 'src/cmd/compile/internal/abi/abiutils.go')
-rw-r--r-- | src/cmd/compile/internal/abi/abiutils.go | 24 |
1 files changed, 15 insertions, 9 deletions
diff --git a/src/cmd/compile/internal/abi/abiutils.go b/src/cmd/compile/internal/abi/abiutils.go index 7573c13158..8495ed7c51 100644 --- a/src/cmd/compile/internal/abi/abiutils.go +++ b/src/cmd/compile/internal/abi/abiutils.go @@ -236,16 +236,22 @@ func (a *ABIParamAssignment) SpillOffset() int32 { return a.offset } -// FrameOffset returns the location that a value would spill to, if any exists. -// For register-allocated inputs, that is their spill offset reserved for morestack -// (might as well use it, it is there); for stack-allocated inputs and outputs, -// that is their location on the stack. For register-allocated outputs, there is -// no defined spill area, so return -1. +// FrameOffset returns the frame-pointer-relative location that a function +// would spill its input or output parameter to, if such a spill slot exists. +// For register-allocated inputs that is their spill offset reserved for morestack; +// for stack-allocated inputs and outputs, that is their location on the stack. +// For register-allocated outputs, there is no defined spill area, so return -1. +// (In a future version of the ABI, register-resident inputs may lose their defined +// spill area to help reduce stack sizes.) func (a *ABIParamAssignment) FrameOffset(i *ABIParamResultInfo) int64 { - if len(a.Registers) == 0 || a.offset == -1 { - return int64(a.offset) + if a.offset == -1 { + return -1 } - return int64(a.offset) + i.SpillAreaOffset() + if len(a.Registers) == 0 { // passed on stack + return int64(a.offset) - i.config.LocalsOffset() + } + // spill area for registers + return int64(a.offset) + i.SpillAreaOffset() - i.config.LocalsOffset() } // RegAmounts holds a specified number of integer/float registers. @@ -462,7 +468,7 @@ func (config *ABIConfig) updateOffset(result *ABIParamResultInfo, f *types.Field // Getting this wrong breaks stackmaps, see liveness/plive.go:WriteFuncMap and typebits/typebits.go:Set parameterUpdateMu.Lock() defer parameterUpdateMu.Unlock() - off := a.FrameOffset(result) - config.LocalsOffset() + off := a.FrameOffset(result) fOffset := f.Offset if fOffset == types.BOGUS_FUNARG_OFFSET { // Set the Offset the first time. After that, we may recompute it, but it should never change. |