mirror of
https://github.com/rust-lang/rust
synced 2024-10-19 15:03:55 +00:00
Rollup merge of #93868 - Amanieu:asm_reg_conflict, r=cjgillot
Fix incorrect register conflict detection in asm! This would previously incorrectly reject two subregisters that were distinct but part of the same larger register, for example `al` and `ah`.
This commit is contained in:
commit
db7124839c
|
@ -373,7 +373,9 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
|
||||||
err.emit();
|
err.emit();
|
||||||
}
|
}
|
||||||
Entry::Vacant(v) => {
|
Entry::Vacant(v) => {
|
||||||
v.insert(idx);
|
if r == reg {
|
||||||
|
v.insert(idx);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
20
src/test/ui/asm/reg-conflict.rs
Normal file
20
src/test/ui/asm/reg-conflict.rs
Normal file
|
@ -0,0 +1,20 @@
|
||||||
|
// compile-flags: --target armv7-unknown-linux-gnueabihf
|
||||||
|
// needs-llvm-components: arm
|
||||||
|
|
||||||
|
#![feature(no_core, lang_items, rustc_attrs)]
|
||||||
|
#![no_core]
|
||||||
|
|
||||||
|
#[rustc_builtin_macro]
|
||||||
|
macro_rules! asm {
|
||||||
|
() => {};
|
||||||
|
}
|
||||||
|
#[lang = "sized"]
|
||||||
|
trait Sized {}
|
||||||
|
|
||||||
|
fn main() {
|
||||||
|
unsafe {
|
||||||
|
asm!("", out("d0") _, out("d1") _);
|
||||||
|
asm!("", out("d0") _, out("s1") _);
|
||||||
|
//~^ ERROR register `s1` conflicts with register `d0`
|
||||||
|
}
|
||||||
|
}
|
10
src/test/ui/asm/reg-conflict.stderr
Normal file
10
src/test/ui/asm/reg-conflict.stderr
Normal file
|
@ -0,0 +1,10 @@
|
||||||
|
error: register `s1` conflicts with register `d0`
|
||||||
|
--> $DIR/reg-conflict.rs:17:31
|
||||||
|
|
|
||||||
|
LL | asm!("", out("d0") _, out("s1") _);
|
||||||
|
| ----------- ^^^^^^^^^^^ register `s1`
|
||||||
|
| |
|
||||||
|
| register `d0`
|
||||||
|
|
||||||
|
error: aborting due to previous error
|
||||||
|
|
Loading…
Reference in a new issue