Skip to content

Commit 95687bf

Browse files
committed
rustc_trans: (hack) use preferred alignment for atomic loads/stores.
1 parent 753d582 commit 95687bf

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

src/librustc_trans/builder.rs

+7-2
Original file line numberDiff line numberDiff line change
@@ -544,7 +544,10 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
544544
self.count_insn("load.atomic");
545545
unsafe {
546546
let load = llvm::LLVMRustBuildAtomicLoad(self.llbuilder, ptr, noname(), order);
547-
llvm::LLVMSetAlignment(load, align.abi() as c_uint);
547+
// FIXME(eddyb) Isn't it UB to use `pref` instead of `abi` here?
548+
// However, 64-bit atomic loads on `i686-apple-darwin` appear to
549+
// require `___atomic_load` with ABI-alignment, so it's staying.
550+
llvm::LLVMSetAlignment(load, align.pref() as c_uint);
548551
load
549552
}
550553
}
@@ -605,7 +608,9 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
605608
let ptr = self.check_store(val, ptr);
606609
unsafe {
607610
let store = llvm::LLVMRustBuildAtomicStore(self.llbuilder, val, ptr, order);
608-
llvm::LLVMSetAlignment(store, align.abi() as c_uint);
611+
// FIXME(eddyb) Isn't it UB to use `pref` instead of `abi` here?
612+
// Also see `atomic_load` for more context.
613+
llvm::LLVMSetAlignment(store, align.pref() as c_uint);
609614
}
610615
}
611616

0 commit comments

Comments
 (0)