aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/compile/internal/ssa/likelyadjust.go
diff options
context:
space:
mode:
authorKeith Randall <khr@golang.org>2016-09-09 13:11:07 -0700
committerKeith Randall <khr@golang.org>2016-09-12 23:27:02 +0000
commitc345a3913f54ab88720654b3dc9b2c34779fca0c (patch)
tree239d7d98bbf92ebb07b63bcd78be8b4599bb54a0 /src/cmd/compile/internal/ssa/likelyadjust.go
parentd00a3cead8423c8af6c5781aa2a3efe0a9a442ae (diff)
downloadgo-c345a3913f54ab88720654b3dc9b2c34779fca0c.tar.gz
go-c345a3913f54ab88720654b3dc9b2c34779fca0c.zip
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>
Diffstat (limited to 'src/cmd/compile/internal/ssa/likelyadjust.go')
-rw-r--r--src/cmd/compile/internal/ssa/likelyadjust.go20
1 files changed, 17 insertions, 3 deletions
diff --git a/src/cmd/compile/internal/ssa/likelyadjust.go b/src/cmd/compile/internal/ssa/likelyadjust.go
index cb2d82f352..2c3e02bd30 100644
--- a/src/cmd/compile/internal/ssa/likelyadjust.go
+++ b/src/cmd/compile/internal/ssa/likelyadjust.go
@@ -28,7 +28,7 @@ type loop struct {
isInner bool // True if never discovered to contain a loop
// register allocation uses this.
- containsCall bool // if any block in this loop or any loop it contains is a BlockCall or BlockDefer
+ containsCall bool // if any block in this loop or any loop it contains has a call
}
// outerinner records that outer contains inner
@@ -50,8 +50,15 @@ func (l *loop) setContainsCall() {
}
func (l *loop) checkContainsCall(bb *Block) {
- if bb.Kind == BlockCall || bb.Kind == BlockDefer {
+ if bb.Kind == BlockDefer {
l.setContainsCall()
+ return
+ }
+ for _, v := range bb.Values {
+ if opcodeTable[v.Op].call {
+ l.setContainsCall()
+ return
+ }
}
}
@@ -132,7 +139,7 @@ func likelyadjust(f *Func) {
// Calls. TODO not all calls are equal, names give useful clues.
// Any name-based heuristics are only relative to other calls,
// and less influential than inferences from loop structure.
- case BlockCall, BlockDefer:
+ case BlockDefer:
local[b.ID] = blCALL
certain[b.ID] = max8(blCALL, certain[b.Succs[0].b.ID])
@@ -210,6 +217,13 @@ func likelyadjust(f *Func) {
}
}
}
+ // Look for calls in the block. If there is one, make this block unlikely.
+ for _, v := range b.Values {
+ if opcodeTable[v.Op].call {
+ local[b.ID] = blCALL
+ certain[b.ID] = max8(blCALL, certain[b.Succs[0].b.ID])
+ }
+ }
}
if f.pass.debug > 2 {
f.Config.Warnl(b.Line, "BP: Block %s, local=%s, certain=%s", b, bllikelies[local[b.ID]-blMin], bllikelies[certain[b.ID]-blMin])