]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/compile: don't modify underlying type when creating bitmap for bodyless function
authorDavid Chase <drchase@google.com>
Fri, 9 Apr 2021 22:05:57 +0000 (18:05 -0400)
committerDavid Chase <drchase@google.com>
Tue, 13 Apr 2021 22:31:20 +0000 (22:31 +0000)
This fixes the build crash for
    GOEXPERIMENT=regabi,regabiargs GOOS=windows go build syscall

Updates #40724.

Change-Id: I4400f6ff2e83e7e7e93ad5e58c6063b327532504
Reviewed-on: https://go-review.googlesource.com/c/go/+/309110
Trust: David Chase <drchase@google.com>
Reviewed-by: Than McIntosh <thanm@google.com>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
src/cmd/compile/internal/abi/abiutils.go
src/cmd/compile/internal/gc/compile.go
src/cmd/compile/internal/liveness/plive.go

index 50a818c025cc63bfb3b9acfb7924856322e75e53..e192adb5e1a1f7febb16e2cdded5c504bcc023f6 100644 (file)
@@ -5,6 +5,7 @@
 package abi
 
 import (
+       "cmd/compile/internal/base"
        "cmd/compile/internal/ir"
        "cmd/compile/internal/types"
        "cmd/internal/src"
@@ -104,7 +105,7 @@ type ABIParamAssignment struct {
 // This will panic if "a" describes a register-allocated parameter.
 func (a *ABIParamAssignment) Offset() int32 {
        if len(a.Registers) > 0 {
-               panic("Register allocated parameters have no offset")
+               base.Fatalf("register allocated parameters have no offset")
        }
        return a.offset
 }
@@ -238,7 +239,7 @@ func appendParamOffsets(offsets []int64, at int64, t *types.Type) ([]int64, int6
 // spill area to help reduce stack sizes.)
 func (a *ABIParamAssignment) FrameOffset(i *ABIParamResultInfo) int64 {
        if a.offset == -1 {
-               panic("Function parameter has no ABI-defined frame-pointer offset")
+               base.Fatalf("function parameter has no ABI-defined frame-pointer offset")
        }
        if len(a.Registers) == 0 { // passed on stack
                return int64(a.offset) - i.config.LocalsOffset()
@@ -429,6 +430,7 @@ func (config *ABIConfig) ABIAnalyzeFuncType(ft *types.Func) *ABIParamResultInfo
 func (config *ABIConfig) ABIAnalyze(t *types.Type, setNname bool) *ABIParamResultInfo {
        ft := t.FuncType()
        result := config.ABIAnalyzeFuncType(ft)
+
        // Fill in the frame offsets for receiver, inputs, results
        k := 0
        if t.NumRecvs() != 0 {
@@ -472,7 +474,7 @@ func (config *ABIConfig) updateOffset(result *ABIParamResultInfo, f *types.Field
                                f.Nname.(*ir.Name).SetIsOutputParamInRegisters(false)
                        }
                } else if fOffset != off {
-                       panic(fmt.Errorf("Offset changed from %d to %d", fOffset, off))
+                       base.Fatalf("offset for %s at %s changed from %d to %d", f.Sym.Name, base.FmtPos(f.Pos), fOffset, off)
                }
        } else {
                if setNname && f.Nname != nil {
@@ -610,7 +612,8 @@ func (state *assignState) allocateRegs(regs []RegIndex, t *types.Type) []RegInde
                        return state.allocateRegs(regs, synthIface)
                }
        }
-       panic(fmt.Errorf("Was not expecting type %s", t))
+       base.Fatalf("was not expecting type %s", t)
+       panic("unreachable")
 }
 
 // regAllocate creates a register ABIParamAssignment object for a param
@@ -765,7 +768,8 @@ func (state *assignState) regassign(pt *types.Type) bool {
        case types.TINTER:
                return state.regassignStruct(synthIface)
        default:
-               panic("not expected")
+               base.Fatalf("not expected")
+               panic("unreachable")
        }
 }
 
@@ -776,7 +780,8 @@ func (state *assignState) regassign(pt *types.Type) bool {
 func (state *assignState) assignParamOrReturn(pt *types.Type, n types.Object, isReturn bool) ABIParamAssignment {
        state.pUsed = RegAmounts{}
        if pt.Width == types.BADWIDTH {
-               panic("should never happen")
+               base.Fatalf("should never happen")
+               panic("unreachable")
        } else if pt.Width == 0 {
                return state.stackAllocate(pt, n)
        } else if state.regassign(pt) {
index 6db37919fa92a52e70d6e7aedbb7e47ad12082d3..a71684a859d59a25c1b376e6585f5e159fb91aac 100644 (file)
@@ -43,9 +43,9 @@ func enqueueFunc(fn *ir.Func) {
        if len(fn.Body) == 0 {
                // Initialize ABI wrappers if necessary.
                ssagen.InitLSym(fn, false)
-               types.CalcSize(fn.Type()) // TODO register args; remove this once all is done by abiutils
+               types.CalcSize(fn.Type())
                a := ssagen.AbiForBodylessFuncStackMap(fn)
-               abiInfo := a.ABIAnalyze(fn.Type(), true) // will set parameter spill/home locations correctly
+               abiInfo := a.ABIAnalyzeFuncType(fn.Type().FuncType()) // abiInfo has spill/home locations for wrapper
                liveness.WriteFuncMap(fn, abiInfo)
                return
        }
index 5d8e8b115d23dc7b09ae7c6a54fad0c79ec9ce42..4395aaeeb649a9d6a9bbb7b7d8a2fb3464726e9c 100644 (file)
@@ -1457,7 +1457,6 @@ func WriteFuncMap(fn *ir.Func, abiInfo *abi.ABIParamResultInfo) {
        if ir.FuncName(fn) == "_" || fn.Sym().Linkname != "" {
                return
        }
-       types.CalcSize(fn.Type())
        nptr := int(abiInfo.ArgWidth() / int64(types.PtrSize))
        bv := bitvec.New(int32(nptr) * 2)