-
Notifications
You must be signed in to change notification settings - Fork 289
Document #[repr(u8)] enum
to enable LLVM optimizations
#8
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Conversation
This is a bit unclear to me as written. I would maybe zoom out from LLVM a bit and focus on the ABI implications of C-like enums: it will be treated as an integer, and not a struct-containing-an-integer. CC @mystor |
Oh, hm, is a |
It might also be good to note that controlling the |
OK, I've rewritten it to take the above comments into account. This has drifted a fair bit from my original subject; the specific optimization LLVM does with |
This seems like a silly guarantee to make, since they should not be treated as a one-member struct for ABI purposes.
Again, why are we guaranteeing this? The null pointer optimization inhibition, sure, but otherwise this seems like it should mostly be deleted. |
I have no idea what's right here... |
I generally agree with @ubsan That any properties of |
Agreed, the only property of repr(rust) that's guaranteed is that |
Great. @geofft care to make these changes? |
Oh yeah, good points about not documenting the exact properties of I've updated the pull request. This doesn't seem like the right area to discuss |
Let's |
See rust-lang/rust#27303 and rust-lang/libc#48 for discussion of the
optimization, or just try compiling
unsafe {free(malloc(16))}
with variousRust definitions of
void *
in the FFI binding.