Skip to content

Commit e539461

Browse files
cuonglmgopherbot
authored andcommitted
cmd/compile: emit ODCL node for autotmp during RewriteNonNameCall
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>
1 parent a7fd2fa commit e539461

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/cmd/compile/internal/typecheck/typecheck.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -889,7 +889,7 @@ func RewriteNonNameCall(n *ir.CallExpr) {
889889

890890
tmp := Temp((*np).Type())
891891
as := ir.NewAssignStmt(base.Pos, tmp, *np)
892-
as.Def = true
892+
as.PtrInit().Append(Stmt(ir.NewDecl(n.Pos(), ir.ODCL, tmp)))
893893
*np = tmp
894894

895895
if static {

0 commit comments

Comments
 (0)