about summary refs log tree commit diff
path: root/tests/assembly
diff options
context:
space:
mode:
authorquininer <quininer@live.com>2025-05-19 10:44:00 +0800
committerquininer <quininer@live.com>2025-05-26 00:39:23 +0800
commit45ed022d636ec72dfbb22269196007b0e71a9c7d (patch)
tree57aea3bc9b82c0c61adf6cac6e2d28c2e01b0600 /tests/assembly
parent1758f07cb832e9a854f34af437878a10f22dae82 (diff)
Add compiler tests for xray
Diffstat (limited to 'tests/assembly')
-rw-r--r--tests/assembly/aarch64-xray.rs25
-rw-r--r--tests/assembly/x86_64-xray.rs25
2 files changed, 50 insertions, 0 deletions
diff --git a/tests/assembly/aarch64-xray.rs b/tests/assembly/aarch64-xray.rs
new file mode 100644
index 00000000000..d5ee0111843
--- /dev/null
+++ b/tests/assembly/aarch64-xray.rs
@@ -0,0 +1,25 @@
+//@ assembly-output: emit-asm
+//@ compile-flags: -Zinstrument-xray=always
+
+//@ revisions: aarch64-linux
+//@[aarch64-linux] compile-flags: --target=aarch64-unknown-linux-gnu
+//@[aarch64-linux] needs-llvm-components: aarch64
+//@[aarch64-linux] only-aarch64-unknown-linux-gnu
+
+//@ revisions: aarch64-darwin
+//@[aarch64-darwin] compile-flags: --target=aarch64-apple-darwin
+//@[aarch64-darwin] needs-llvm-components: aarch64
+//@[aarch64-darwin] only-aarch64-apple-darwin
+
+#![crate_type = "lib"]
+
+// CHECK-LABEL: xray_func:
+#[no_mangle]
+pub fn xray_func() {
+    // CHECK: nop
+
+    std::hint::black_box(());
+
+    // CHECK: b #32
+    // CHECK-NEXT: nop
+}
diff --git a/tests/assembly/x86_64-xray.rs b/tests/assembly/x86_64-xray.rs
new file mode 100644
index 00000000000..4cf3e8cda13
--- /dev/null
+++ b/tests/assembly/x86_64-xray.rs
@@ -0,0 +1,25 @@
+//@ assembly-output: emit-asm
+//@ compile-flags: -Zinstrument-xray=always -Cllvm-args=-x86-asm-syntax=intel
+
+//@ revisions: x86_64-linux
+//@[x86_64-linux] compile-flags: --target=x86_64-unknown-linux-gnu
+//@[x86_64-linux] needs-llvm-components: x86
+//@[x86_64-linux] only-x86_64-unknown-linux-gnu
+
+//@ revisions: x86_64-darwin
+//@[x86_64-darwin] compile-flags: --target=x86_64-apple-darwin
+//@[x86_64-darwin] needs-llvm-components: x86
+//@[x86_64-darwin] only-x86_64-apple-darwin
+
+#![crate_type = "lib"]
+
+// CHECK-LABEL: xray_func:
+#[no_mangle]
+pub fn xray_func() {
+    // CHECK: nop word ptr [rax + rax + 512]
+
+    std::hint::black_box(());
+
+    // CHECK: ret
+    // CHECK-NEXT: nop word ptr cs:[rax + rax + 512]
+}