-
Notifications
You must be signed in to change notification settings - Fork 13.6k
Closed
Labels
A-docsArea: Documentation for any part of the project, including the compiler, standard library, and toolsArea: Documentation for any part of the project, including the compiler, standard library, and toolsA-inline-assemblyArea: Inline assembly (`asm!(…)`)Area: Inline assembly (`asm!(…)`)C-bugCategory: This is a bug.Category: This is a bug.O-AVRTarget: AVR processors (ATtiny, ATmega, etc.)Target: AVR processors (ATtiny, ATmega, etc.)llvm-fixed-upstreamIssue expected to be fixed by the next major LLVM upgrade, or backported fixesIssue expected to be fixed by the next major LLVM upgrade, or backported fixes
Description
AVR assembler instruction ldd
is defined only for registers Y
and Z
, but not for X
.
asm!()
macro accepts it.
I tried this code:
#[no_mangle]
extern "C" fn main() {
unsafe {
::core::arch::asm!("
ldd {tmp}, X+0
ldd {tmp}, X+1
",
tmp = out(reg) _,
in("X") &0xAABB_u16,
);
}
}
I expected to see this happen: compilation error.
Instead, this happened: rustc produces a binary with a corrupted code.
000000a6 <main>:
a6: a0 e0 ldi r26, 0x00 ; 0
a8: b1 e0 ldi r27, 0x01 ; 1
aa: 88 81 ld r24, Y
ac: 89 81 ldd r24, Y+1 ; 0x01
ae: 08 95 ret
Pointer (0x0100) to a value is loaded into register X
(r26:r27
) following by reads from *Y
.
Meta
rustc --version --verbose
:
rustc 1.70.0-nightly (22f247c6f 2023-03-13)
binary: rustc
commit-hash: 22f247c6f3ed388cb702d01c2ff27da658a8b353
commit-date: 2023-03-13
host: x86_64-unknown-linux-gnu
release: 1.70.0-nightly
LLVM version: 15.0.7
Steps to reproduce:
repo: https://github.com/Slickis/rustc-ldd-x
git clone https://github.com/Slickis/rustc-ldd-x
cd rustc-ldd-x
make lss
Metadata
Metadata
Assignees
Labels
A-docsArea: Documentation for any part of the project, including the compiler, standard library, and toolsArea: Documentation for any part of the project, including the compiler, standard library, and toolsA-inline-assemblyArea: Inline assembly (`asm!(…)`)Area: Inline assembly (`asm!(…)`)C-bugCategory: This is a bug.Category: This is a bug.O-AVRTarget: AVR processors (ATtiny, ATmega, etc.)Target: AVR processors (ATtiny, ATmega, etc.)llvm-fixed-upstreamIssue expected to be fixed by the next major LLVM upgrade, or backported fixesIssue expected to be fixed by the next major LLVM upgrade, or backported fixes