]> Cypherpunks repositories - gostls13.git/commit
cmd/compile: emit ODCL node for autotmp during RewriteNonNameCall
authorCuong Manh Le <cuong.manhle.vn@gmail.com>
Thu, 22 Dec 2022 20:37:43 +0000 (03:37 +0700)
committerGopher Robot <gobot@golang.org>
Fri, 31 Mar 2023 18:41:12 +0000 (18:41 +0000)
commite539461e34b1c5163220f9910b2c0360fb9f21e4
treed4627470225e96942ef15cbe11e07d8152d3fab8
parenta7fd2fab0e865f7fcedd3b437f1fa6e958bacc61
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>
src/cmd/compile/internal/typecheck/typecheck.go