For f()() call, the compiler rewrite it roughly to:
autotmp := f()
autotmp()
However, if f() were inlined, escape analysis will confuse about the
lifetime of autotmp, leading to bad escaping decision.
This CL fixes this issue by rewriting f()() to:
var autotmp
autotmp = f()
autotmp()
This problem also happens with Unified IR, until CL 421821 land.
Fixes #57434
Change-Id: I159a7e4c93bbc172f0eae60e7d40fc64ba70b236
Reviewed-on: https://go-review.googlesource.com/c/go/+/459295
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Auto-Submit: Cuong Manh Le <cuong.manhle.vn@gmail.com>
tmp := Temp((*np).Type())
as := ir.NewAssignStmt(base.Pos, tmp, *np)
- as.Def = true
+ as.PtrInit().Append(Stmt(ir.NewDecl(n.Pos(), ir.ODCL, tmp)))
*np = tmp
if static {