-
Notifications
You must be signed in to change notification settings - Fork 18k
cmd/compile: inline slicebytetostringtmp when !instrumenting #17044
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
I like it. Seems like a solid, easy win. cc @martisch |
Interestingly i had been working on optimizing runtime.intstring this week (which uses slicebytetostringtmp) and had a similar thought for lowering this too :) Will work to implement it and it fits nicely with other CLs i work on for runtime string/rune . |
I started a CL to do the lowering in the backend when not instrumenting as it is more direct than expressing _(_string)(unsafe.Pointer(&b)) in the frontend and then hope the ssa optimizations figure out that indirections are not needed. Can we let the frontend generate code to use the runtime function when ssaEnabled is not true since the non-ssa backend is likely to be removed for 1.8 anyway or would that be a violation of the separation between the stages? OARRAYBYTESTRTMP does not sound like a good name to me. Something like OSLICEBYTETOSTRTMP or OSLICEBYTETOSTRNOCOPY might be better? Later sounds more universal and can be used for all kinds of mappings in the compiler which we deem save and where we keep either byteslice or str around afterwards. Other string functions (e.g. stringtoslicebytetmp) seem to be also good candidates to be handled directly by either frontend or backend instead of a runtime function. |
CL https://golang.org/cl/29017 mentions this issue. |
It might take a bit of work to get ssaEnabled available earlier in the compiler. We've resisted doing this so far, in part to make it easier for people working on the migration. However, maybe it's time. Then we could start now on eliminating bits of the mid-tier in a way that'd be easy to cope with when the old backend is gone for good. Thoughts, @randall77?
In very old versions of the compiler, there were no slices in Go yet, only arrays. Slices were clearly then hacked in as array variants. We've been slowly cleaning that up ever since (only last week I separated OSLICELIT from OARRAYLIT). So yeah, we should do a bunch of renaming at some point. Still sitting in my pile of unmailed CLs:
and
SGTM |
I'd rather avoid backend-dependent phases in the frontend. It will lead to very confusing code. I'd rather wait until the old backend is deleted and then do it unconditionally. |
slicebytetostringtmp just reinterprets a []byte as a string, with some extra logic for tsan/msan. When we're in !instrumenting mode though, the compiler could trivially do this itself without the function call overhead.
The text was updated successfully, but these errors were encountered: