aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/compile/internal/amd64
diff options
context:
space:
mode:
authorCherry Zhang <cherryyz@google.com>2021-04-11 12:42:49 -0400
committerCherry Zhang <cherryyz@google.com>2021-04-14 21:00:20 +0000
commit23f8c203f026814ddc4ba4538f900d8151eb6840 (patch)
tree2aa865117c54427b314177f604b6dba44a26c6fc /src/cmd/compile/internal/amd64
parent1a8f0a79619bee4b0040888a5703e38f8117d682 (diff)
downloadgo-23f8c203f026814ddc4ba4538f900d8151eb6840.tar.gz
go-23f8c203f026814ddc4ba4538f900d8151eb6840.zip
cmd/compile: rework/reduce partially lived argument spilling
In CL 307909 we generate code that spills pointer-typed argument registers if it is part of an SSA-able aggregate. The current code spill the register unconditionally. Sometimes it is unnecessary, because it is already spilled, or it is never live. This CL reworks the spill generation. We move it to the end of compilation, after liveness analysis, so we have information about if a spill is necessary, and only generate spills for the necessary ones. Change-Id: I8d60be9b2c47651aeda14f5e2d1bbd207c134b26 Reviewed-on: https://go-review.googlesource.com/c/go/+/309331 Trust: Cherry Zhang <cherryyz@google.com> Run-TryBot: Cherry Zhang <cherryyz@google.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: David Chase <drchase@google.com> Reviewed-by: Than McIntosh <thanm@google.com>
Diffstat (limited to 'src/cmd/compile/internal/amd64')
-rw-r--r--src/cmd/compile/internal/amd64/galign.go1
-rw-r--r--src/cmd/compile/internal/amd64/ssa.go8
2 files changed, 9 insertions, 0 deletions
diff --git a/src/cmd/compile/internal/amd64/galign.go b/src/cmd/compile/internal/amd64/galign.go
index 7845395538..2785aa0336 100644
--- a/src/cmd/compile/internal/amd64/galign.go
+++ b/src/cmd/compile/internal/amd64/galign.go
@@ -24,4 +24,5 @@ func Init(arch *ssagen.ArchInfo) {
arch.SSAGenValue = ssaGenValue
arch.SSAGenBlock = ssaGenBlock
arch.LoadRegResults = loadRegResults
+ arch.SpillArgReg = spillArgReg
}
diff --git a/src/cmd/compile/internal/amd64/ssa.go b/src/cmd/compile/internal/amd64/ssa.go
index e7b4fae016..fce3c6b820 100644
--- a/src/cmd/compile/internal/amd64/ssa.go
+++ b/src/cmd/compile/internal/amd64/ssa.go
@@ -11,6 +11,7 @@ import (
"cmd/compile/internal/base"
"cmd/compile/internal/ir"
"cmd/compile/internal/logopt"
+ "cmd/compile/internal/objw"
"cmd/compile/internal/ssa"
"cmd/compile/internal/ssagen"
"cmd/compile/internal/types"
@@ -1364,3 +1365,10 @@ func loadRegResults(s *ssagen.State, f *ssa.Func) {
}
}
}
+
+func spillArgReg(pp *objw.Progs, p *obj.Prog, f *ssa.Func, t *types.Type, reg int16, n *ir.Name, off int64) *obj.Prog {
+ p = pp.Append(p, storeByType(t), obj.TYPE_REG, reg, 0, obj.TYPE_MEM, 0, n.FrameOffset()+off)
+ p.To.Name = obj.NAME_PARAM
+ p.To.Sym = n.Linksym()
+ return p
+}