Commit 79db1625 authored by Matthew Dempsky's avatar Matthew Dempsky

cmd/compile: eliminate stkdelta

At this point in the compiler we haven't assigned Xoffset values for
PAUTO variables anyway, so just immediately store the stack offsets
into Xoffset rather than into a global map.

Change-Id: I61eb471c857c8b145fd0895cbd98fd4e8d3c3365
Reviewed-on: https://go-review.googlesource.com/30081
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: default avatarKeith Randall <khr@golang.org>
parent bb2bbfa0
...@@ -286,7 +286,7 @@ func (n *Node) jconv(s fmt.State, flag FmtFlag) { ...@@ -286,7 +286,7 @@ func (n *Node) jconv(s fmt.State, flag FmtFlag) {
} }
if c == 0 && n.Xoffset != BADWIDTH { if c == 0 && n.Xoffset != BADWIDTH {
fmt.Fprintf(s, " x(%d%+d)", n.Xoffset, stkdelta[n]) fmt.Fprintf(s, " x(%d)", n.Xoffset)
} }
if n.Class != 0 { if n.Class != 0 {
......
...@@ -98,11 +98,11 @@ func fixautoused(p *obj.Prog) { ...@@ -98,11 +98,11 @@ func fixautoused(p *obj.Prog) {
} }
if p.From.Name == obj.NAME_AUTO && p.From.Node != nil { if p.From.Name == obj.NAME_AUTO && p.From.Node != nil {
p.From.Offset += stkdelta[p.From.Node.(*Node)] p.From.Offset += p.From.Node.(*Node).Xoffset
} }
if p.To.Name == obj.NAME_AUTO && p.To.Node != nil { if p.To.Name == obj.NAME_AUTO && p.To.Node != nil {
p.To.Offset += stkdelta[p.To.Node.(*Node)] p.To.Offset += p.To.Node.(*Node).Xoffset
} }
lp = &p.Link lp = &p.Link
......
...@@ -214,11 +214,6 @@ func (s byStackVar) Len() int { return len(s) } ...@@ -214,11 +214,6 @@ func (s byStackVar) Len() int { return len(s) }
func (s byStackVar) Less(i, j int) bool { return cmpstackvarlt(s[i], s[j]) } func (s byStackVar) Less(i, j int) bool { return cmpstackvarlt(s[i], s[j]) }
func (s byStackVar) Swap(i, j int) { s[i], s[j] = s[j], s[i] } func (s byStackVar) Swap(i, j int) { s[i], s[j] = s[j], s[i] }
// stkdelta records the stack offset delta for a node
// during the compaction of the stack frame to remove
// unused stack slots.
var stkdelta = map[*Node]int64{}
// TODO(lvd) find out where the PAUTO/OLITERAL nodes come from. // TODO(lvd) find out where the PAUTO/OLITERAL nodes come from.
func allocauto(ptxt *obj.Prog) { func allocauto(ptxt *obj.Prog) {
Stksize = 0 Stksize = 0
...@@ -282,22 +277,13 @@ func allocauto(ptxt *obj.Prog) { ...@@ -282,22 +277,13 @@ func allocauto(ptxt *obj.Prog) {
yyerror("stack frame too large (>2GB)") yyerror("stack frame too large (>2GB)")
} }
stkdelta[n] = -Stksize - n.Xoffset n.Xoffset = -Stksize
} }
Stksize = Rnd(Stksize, int64(Widthreg)) Stksize = Rnd(Stksize, int64(Widthreg))
stkptrsize = Rnd(stkptrsize, int64(Widthreg)) stkptrsize = Rnd(stkptrsize, int64(Widthreg))
fixautoused(ptxt) fixautoused(ptxt)
// The debug information needs accurate offsets on the symbols.
for _, ln := range Curfn.Func.Dcl {
if ln.Class != PAUTO || ln.Op != ONAME {
continue
}
ln.Xoffset += stkdelta[ln]
delete(stkdelta, ln)
}
} }
func compile(fn *Node) { func compile(fn *Node) {
......
...@@ -4374,12 +4374,13 @@ func AddAux2(a *obj.Addr, v *ssa.Value, offset int64) { ...@@ -4374,12 +4374,13 @@ func AddAux2(a *obj.Addr, v *ssa.Value, offset int64) {
a.Name = obj.NAME_PARAM a.Name = obj.NAME_PARAM
a.Node = n a.Node = n
a.Sym = Linksym(n.Orig.Sym) a.Sym = Linksym(n.Orig.Sym)
a.Offset += n.Xoffset // TODO: why do I have to add this here? I don't for auto variables. a.Offset += n.Xoffset
case *ssa.AutoSymbol: case *ssa.AutoSymbol:
n := sym.Node.(*Node) n := sym.Node.(*Node)
a.Name = obj.NAME_AUTO a.Name = obj.NAME_AUTO
a.Node = n a.Node = n
a.Sym = Linksym(n.Sym) a.Sym = Linksym(n.Sym)
// TODO: a.Offset += n.Xoffset once frame offsets for autos are computed during SSA
default: default:
v.Fatalf("aux in %s not implemented %#v", v, v.Aux) v.Fatalf("aux in %s not implemented %#v", v, v.Aux)
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment