Skip to content

Commit

Permalink
[dev.regabi] cmd/compile: fixes for big rewrite
Browse files Browse the repository at this point in the history
Adjust the new regabi code a bit to make the rewrites apply cleanly.

Change-Id: Ice5378e94d94ab45ca0572f44ab8c94b847271b8
Reviewed-on: https://go-review.googlesource.com/c/go/+/279530
Trust: Russ Cox <rsc@golang.org>
Run-TryBot: Russ Cox <rsc@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
  • Loading branch information
rsc committed Dec 23, 2020
1 parent ec741b0 commit d1d1099
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 9 deletions.
11 changes: 6 additions & 5 deletions src/cmd/compile/internal/gc/gsubr.go
Expand Up @@ -265,20 +265,21 @@ func makeABIWrapper(f *ir.Func, wrapperABI obj.ABI) {
// to allocate any stack space). Doing this will require some
// extra work in typecheck/walk/ssa, might want to add a new node
// OTAILCALL or something to this effect.
var call ir.Node
var tail ir.Node
if tfn.Type().NumResults() == 0 && tfn.Type().NumParams() == 0 && tfn.Type().NumRecvs() == 0 {
call = nodSym(ir.ORETJMP, nil, f.Nname.Sym())
tail = nodSym(ir.ORETJMP, nil, f.Nname.Sym())
} else {
call = ir.Nod(ir.OCALL, f.Nname, nil)
call := ir.Nod(ir.OCALL, f.Nname, nil)
call.PtrList().Set(paramNnames(tfn.Type()))
call.SetIsDDD(tfn.Type().IsVariadic())
tail = call
if tfn.Type().NumResults() > 0 {
n := ir.Nod(ir.ORETURN, nil, nil)
n.PtrList().Set1(call)
call = n
tail = n
}
}
fn.PtrBody().Append(call)
fn.PtrBody().Append(tail)

funcbody()
if base.Debug.DclStack != 0 {
Expand Down
10 changes: 6 additions & 4 deletions src/cmd/compile/internal/gc/ssa.go
Expand Up @@ -7332,18 +7332,20 @@ func callTargetLSym(callee *types.Sym, callerLSym *obj.LSym) *obj.LSym {
if ir.AsNode(callee.Def) == nil {
return lsym
}
ndclfunc := ir.AsNode(callee.Def).Name().Defn
if ndclfunc == nil {
defn := ir.AsNode(callee.Def).Name().Defn
if defn == nil {
return lsym
}
ndclfunc := defn.(*ir.Func)

// check for case 1 above
if callerLSym.ABIWrapper() {
if nlsym := ndclfunc.Func().LSym; nlsym != nil {
if nlsym := ndclfunc.LSym; nlsym != nil {
lsym = nlsym
}
} else {
// check for case 2 above
nam := ndclfunc.Func().Nname
nam := ndclfunc.Nname
defABI, hasDefABI := symabiDefs[nam.Sym().LinksymName()]
if hasDefABI && defABI == obj.ABI0 {
lsym = nam.Sym().LinksymABI0()
Expand Down

0 comments on commit d1d1099

Please sign in to comment.