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: -m output is missing escape information #32850
Comments
CC @dr2chase |
I think this is intentional. Some old messages are either redundant or misleading. As in the example, the presence of both
are confusing -- does it escape or not? (What it actually meant is that &dst does not escape at line 12, but does escape at line 21.) Also, The information is still there: Maybe the "fix" is to mention that in the release note? @aclements |
I don't think I also don't think |
No, esc.go's messages are just inconsistent and some prefix with the function name and others don't. (For regress compatibility, escape.go is similarly inconsistent, but I plan to fix this next cycle after removing esc.go.)
The current convention is that:
We used to print "escapes to heap" or "does not escape to heap" for &x expressions because they were imprecisely modeled as allocating expressions. The new algorithm models them more precisely/simply. I admit knowing where the address leaked was nice, and I spent quite a while trying to figure out how to preserve that in the new algorithm without success.
It would be easy to add additional messages to print when named variables are stack allocated. I think that would become very noisy though. |
Ok, sounds like the current output is more nuanced than I am qualified to judge.
Still, am I correct in saying that If yes, there should be something in the output about that, and If no, I must have misread the SSA and I need to redesign my API. |
Does any of the above still make this issue a |
Yes. Sorry, I meant to clarify just that bare "&dst" does not mean uninlined; it just means those diagnostics happen to not include function name.
If the inlined copy of
Your point that this isn't very intuitive though is well received. The current output isn't really designed with inlining in mind: -m output is mostly used for regress tests, and most regress tests disable inlining. It could certainly be improved. That said, I don't think this is a release blocking issue. The change in behavior was intentional. |
Yes, this is correct. But I wanted to say that I'm a little concerned that an API design relies on inlining. The inliner works heuristically, which changes over time, and it makes no guarantee about what is inlined (although we try to avoid regression in performance). Other implementations of the compiler (e.g. gccgo) may have very different inlining model. So I'm not sure it is best to have the API tied to the implementation detail of a particular compiler, or even a particular version of it. |
Seems only slices get reported as not escaping... whereas arrays never get reported.
Here t is defined as a slice, "AppendVarint32 []byte literal does not escape" |
@renthraysk That's because slice literals implicitly allocate a backing array that the compiler needs to decide whether to heap or stack allocate, whereas array literals are passed by value. |
The API works correctly regardless of the inliner. What changes are its performance properties, and in a sense every API's performance changes based on the behavior of the inliner. I don't feel like we should ignore the capabilities of the inliner in deciding on API performance tradeoffs. (If you want to continue this discussion, I suggest moving to #32670.) |
I was going to file this as an issue as well. All this information is now missing from 1.13
This information was essential for not having to guess why an escpae occurred. All we are left with in 1.13 is this
Then are are some disconnected lines of information about where the variable allocated. There is no single picture of it anymore. This makes reading the report much harder. |
@ardan-bkennedy FWIW, the lack of detailed diagnostics (e.g., -m=2) is #31489. This issue is about the -m=1 diagnostics in the presence of inlining. |
Ok, I will post a new issue then. Sorry. |
In #32670 we are considering a new API for golang.org/x/crypto/curve25519. One of the changes I'd like to introduce is not to require the caller to pre-allocate the destination. OTOH, I'd like not to introduce a heap allocation in the process.
I was hoping to be able to use the inliner to inline the variable declaration in the caller, where it has a chance not to escape. I used
-gcflags -m
to verify if it would work.In Go 1.12.6 this works as intended. Note
main &dst does not escape
.In Go +2f387ac1f3, however, a lot of information is missing from the output. Note that the
&dst escapes to heap
andmain &dst does not escape
lines are gone, along with others.Looking at the SSA it seems the inlined value still doesn't escape, but it's impossible to tell from the
-gcflags -m
output now.Marking as release-blocker to look into as a regression.
/cc @mdempsky
The text was updated successfully, but these errors were encountered: