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
Tracking Issue for allowing zero-sized memory accesses and offsets #117945
Comments
cg_clif accepts ZST memory accesses and pointer offsets already. Pointer offsets are implemented as integer addition which doesn't have UB and ZST memory accesses never get turned into loads and stores in cranelift ir as there is no instruction that does so. |
Besides direct accesses, the other concerns are the copy, write_bytes, compare_bytes intrinsics. Those must be implemented in a way that they are not UB when |
They are implemented by calling the respective libc functions which LLVM already expects to accept 0-sized accesses, right? |
GCC codegen might also need updating, Cc @antoyo @GuillaumeGomez |
Well what LLVM assumes doesn't matter for the cranelift backend, does it? ;) But more importantly, Rust explicitly assumes this itself as documented here. |
No problem. Please ping us when we need to update our part and thanks for the ping! |
Well I'm asking you if you need to update anything. :) You need to make sure that the I think zero-sized memory accesses disappear in the SSA codegen infrastructure before your backend even sees them so they should be fine. And finally the |
These intrinsics are implemented by calling the GCC builtin functions: memcmp, memset, memcpy, memmove. |
Okay, something needs to change then in the backend because we'll allow null pointers for the Rust intrinsics. |
I updated #117329 to make it ready to land. @rust-lang/opsem to address this concern, I made |
This issue tracks implementing the t-opsem decision in rust-lang/unsafe-code-guidelines#472. This will require adjustments in many places (codegen, Miri, library docs, reference, ...). The intention is to track here what needs to be done until the transition is complete.
2024-04-17: The current status is that this is blocked on t-lang discussing #117329.
Implementation history
The text was updated successfully, but these errors were encountered: