about summary refs log tree commit diff
path: root/src/test/assembly
diff options
context:
space:
mode:
authorJosh Stone <jistone@redhat.com>2022-09-29 19:13:30 -0700
committerJosh Stone <jistone@redhat.com>2022-09-29 19:49:23 -0700
commited9e6f2ad82a9ad783ed89b937d2951e44b6ce4b (patch)
tree7967f1b6edc80c2a305f4322ed71407302064b03 /src/test/assembly
parent1bb8d276c94c77a5fada815c5fad3b8d324adac4 (diff)
Enable inline stack probes on X86 with LLVM 16
Diffstat (limited to 'src/test/assembly')
-rw-r--r--src/test/assembly/x86-stack-probes.rs42
1 files changed, 42 insertions, 0 deletions
diff --git a/src/test/assembly/x86-stack-probes.rs b/src/test/assembly/x86-stack-probes.rs
new file mode 100644
index 00000000000..c7141fb208a
--- /dev/null
+++ b/src/test/assembly/x86-stack-probes.rs
@@ -0,0 +1,42 @@
+// min-llvm-version: 16
+// revisions: x86_64 i686
+// assembly-output: emit-asm
+//[x86_64] compile-flags: --target x86_64-unknown-linux-gnu
+//[x86_64] needs-llvm-components: x86
+//[i686] compile-flags: --target i686-unknown-linux-gnu
+//[i686] needs-llvm-components: x86
+// compile-flags: -C llvm-args=-x86-asm-syntax=intel
+
+#![feature(no_core, lang_items)]
+#![crate_type = "lib"]
+#![no_core]
+
+#[lang = "sized"]
+trait Sized {}
+#[lang = "copy"]
+trait Copy {}
+
+impl Copy for u8 {}
+
+// Check that inline-asm stack probes are generated correctly.
+// To avoid making this test fragile to slight asm changes,
+// we only check that the stack pointer is decremented by a page at a time,
+// instead of matching the whole probe sequence.
+
+// CHECK-LABEL: small_stack_probe:
+#[no_mangle]
+pub fn small_stack_probe(x: u8, f: fn(&mut [u8; 8192])) {
+    // CHECK-NOT: __rust_probestack
+    // x86_64: sub rsp, 4096
+    // i686: sub esp, 4096
+    f(&mut [x; 8192]);
+}
+
+// CHECK-LABEL: big_stack_probe:
+#[no_mangle]
+pub fn big_stack_probe(x: u8, f: fn(&[u8; 65536])) {
+    // CHECK-NOT: __rust_probestack
+    // x86_64: sub rsp, 4096
+    // i686: sub esp, 4096
+    f(&mut [x; 65536]);
+}