Add compiler tests for xray

This commit is contained in:
quininer
2025-05-19 10:44:00 +08:00
parent 1758f07cb8
commit 45ed022d63
5 changed files with 77 additions and 10 deletions
+25
View File
@@ -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
}
+25
View File
@@ -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]
}
@@ -0,0 +1,27 @@
//@ only-nightly (flag is still unstable)
//@ needs-xray
//@ revisions: unsupported
//@[unsupported] needs-llvm-components: x86
//@[unsupported] compile-flags: -Z instrument-xray --target=x86_64-pc-windows-msvc
//@ revisions: x86_64-linux
//@[x86_64-linux] needs-llvm-components: x86
//@[x86_64-linux] compile-flags: -Z instrument-xray --target=x86_64-unknown-linux-gnu
//@[x86_64-linux] check-pass
//@ revisions: x86_64-darwin
//@[x86_64-darwin] needs-llvm-components: x86
//@[x86_64-darwin] compile-flags: -Z instrument-xray --target=x86_64-apple-darwin
//@[x86_64-darwin] check-pass
//@ revisions: aarch64-darwin
//@[aarch64-darwin] needs-llvm-components: aarch64
//@[aarch64-darwin] compile-flags: -Z instrument-xray --target=aarch64-apple-darwin
//@[aarch64-darwin] check-pass
#![feature(no_core)]
#![no_core]
#![no_main]
//[unsupported]~? ERROR XRay instrumentation is not supported for this target
@@ -1,10 +0,0 @@
// Verifies that `-Z instrument-xray` cannot be used with unsupported targets,
//
//@ needs-llvm-components: x86
//@ compile-flags: -Z instrument-xray --target x86_64-pc-windows-msvc
#![feature(no_core)]
#![no_core]
#![no_main]
//~? ERROR XRay instrumentation is not supported for this target