cmd/compile: get rid of BlockCall

No need for it, we can treat calls as (mostly) normal values
that take a memory and return a memory.

Lowers the number of basic blocks needed to represent a function.
"go test -c net/http" uses 27% fewer basic blocks.
Probably doesn't affect generated code much, but should help
various passes whose running time and/or space depends on
the number of basic blocks.

Fixes #15631

Change-Id: I0bf21e123f835e2cfa382753955a4f8bce03dfa6
Reviewed-on: https://go-review.googlesource.com/28950
Run-TryBot: Keith Randall <khr@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Josh Bleecher Snyder <josharian@gmail.com>
This commit is contained in:
Keith Randall 2016-09-09 13:11:07 -07:00
parent d00a3cead8
commit c345a3913f
21 changed files with 125 additions and 87 deletions

View file

@ -698,12 +698,8 @@ func (s *regAllocState) regalloc(f *Func) {
// Initialize liveSet and uses fields for this block.
// Walk backwards through the block doing liveness analysis.
liveSet.clear()
d := int32(len(b.Values))
if b.Kind == BlockCall || b.Kind == BlockDefer {
d += unlikelyDistance
}
for _, e := range s.live[b.ID] {
s.addUse(e.ID, d+e.dist) // pseudo-uses from beyond end of block
s.addUse(e.ID, int32(len(b.Values))+e.dist) // pseudo-uses from beyond end of block
liveSet.add(e.ID)
}
if v := b.Control; v != nil && s.values[v.ID].needReg {
@ -2200,14 +2196,8 @@ func (s *regAllocState) computeLive() {
// Add len(b.Values) to adjust from end-of-block distance
// to beginning-of-block distance.
live.clear()
d := int32(len(b.Values))
if b.Kind == BlockCall || b.Kind == BlockDefer {
// Because we keep no values in registers across a call,
// make every use past a call appear very far away.
d += unlikelyDistance
}
for _, e := range s.live[b.ID] {
live.set(e.ID, e.dist+d)
live.set(e.ID, e.dist+int32(len(b.Values)))
}
// Mark control value as live
@ -2226,6 +2216,12 @@ func (s *regAllocState) computeLive() {
phis = append(phis, v)
continue
}
if opcodeTable[v.Op].call {
c := live.contents()
for i := range c {
c[i].val += unlikelyDistance
}
}
for _, a := range v.Args {
if s.values[a.ID].needReg {
live.set(a.ID, int32(i))