-
Notifications
You must be signed in to change notification settings - Fork 13.6k
atomicrmw on pointers: move integer-pointer cast hacks into backend #144192
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
base: master
Are you sure you want to change the base?
Conversation
rustbot has assigned @Mark-Simulacrum. Use |
This comment has been minimized.
This comment has been minimized.
Some changes occurred in compiler/rustc_codegen_gcc |
@antoyo, @GuillaumeGomez I took a wild guess with those GCC changes, please take a look. @bjorn3 this seems to somehow break cranelift, which is surprising since I thought |
3494e9c
to
a5a87d3
Compare
Some changes occurred in compiler/rustc_codegen_cranelift cc @bjorn3 |
I took a guess at what I have to do in cranelift, I hope it makes sense. |
This comment has been minimized.
This comment has been minimized.
577b7f8
to
c8c38b3
Compare
This comment has been minimized.
This comment has been minimized.
1eb3567
to
bd0cb3c
Compare
This PR modifies cc @jieyouxu |
@@ -35,51 +35,62 @@ impl<T: ?Sized> Copy for *mut T {} | |||
impl ConstParamTy for AtomicOrdering {} | |||
|
|||
#[cfg(target_has_atomic = "8")] | |||
#[unsafe(no_mangle)] // let's make sure we actually generate a symbol to check |
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 test might actually have been ineffective ever since we gained that heuristic that automatically marks small functions as #[inline]
.
☔ The latest upstream changes (presumably #144249) made this pull request unmergeable. Please resolve the merge conflicts. |
r? @nikic |
Conceptually, we want to have atomic operations on pointers of the form
fn atomic_add(ptr: *mut T, offset: usize, ...)
. However, LLVM does not directly support such operations (llvm/llvm-project#120837), so we have to cast theoffset
to a pointer somewhere.This PR moves that hack into the LLVM backend, so that the standard library, intrinsic, and Miri all work with the conceptual operation we actually want. Hopefully, one day LLVM will gain a way to represent these operations without integer-pointer casts, and then the hack will disappear entirely.
Cc @nikic -- this is the best we can do right now, right?
Fixes #134617