1
0
mirror of https://github.com/golang/go synced 2024-11-27 00:01:23 -07:00

cmd/compile/internal/types: replace BOGUS_FUNARG_OFFSET with BADWIDTH

We already have a magic constant to represent fields that haven't had
their offsets calculated. We don't need two.

Change-Id: Ibfa95a3a15a5cd43e1e5ec7d0971d3e61d47fb3c
Reviewed-on: https://go-review.googlesource.com/c/go/+/521317
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Reviewed-by: Than McIntosh <thanm@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
This commit is contained in:
Matthew Dempsky 2023-08-20 14:27:27 -07:00
parent a65b4904fc
commit b0a17c0489
3 changed files with 8 additions and 30 deletions

View File

@ -445,20 +445,19 @@ func (config *ABIConfig) ABIAnalyze(t *types.Type, setNname bool) *ABIParamResul
}
func (config *ABIConfig) updateOffset(result *ABIParamResultInfo, f *types.Field, a ABIParamAssignment, isReturn, setNname bool) {
if f.Offset != types.BADWIDTH {
base.Fatalf("field offset for %s at %s has been set to %d", f.Sym.Name, base.FmtPos(f.Pos), f.Offset)
}
// Everything except return values in registers has either a frame home (if not in a register) or a frame spill location.
if !isReturn || len(a.Registers) == 0 {
// The type frame offset DOES NOT show effects of minimum frame size.
// Getting this wrong breaks stackmaps, see liveness/plive.go:WriteFuncMap and typebits/typebits.go:Set
off := a.FrameOffset(result)
fOffset := f.Offset
if fOffset == types.BOGUS_FUNARG_OFFSET {
if setNname && f.Nname != nil {
f.Nname.(*ir.Name).SetFrameOffset(off)
f.Nname.(*ir.Name).SetIsOutputParamInRegisters(false)
}
} else {
base.Fatalf("field offset for %s at %s has been set to %d", f.Sym.Name, base.FmtPos(f.Pos), fOffset)
}
} else {
if setNname && f.Nname != nil {
fname := f.Nname.(*ir.Name)

View File

@ -306,13 +306,6 @@ func (s *state) emitOpenDeferInfo() {
off = dvarint(x, off, -firstOffset)
}
func okOffset(offset int64) int64 {
if offset == types.BOGUS_FUNARG_OFFSET {
panic(fmt.Errorf("Bogus offset %d", offset))
}
return offset
}
// buildssa builds an SSA function for fn.
// worker indicates which of the backend workers is doing the processing.
func buildssa(fn *ir.Func, worker int) *ssa.Func {

View File

@ -409,8 +409,7 @@ type Field struct {
Nname Object
// Offset in bytes of this field or method within its enclosing struct
// or interface Type. Exception: if field is function receiver, arg or
// result, then this is BOGUS_FUNARG_OFFSET; types does not know the Abi.
// or interface Type. For parameters, this is BADWIDTH.
Offset int64
}
@ -1686,14 +1685,6 @@ func NewInterface(methods []*Field) *Type {
return t
}
const BOGUS_FUNARG_OFFSET = -1000000000
func unzeroFieldOffsets(f []*Field) {
for i := range f {
f[i].Offset = BOGUS_FUNARG_OFFSET // This will cause an explosion if it is not corrected
}
}
// NewSignature returns a new function type for the given receiver,
// parameters, and results, any of which may be nil.
func NewSignature(recv *Field, params, results []*Field) *Type {
@ -1711,11 +1702,6 @@ func NewSignature(recv *Field, params, results []*Field) *Type {
return s
}
if recv != nil {
recv.Offset = BOGUS_FUNARG_OFFSET
}
unzeroFieldOffsets(params)
unzeroFieldOffsets(results)
ft.Receiver = funargs(recvs)
ft.Params = funargs(params)
ft.Results = funargs(results)