• Hugues Bruant's avatar
    cmd/compile: inline calls to local closures · 4f70a2a6
    Hugues Bruant authored
    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: 's avatarHugues Bruant <hugues.bruant@gmail.com>
    Reviewed-by: 's avatarKeith Randall <khr@golang.org>
    4f70a2a6
inline.go 3.09 KB