Open
Description
The issue was discovered while looking into source of rust-lang/rust#101346.
The following Rust function:
pub fn foo() -> u32 {
let t1: u32;
let t2: u32;
unsafe {
asm!(
"mov {0:e}, 1",
"mov eax, 42",
lateout(reg) t1,
lateout("eax") t2,
options(nostack),
);
}
t1
}
Gets compiled into this obviously incorrect assembly:
example::foo:
mov eax, 1
mov eax, 42
ret
Godbolt link: https://rust.godbolt.org/z/Yb9v7WobM
LLVM incorrectly reuses register for a pair of lateout
s if it can see that one of those does not get used later.