aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/compile/internal/ssa/deadcode.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/deadcode.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/deadcode.go')
-rw-r--r--src/cmd/compile/internal/ssa/deadcode.go7
1 files changed, 7 insertions, 0 deletions
diff --git a/src/cmd/compile/internal/ssa/deadcode.go b/src/cmd/compile/internal/ssa/deadcode.go
index 5ccf39027f..5a83e2342d 100644
--- a/src/cmd/compile/internal/ssa/deadcode.go
+++ b/src/cmd/compile/internal/ssa/deadcode.go
@@ -54,6 +54,7 @@ func liveValues(f *Func, reachable []bool) []bool {
var q []*Value // stack-like worklist of unscanned values
// Starting set: all control values of reachable blocks are live.
+ // Calls are live (because callee can observe the memory state).
for _, b := range f.Blocks {
if !reachable[b.ID] {
continue
@@ -62,6 +63,12 @@ func liveValues(f *Func, reachable []bool) []bool {
live[v.ID] = true
q = append(q, v)
}
+ for _, v := range b.Values {
+ if opcodeTable[v.Op].call && !live[v.ID] {
+ live[v.ID] = true
+ q = append(q, v)
+ }
+ }
}
// Compute transitive closure of live values.