Skip to content

Commit

Permalink
cmd/compile: remove regabi magic names
Browse files Browse the repository at this point in the history
When developing register ABI, for early testing the compiler
recognized a few magic names to trigger enabling register ABI.
After the development it is disabled (changed to a name that
cannot be spelled in the source code). Later in the development of
register ABI for ARM64 and PPC64, I don't think the magic names
were used. I think they can now be removed.

Keep the magic pragma for now in case it helps development.

Change-Id: Icbc34e2786a80fd8fffe4a464c569dc03a54cd09
Reviewed-on: https://go-review.googlesource.com/c/go/+/393877
Trust: Cherry Mui <[email protected]>
Run-TryBot: Cherry Mui <[email protected]>
TryBot-Result: Gopher Robot <[email protected]>
Reviewed-by: David Chase <[email protected]>
  • Loading branch information
cherrymui committed Mar 21, 2022
1 parent 7eaad60 commit 3f8a694
Showing 1 changed file with 0 additions and 53 deletions.
53 changes: 0 additions & 53 deletions src/cmd/compile/internal/ssagen/ssa.go
Original file line number Diff line number Diff line change
Expand Up @@ -224,11 +224,6 @@ func AbiForBodylessFuncStackMap(fn *ir.Func) *abi.ABIConfig {
return ssaConfig.ABI0.Copy() // No idea what races will result, be safe
}

// These are disabled but remain ready for use in case they are needed for the next regabi port.
// TODO if they are not needed for 1.18 / next register abi port, delete them.
const magicNameDotSuffix = ".*disabled*MagicMethodNameForTestingRegisterABI"
const magicLastTypeName = "*disabled*MagicLastTypeNameForTestingRegisterABI"

// abiForFunc implements ABI policy for a function, but does not return a copy of the ABI.
// Passing a nil function returns the default ABI based on experiment configuration.
func abiForFunc(fn *ir.Func, abi0, abi1 *abi.ABIConfig) *abi.ABIConfig {
Expand All @@ -251,36 +246,13 @@ func abiForFunc(fn *ir.Func, abi0, abi1 *abi.ABIConfig) *abi.ABIConfig {

a := abi0
if fn != nil {
name := ir.FuncName(fn)
magicName := strings.HasSuffix(name, magicNameDotSuffix)
if fn.Pragma&ir.RegisterParams != 0 { // TODO(register args) remove after register abi is working
if strings.Contains(name, ".") {
if !magicName {
base.ErrorfAt(fn.Pos(), "Calls to //go:registerparams method %s won't work, remove the pragma from the declaration.", name)
}
}
a = abi1
} else if magicName {
if base.FmtPos(fn.Pos()) == "<autogenerated>:1" {
// no way to put a pragma here, and it will error out in the real source code if they did not do it there.
a = abi1
} else {
base.ErrorfAt(fn.Pos(), "Methods with magic name %s (method %s) must also specify //go:registerparams", magicNameDotSuffix[1:], name)
}
}
if regAbiForFuncType(fn.Type().FuncType()) {
// fmt.Printf("Saw magic last type name for function %s\n", name)
a = abi1
}
}
return a
}

func regAbiForFuncType(ft *types.Func) bool {
np := ft.Params.NumFields()
return np > 0 && strings.Contains(ft.Params.FieldType(np-1).String(), magicLastTypeName)
}

// dvarint writes a varint v to the funcdata in symbol x and returns the new offset
func dvarint(x *obj.LSym, off int, v int64) int {
if v < 0 || v > 1e9 {
Expand Down Expand Up @@ -4950,24 +4922,6 @@ func (s *state) call(n *ir.CallExpr, k callKind, returnResultAddr bool) *ssa.Val

callABI := s.f.ABIDefault

if !buildcfg.Experiment.RegabiArgs {
var magicFnNameSym *types.Sym
if fn.Name() != nil {
magicFnNameSym = fn.Name().Sym()
ss := magicFnNameSym.Name
if strings.HasSuffix(ss, magicNameDotSuffix) {
callABI = s.f.ABI1
}
}
if magicFnNameSym == nil && n.Op() == ir.OCALLINTER {
magicFnNameSym = fn.(*ir.SelectorExpr).Sym()
ss := magicFnNameSym.Name
if strings.HasSuffix(ss, magicNameDotSuffix[1:]) {
callABI = s.f.ABI1
}
}
}

if k != callNormal && k != callTail && (len(n.Args) != 0 || n.Op() == ir.OCALLINTER || n.X.Type().NumResults() != 0) {
s.Fatalf("go/defer call with arguments: %v", n)
}
Expand Down Expand Up @@ -5016,13 +4970,6 @@ func (s *state) call(n *ir.CallExpr, k callKind, returnResultAddr bool) *ssa.Val
}
}

if !buildcfg.Experiment.RegabiArgs {
if regAbiForFuncType(n.X.Type().FuncType()) {
// Magic last type in input args to call
callABI = s.f.ABI1
}
}

params := callABI.ABIAnalyze(n.X.Type(), false /* Do not set (register) nNames from caller side -- can cause races. */)
types.CalcSize(fn.Type())
stksize := params.ArgWidth() // includes receiver, args, and results
Expand Down

0 comments on commit 3f8a694

Please sign in to comment.