about summary refs log tree commit diff
path: root/compiler/rustc_codegen_llvm/src/builder.rs
diff options
context:
space:
mode:
authorBen Kimock <kimockb@gmail.com>2024-03-08 21:50:23 -0500
committerBen Kimock <kimockb@gmail.com>2024-03-09 10:08:53 -0500
commitaa6cfb2669e51b3211017bde2faa6eddba22ecbe (patch)
treee8c0dbef790c1e0c02dfa0ca2aa0487f2a836ef9 /compiler/rustc_codegen_llvm/src/builder.rs
parent42825768b103c28b10ce0407749acb21d32abeec (diff)
downloadrust-aa6cfb2669e51b3211017bde2faa6eddba22ecbe.tar.gz
rust-aa6cfb2669e51b3211017bde2faa6eddba22ecbe.zip
Sink ptrtoint for RMW ops on pointers to cg_llvm
Diffstat (limited to 'compiler/rustc_codegen_llvm/src/builder.rs')
-rw-r--r--compiler/rustc_codegen_llvm/src/builder.rs8
1 files changed, 7 insertions, 1 deletions
diff --git a/compiler/rustc_codegen_llvm/src/builder.rs b/compiler/rustc_codegen_llvm/src/builder.rs
index ca2e2b57580..63e59ea13fc 100644
--- a/compiler/rustc_codegen_llvm/src/builder.rs
+++ b/compiler/rustc_codegen_llvm/src/builder.rs
@@ -1132,9 +1132,15 @@ impl<'a, 'll, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'll, 'tcx> {
         &mut self,
         op: rustc_codegen_ssa::common::AtomicRmwBinOp,
         dst: &'ll Value,
-        src: &'ll Value,
+        mut src: &'ll Value,
         order: rustc_codegen_ssa::common::AtomicOrdering,
     ) -> &'ll Value {
+        // The only RMW operation that LLVM supports on pointers is compare-exchange.
+        if self.val_ty(src) == self.type_ptr()
+            && op != rustc_codegen_ssa::common::AtomicRmwBinOp::AtomicXchg
+        {
+            src = self.ptrtoint(src, self.type_isize());
+        }
         unsafe {
             llvm::LLVMBuildAtomicRMW(
                 self.llbuilder,