New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
cmd/compile: escape analysis loopdepth should reset when blocks end #22438
Comments
A variation on the issue is:
This is trickier though, because we flatten blocks in the Node tree representation, so the above is indistinguishable from:
(Which also really needn't escape, but requires more sophisticated control flow analysis.) |
CC @dr2chase |
It seems aggressive to make this a milestone before we even have a non-test example of a loop made from a goto. |
The milestone is to set a point by which we should make progress. If you want to make progress by changing the milestone to unplanned, that is fine. |
Milestone set to unplanned, lacking any performance problem in "real" code caused by this shortfall (which would be a bit of a pain to fix since the tree-based analyses lack structural loop detectors). |
Change https://golang.org/cl/193517 mentions this issue: |
Add block method to preserve loop depth when evaluating statements in a block, so escape analysis can handle looping label more precisely. Updates #22438 Change-Id: I39b306544a6c0ee3fcbebbe0d0ee735cb71773e6 Reviewed-on: https://go-review.googlesource.com/c/go/+/193517 Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Compiling the package below with compile -m shows that
new(int)
escapes to heap:After replacing
x: goto x
withfor {}
, it no longer escapes.The issue is
x
is considered a looping label, so(*EscState).esc
incrementse.loopdepth
when visiting it. However, loopdepth is never decremented again at the end of its enclosing block, so loopdepth is still incremented when visiting thep = new(int)
assignment.The text was updated successfully, but these errors were encountered: