-
Notifications
You must be signed in to change notification settings - Fork 13.4k
trans: always use a memcpy for ABI argument/return casts. #34141
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
r? @nrc (rust_highfive has picked a reviewer for you, use r? to override) |
|
||
// We instead thus allocate some scratch space... | ||
let llscratch = AllocaFcx(bcx.fcx(), ty, "abi_cast"); | ||
base::Lifetime::End.call(bcx, llscratch); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
shouldn't this be lifetime start?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oops...
@bors r+ p=1 |
📌 Commit 2e68f31 has been approved by |
I'm inclined to beta-accept -- thoughts from @rust-lang/compiler team? |
I’m fine with it. My fix wasn’t supposed to be more than a short-term quick-hack anyway (for certain time-pressing reasons like trains rolling over the next day). EDIT: or rather, please do accept it. |
📌 Commit 0d145c9 has been approved by |
+1 on the backport |
}) | ||
impl Lifetime { | ||
pub fn call(self, b: &Builder, ptr: ValueRef) { | ||
core_lifetime_emit(b.ccx, ptr, Lifetime::Start, |ccx, size, lifetime_intrinsic| { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this needs to be self
instead of Lifetime::Start
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I... wrote this twice. It was fine the first time :/.
Yep, that's much closer (not sure if 100% the same) to what I had in mind. Sorry for not getting that done myself earlier and causing some unnecessary churn :-/ That should also be useful for the outstanding transmute fix of mine that's still missing its MIR part. Nice! |
@bors r=nikomatsakis |
📌 Commit d9f93b9 has been approved by |
⌛ Testing commit d9f93b9 with merge ab5b316... |
💔 Test failed - auto-win-gnu-32-opt-rustbuild |
Real failure:
Difference: |
@arielb1 Who needs 32-bit anyway /s. |
@bors r=nikomatsakis |
📌 Commit e252865 has been approved by |
trans: always use a memcpy for ABI argument/return casts. When storing incoming arguments or values returned by call/invoke, always do a `memcpy` from a temporary of the cast type, if there is an ABI cast. While Clang has gotten smarter ([store](https://godbolt.org/g/EphFuK) vs [memcpy](https://godbolt.org/g/5dikH9)), a `memcpy` will always work. This is what @dotdash has wanted to do all along, and it fixes #32049.
When storing incoming arguments or values returned by call/invoke, always do a
memcpy
from a temporary of the cast type, if there is an ABI cast.While Clang has gotten smarter (store vs memcpy), a
memcpy
will always work.This is what @dotdash has wanted to do all along, and it fixes #32049.