Join GitHub today
GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.Sign up
cmd/compile: ephemeral slicing doesn't need protection against next object pointers #15397
We compile this to something like (bounds checks omitted):
Unfortunately, I don't see an easy way to do this optimization in the current compiler. Marked as unplanned.
If you can ensure the out-of-bounds pointer won't be live for more than an instruction or two, it might be okay to mark those as unsafe points. We're absolutely going to need unsafe points for the write barrier, but I've been working on removing them from other compiler constructs (like range loops).