Skip to content

Commit 20bd0c3

Browse files
committedJun 21, 2022
Re-enable atomic loads and stores for all RISC-V targets
This roughly reverts PR #66548 Atomic "CAS" are still disabled for targets without the *“A” Standard Extension for Atomic Instructions*. However this extension only adds instructions for operations more complex than simple loads and stores, which are always atomic when aligned. In the [Unprivileged Spec v. 20191213](https://riscv.org/technical/specifications/) section 2.6 *Load and Store Instructions* of chapter 2 *RV32I Base Integer Instruction Set* (emphasis mine): > Even when misaligned loads and stores complete successfully, > these accesses might run extremely slowly depending on the implementation > (e.g., when implemented via an invisible trap). Further-more, whereas > **naturally aligned loads and stores are guaranteed to execute atomically**, > misaligned loads and stores might not, and hence require > additional synchronization to ensure atomicity. Unfortunately PR #66548 did not provide much details on the bug that motivated it, but #66240 and #85736 appear related and happen with targets that do have the A extension.
1 parent abace0a commit 20bd0c3

File tree

3 files changed

+3
-3
lines changed

3 files changed

+3
-3
lines changed
 

‎compiler/rustc_target/src/spec/riscv32i_unknown_none_elf.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ pub fn target() -> Target {
1212
linker_flavor: LinkerFlavor::Lld(LldFlavor::Ld),
1313
linker: Some("rust-lld".into()),
1414
cpu: "generic-rv32".into(),
15-
max_atomic_width: Some(0),
15+
max_atomic_width: Some(32),
1616
atomic_cas: false,
1717
executables: true,
1818
panic_strategy: PanicStrategy::Abort,

‎compiler/rustc_target/src/spec/riscv32im_unknown_none_elf.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ pub fn target() -> Target {
1212
linker_flavor: LinkerFlavor::Lld(LldFlavor::Ld),
1313
linker: Some("rust-lld".into()),
1414
cpu: "generic-rv32".into(),
15-
max_atomic_width: Some(0),
15+
max_atomic_width: Some(32),
1616
atomic_cas: false,
1717
features: "+m".into(),
1818
executables: true,

‎compiler/rustc_target/src/spec/riscv32imc_unknown_none_elf.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ pub fn target() -> Target {
1212
linker_flavor: LinkerFlavor::Lld(LldFlavor::Ld),
1313
linker: Some("rust-lld".into()),
1414
cpu: "generic-rv32".into(),
15-
max_atomic_width: Some(0),
15+
max_atomic_width: Some(32),
1616
atomic_cas: false,
1717
features: "+m,+c".into(),
1818
executables: true,

0 commit comments

Comments
 (0)
Please sign in to comment.