]> Cypherpunks repositories - gostls13.git/commit
cmd/compile: inline calls to local closures
authorHugues Bruant <hugues.bruant@gmail.com>
Mon, 18 Sep 2017 21:54:10 +0000 (14:54 -0700)
committerDaniel Martí <mvdan@mvdan.cc>
Wed, 11 Oct 2017 22:32:36 +0000 (22:32 +0000)
commit4f70a2a699d23bb47eae36c5170086688d2fa764
treed764c2417d55ecf69bd8ae20822e9c5fafff9893
parent44d9e96da9b7625be81f2c7eacf73fcc609874ce
cmd/compile: inline calls to local closures

Calls to a closure held in a local, non-escaping,
variable can be inlined, provided the closure body
can be inlined and the variable is never written to.

The current implementation has the following limitations:

 - closures with captured variables are not inlined because
   doing so naively triggers invariant violation in the SSA
   phase
 - re-assignment check is currently approximated by checking
   the Addrtaken property of the variable which should be safe
   but may miss optimization opportunities if the address is
   not used for a write before the invocation

Updates #15561

Change-Id: I508cad5d28f027bd7e933b1f793c14dcfef8b5a1
Reviewed-on: https://go-review.googlesource.com/65071
Run-TryBot: Daniel Martí <mvdan@mvdan.cc>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Hugues Bruant <hugues.bruant@gmail.com>
Reviewed-by: Keith Randall <khr@golang.org>
src/cmd/compile/internal/gc/bitset.go
src/cmd/compile/internal/gc/inl.go
src/cmd/compile/internal/gc/syntax.go
test/escape4.go
test/inline.go