-
Notifications
You must be signed in to change notification settings - Fork 18k
cmd/compile: explicit zeroing memory returned by newobject #19027
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
Comments
It still uses statictmp probably because CL https://go-review.googlesource.com/c/35261/ doesn't cover array? I'm working on the new write barrier insertion code for #17583 (almost ready). Along that line I have prepared some changes that will remove the explicit zeroing (given that it doesn't use statictmp). For the escape analysis, probably related to #18001? |
That explains why we were using statictmp originally. I don't understand though why s/OASWB/OAS/ would cause us to stop using statictmp though, since it's still an array literal assignment. |
Yes, that seems to be the same bug. |
I replied in your CL. |
CL https://golang.org/cl/36836 mentions this issue. |
The Zero op right after newobject has been removed. But this rule does not cover Store of constant zero (for SSA-able types). Add rules to cover Store op as well. Updates #19027. Change-Id: I5d2b62eeca0aa9ce8dc7205b264b779de01c660b Reviewed-on: https://go-review.googlesource.com/36836 Run-TryBot: Cherry Zhang <[email protected]> TryBot-Result: Gobot Gobot <[email protected]> Reviewed-by: Keith Randall <[email protected]>
@cherrymui is this fixed? If not, what remains to be done? |
I believe this is fixed. Thanks. |
Compiling this code at 249aca5:
generates a call to newobject (to heap allocate
a
) followed by code to zero it out (e.g., the call to typedmemmove).There's a couple related questions:
newobject
returns zero'd memory, so why are we still generating explicit zeroing code? Replacinga := x{}
withvar a x
eliminates the explicit zero'ing.typedmemclr
would be better for explicit zero'ing, and CL 34566 actually fixes this... except I'm not sure why. (Edit: @cherrymui pointed out why in the CL.)a
being heap allocated anyway? Shouldn't escape analysis be able to identify that (*x).m's parameters don't escape? (Edit: This appears to be cmd/compile: argument escapes when it should not #18001.)/cc @randall77 @cherrymui @josharian @aclements @dr2chase
The text was updated successfully, but these errors were encountered: