about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--src/librustc_trans/builder.rs9
1 files changed, 7 insertions, 2 deletions
diff --git a/src/librustc_trans/builder.rs b/src/librustc_trans/builder.rs
index 9da3a479f0c..592a6d91475 100644
--- a/src/librustc_trans/builder.rs
+++ b/src/librustc_trans/builder.rs
@@ -544,7 +544,10 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
         self.count_insn("load.atomic");
         unsafe {
             let load = llvm::LLVMRustBuildAtomicLoad(self.llbuilder, ptr, noname(), order);
-            llvm::LLVMSetAlignment(load, align.abi() as c_uint);
+            // FIXME(eddyb) Isn't it UB to use `pref` instead of `abi` here?
+            // However, 64-bit atomic loads on `i686-apple-darwin` appear to
+            // require `___atomic_load` with ABI-alignment, so it's staying.
+            llvm::LLVMSetAlignment(load, align.pref() as c_uint);
             load
         }
     }
@@ -605,7 +608,9 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
         let ptr = self.check_store(val, ptr);
         unsafe {
             let store = llvm::LLVMRustBuildAtomicStore(self.llbuilder, val, ptr, order);
-            llvm::LLVMSetAlignment(store, align.abi() as c_uint);
+            // FIXME(eddyb) Isn't it UB to use `pref` instead of `abi` here?
+            // Also see `atomic_load` for more context.
+            llvm::LLVMSetAlignment(store, align.pref() as c_uint);
         }
     }