-
Notifications
You must be signed in to change notification settings - Fork 12.8k
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
Set max_atomic_width for AVR to 16 #114495
Conversation
These commits modify compiler targets. |
The generated code disables interrupts, which doesn't seem like an operation that should happen implicitly to me. Do any other LLVM targets do this? AVR has an 8-bit data bus, so it can't support anything beyond 8-bit atomics in hardware. |
AFAIK, AVR has no unprivileged mode and is always single-core, so the atomic implementation by disabling interrupts is always valid. (The situation differs somewhat from ARM and RISC-V, which have unprivileged modes.) That said, I'm open to discarding this PR if it is considered that the compiler should not implicitly generate code to disable interrupts to implement atomics, regardless of the architecture.
AFAIK, it is only AVR. (However, I think atomic RMW on MSP430 possibly be implemented in the same way in the future, aside from whether the LLVM should do it.)
Yeah, we cannot implement 16-bit atomic on AVR without disabling interrupts (or guaranteeing atomicity in an environment-specific way). Although LLVM doesn't seem to consider 8-bit load/store instructions to be atomic either (that may be a bug, but they disable interrupts for both 8-bit and 16-bit atomic load/store). |
@bors r+ |
…iaskrgr Rollup of 9 pull requests Successful merges: - rust-lang#113568 (Fix spurious test failure with `panic=abort`) - rust-lang#114196 (Bubble up nested goals from equation in `predicates_for_object_candidate`) - rust-lang#114485 (Add trait decls to SMIR) - rust-lang#114495 (Set max_atomic_width for AVR to 16) - rust-lang#114496 (Set max_atomic_width for sparc-unknown-linux-gnu to 32) - rust-lang#114510 (llvm-wrapper: adapt for LLVM API changes) - rust-lang#114562 (stabilize abi_thiscall) - rust-lang#114570 ([miri][typo] Fix a typo in a vector_block comment.) - rust-lang#114573 (CI: do not hide error logs in a group) r? `@ghost` `@rustbot` modify labels: rollup
This is currently set to 0
rust/compiler/rustc_target/src/spec/avr_gnu_base.rs
Lines 26 to 27 in 90f0b24
However, LLVM supports {8,16}-bit atomic load/store on AVR (support for RMW is still quite incomplete and only partially supported).
https://github.com/llvm/llvm-project/blob/llvmorg-15.0.0/llvm/test/CodeGen/AVR/atomics/load8.ll#L5-L13
https://github.com/llvm/llvm-project/blob/llvmorg-15.0.0/llvm/test/CodeGen/AVR/atomics/load16.ll#L3-L12
https://github.com/llvm/llvm-project/blob/llvmorg-15.0.0/llvm/test/CodeGen/AVR/atomics/store.ll#L3-L22
cc #99668
r? @Amanieu