about summary refs log tree commit diff
diff options
context:
space:
mode:
authorAmanieu d'Antras <amanieu@gmail.com>2022-02-19 21:46:49 +0000
committerAmanieu d'Antras <amanieu@gmail.com>2022-02-21 18:28:22 +0000
commitfb5539b475586c31e6e51f252dae1559343b2be7 (patch)
tree387b8a57f5f50421b6d8950a3b4a214eba74dbd4
parentfc41d4bf351b9c39aac58b7d0e307495ddf60dfc (diff)
downloadrust-fb5539b475586c31e6e51f252dae1559343b2be7.tar.gz
rust-fb5539b475586c31e6e51f252dae1559343b2be7.zip
Add tests
-rw-r--r--compiler/rustc_target/src/asm/riscv.rs2
-rw-r--r--compiler/rustc_target/src/asm/x86.rs2
-rw-r--r--src/test/ui/asm/issue-85247.rs26
-rw-r--r--src/test/ui/asm/issue-85247.rwpi.stderr8
-rw-r--r--src/test/ui/asm/issue-92378.rs30
5 files changed, 66 insertions, 2 deletions
diff --git a/compiler/rustc_target/src/asm/riscv.rs b/compiler/rustc_target/src/asm/riscv.rs
index 65ce69cb5c0..987bf970529 100644
--- a/compiler/rustc_target/src/asm/riscv.rs
+++ b/compiler/rustc_target/src/asm/riscv.rs
@@ -1,5 +1,5 @@
 use super::{InlineAsmArch, InlineAsmType};
-use crate::spec::{Target, RelocModel};
+use crate::spec::{RelocModel, Target};
 use rustc_data_structures::stable_set::FxHashSet;
 use rustc_macros::HashStable_Generic;
 use rustc_span::{sym, Symbol};
diff --git a/compiler/rustc_target/src/asm/x86.rs b/compiler/rustc_target/src/asm/x86.rs
index ac6f39f1c95..7c136a47548 100644
--- a/compiler/rustc_target/src/asm/x86.rs
+++ b/compiler/rustc_target/src/asm/x86.rs
@@ -1,5 +1,5 @@
 use super::{InlineAsmArch, InlineAsmType};
-use crate::spec::{Target, RelocModel};
+use crate::spec::{RelocModel, Target};
 use rustc_data_structures::stable_set::FxHashSet;
 use rustc_macros::HashStable_Generic;
 use rustc_span::Symbol;
diff --git a/src/test/ui/asm/issue-85247.rs b/src/test/ui/asm/issue-85247.rs
new file mode 100644
index 00000000000..e64f5e8af52
--- /dev/null
+++ b/src/test/ui/asm/issue-85247.rs
@@ -0,0 +1,26 @@
+// revisions: ropi rwpi
+
+// [ropi] compile-flags: --target armv7-unknown-linux-gnueabihf -C relocation-model=ropi
+// [rwpi] compile-flags: --target armv7-unknown-linux-gnueabihf -C relocation-model=rwpi
+// [ropi] needs-llvm-components: arm
+// [rwpi] needs-llvm-components: arm
+// [ropi] build-pass
+
+#![feature(no_core, lang_items, rustc_attrs)]
+#![no_core]
+#![crate_type = "rlib"]
+
+#[rustc_builtin_macro]
+macro_rules! asm {
+    () => {};
+}
+#[lang = "sized"]
+trait Sized {}
+
+// R9 is reserved as the RWPI base register
+fn main() {
+    unsafe {
+        asm!("", out("r9") _);
+        //[rwpi]~^ cannot use register `r9`
+    }
+}
diff --git a/src/test/ui/asm/issue-85247.rwpi.stderr b/src/test/ui/asm/issue-85247.rwpi.stderr
new file mode 100644
index 00000000000..996b0933a34
--- /dev/null
+++ b/src/test/ui/asm/issue-85247.rwpi.stderr
@@ -0,0 +1,8 @@
+error: cannot use register `r9`: the RWPI static base register (r9) cannot be used as an operand for inline asm
+  --> $DIR/issue-85247.rs:23:18
+   |
+LL |         asm!("", out("r9") _);
+   |                  ^^^^^^^^^^^
+
+error: aborting due to previous error
+
diff --git a/src/test/ui/asm/issue-92378.rs b/src/test/ui/asm/issue-92378.rs
new file mode 100644
index 00000000000..d595e88ff80
--- /dev/null
+++ b/src/test/ui/asm/issue-92378.rs
@@ -0,0 +1,30 @@
+// compile-flags: --target armv5te-unknown-linux-gnueabi
+// needs-llvm-components: arm
+// build-pass
+
+#![feature(no_core, lang_items, rustc_attrs, isa_attribute)]
+#![no_core]
+#![crate_type = "rlib"]
+
+#[rustc_builtin_macro]
+macro_rules! asm {
+    () => {};
+}
+#[lang = "sized"]
+trait Sized {}
+
+// ARM uses R11 for the frame pointer, make sure R7 is usable.
+#[instruction_set(arm::a32)]
+pub fn arm() {
+    unsafe {
+        asm!("", out("r7") _);
+    }
+}
+
+// Thumb uses R7 for the frame pointer, make sure R11 is usable.
+#[instruction_set(arm::t32)]
+pub fn thumb() {
+    unsafe {
+        asm!("", out("r11") _);
+    }
+}