]> git.lizzy.rs Git - rust.git/blob - tests/assembly/x86-stack-probes.rs
Rollup merge of #106701 - ibraheemdev:sync-sender-spin, r=Amanieu
[rust.git] / tests / assembly / x86-stack-probes.rs
1 // min-llvm-version: 16
2 // revisions: x86_64 i686
3 // assembly-output: emit-asm
4 //[x86_64] compile-flags: --target x86_64-unknown-linux-gnu
5 //[x86_64] needs-llvm-components: x86
6 //[i686] compile-flags: --target i686-unknown-linux-gnu
7 //[i686] needs-llvm-components: x86
8 // compile-flags: -C llvm-args=-x86-asm-syntax=intel
9
10 #![feature(no_core, lang_items)]
11 #![crate_type = "lib"]
12 #![no_core]
13
14 #[lang = "sized"]
15 trait Sized {}
16 #[lang = "copy"]
17 trait Copy {}
18
19 impl Copy for u8 {}
20
21 // Check that inline-asm stack probes are generated correctly.
22 // To avoid making this test fragile to slight asm changes,
23 // we only check that the stack pointer is decremented by a page at a time,
24 // instead of matching the whole probe sequence.
25
26 // CHECK-LABEL: small_stack_probe:
27 #[no_mangle]
28 pub fn small_stack_probe(x: u8, f: fn(&mut [u8; 8192])) {
29     // CHECK-NOT: __rust_probestack
30     // x86_64: sub rsp, 4096
31     // i686: sub esp, 4096
32     f(&mut [x; 8192]);
33 }
34
35 // CHECK-LABEL: big_stack_probe:
36 #[no_mangle]
37 pub fn big_stack_probe(x: u8, f: fn(&[u8; 65536])) {
38     // CHECK-NOT: __rust_probestack
39     // x86_64: sub rsp, 4096
40     // i686: sub esp, 4096
41     f(&mut [x; 65536]);
42 }