aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/compile/internal/liveness
diff options
context:
space:
mode:
authorDavid Chase <drchase@google.com>2021-03-12 13:37:24 -0500
committerDavid Chase <drchase@google.com>2021-03-22 18:42:15 +0000
commit196c33e92d86eb21fe1cb7d244ea61209b4a554e (patch)
tree4e45e3c3de287b7e46f63822c3ec55f258be2473 /src/cmd/compile/internal/liveness
parentba6b8e75ed16b3e9ecb305399e5ec2e29778e299 (diff)
downloadgo-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/liveness')
-rw-r--r--src/cmd/compile/internal/liveness/plive.go29
1 files changed, 17 insertions, 12 deletions
diff --git a/src/cmd/compile/internal/liveness/plive.go b/src/cmd/compile/internal/liveness/plive.go
index c09a8401f7..5d8e8b115d 100644
--- a/src/cmd/compile/internal/liveness/plive.go
+++ b/src/cmd/compile/internal/liveness/plive.go
@@ -22,6 +22,7 @@ import (
"sort"
"strings"
+ "cmd/compile/internal/abi"
"cmd/compile/internal/base"
"cmd/compile/internal/bitvec"
"cmd/compile/internal/ir"
@@ -1449,32 +1450,36 @@ func isfat(t *types.Type) bool {
return false
}
-// TODO THIS IS ALL WRONG AND NEEDS TO USE ABI.
-func WriteFuncMap(fn *ir.Func) {
+// WriteFuncMap writes the pointer bitmaps for bodyless function fn's
+// inputs and outputs as the value of symbol <fn>.args_stackmap.
+// If fn has outputs, two bitmaps are written, otherwise just one.
+func WriteFuncMap(fn *ir.Func, abiInfo *abi.ABIParamResultInfo) {
if ir.FuncName(fn) == "_" || fn.Sym().Linkname != "" {
return
}
types.CalcSize(fn.Type())
- lsym := base.Ctxt.Lookup(fn.LSym.Name + ".args_stackmap")
- nptr := int(fn.Type().ArgWidth() / int64(types.PtrSize))
+ nptr := int(abiInfo.ArgWidth() / int64(types.PtrSize))
bv := bitvec.New(int32(nptr) * 2)
+
+ for _, p := range abiInfo.InParams() {
+ typebits.Set(p.Type, p.FrameOffset(abiInfo), bv)
+ }
+
nbitmap := 1
if fn.Type().NumResults() > 0 {
nbitmap = 2
}
+ lsym := base.Ctxt.Lookup(fn.LSym.Name + ".args_stackmap")
off := objw.Uint32(lsym, 0, uint32(nbitmap))
off = objw.Uint32(lsym, off, uint32(bv.N))
-
- if ir.IsMethod(fn) {
- typebits.Set(fn.Type().Recvs(), 0, bv)
- }
- if fn.Type().NumParams() > 0 {
- typebits.Set(fn.Type().Params(), 0, bv)
- }
off = objw.BitVec(lsym, off, bv)
if fn.Type().NumResults() > 0 {
- typebits.Set(fn.Type().Results(), 0, bv)
+ for _, p := range abiInfo.OutParams() {
+ if len(p.Registers) == 0 {
+ typebits.Set(p.Type, p.FrameOffset(abiInfo), bv)
+ }
+ }
off = objw.BitVec(lsym, off, bv)
}