-
Notifications
You must be signed in to change notification settings - Fork 18k
cmd/compile: liveness too conservative for variables declared in loop body #7602
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
Labels
Milestone
Comments
Related to issue #7345. |
Owner changed to @rsc. |
It looks okay to me now. I get: x.go:5: live at entry to g: p x.go:10: live at call to GC: x x.go:12: live at call to g: x x.go:10: main: x (type *int) is ambiguously live I don't know if the ambiguously live print was included in the ... in your output or not. If not, that was a bug. But it's there now. In this program, x is not a temporary. Real temporaries are killed aggressively and do not exhibit this behavior (anymore). In particular, the automatic ... arguments in a log.Printf call are killed at the end of the log.Printf statement, before the loop goes around again. I agree that it would be nice to do a little better here. It might be possible with the current analysis: the fact that x is marked EscNone (in particular, not EscHeap) means that it does not escape ouside the loop iteration, so we could emit a varkill for it at the end of the loop body in which it is declared. The order.c pass could push declared variables onto a different stack and then pop+clean them whenever the loopdepth went down. In practice, this seems not to come up very often. There are only 18 ambiguously live non-temps when compiling godoc; it looks like a couple would be addressed by this. A few more are the if statement equivalent, but we don't have a 'scopedepth' analogous to loopdepth so that would be even more work. For such few variables, I think we can punt this to a future release. Labels changed: added release-go1.4, removed release-go1.3. |
This doesn't seem to be an issue anymore. |
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
The text was updated successfully, but these errors were encountered: