mirror of
https://github.com/allankoechke/rust.git
synced 2026-12-06 01:38:35 +00:00
This attribute enables or disables function instrumentation when using `-Zinstrument-xray` or `-Zinstrument-mcount`. It supports the following usage: `#[instrument_fn = "on|off"]` For XRay, "on" is equivalent to always instrument, and "off" is equivalent to never instrumenting. For mcount, "on" has no effect. "off" disables instrumentation of the function.
50 lines
1.9 KiB
Rust
50 lines
1.9 KiB
Rust
// Verify the #[instrument_fn] applies the correct LLVM IR function attributes.
|
|
//
|
|
//@ revisions:XRAY MCOUNT
|
|
//@ add-minicore
|
|
//@ compile-flags: -Copt-level=0
|
|
//@ [XRAY] compile-flags: -Zinstrument-xray --target=x86_64-unknown-linux-gnu
|
|
//@ [XRAY] needs-llvm-components: x86
|
|
//@ [MCOUNT] compile-flags: -Zinstrument-mcount
|
|
|
|
#![feature(no_core)]
|
|
#![crate_type = "lib"]
|
|
#![feature(instrument_fn)]
|
|
#![no_core]
|
|
|
|
extern crate minicore;
|
|
use minicore::*;
|
|
|
|
#[no_mangle]
|
|
// CHECK: define {{.*}}void @instrument_default() {{.*}} [[DFLT_ATTR:#[0-9]+]]
|
|
fn instrument_default() {}
|
|
|
|
#[no_mangle]
|
|
#[instrument_fn = "off"]
|
|
// CHECK: define {{.*}}void @instrument_off() {{.*}} [[OFF_ATTR:#[0-9]+]]
|
|
fn instrument_off() {}
|
|
|
|
#[no_mangle]
|
|
#[instrument_fn = "on"]
|
|
// MCOUNT: define {{.*}}void @instrument_on() {{.*}} [[DFLT_ATTR]]
|
|
// XRAY: define void @instrument_on() {{.*}} [[ON_ATTR:#[0-9]+]]
|
|
fn instrument_on() {}
|
|
|
|
// MCOUNT: attributes [[DFLT_ATTR]] {{.*}} "instrument-function-entry-inlined"=
|
|
// MCOUNT-NOT: attributes [[OFF_ATTR]] {{.*}} "instrument-function-entry-inlined"=
|
|
|
|
// XRAY-NOT: attributes [[DFLT_ATTR]] {{.*}} "function-instrument"="xray-always"
|
|
// XRAY-NOT: attributes [[DFLT_ATTR]] {{.*}} "function-instrument"="xray-never"
|
|
// XRAY-NOT: attributes [[DFLT_ATTR]] {{.*}} "xray-skip-exit"
|
|
// XRAY-NOT: attributes [[DFLT_ATTR]] {{.*}} "xray-skip-entry"
|
|
|
|
// XRAY-NOT: attributes [[OFF_ATTR]] {{.*}} "function-instrument"="xray-always"
|
|
// XRAY: attributes [[OFF_ATTR]] {{.*}} "function-instrument"="xray-never"
|
|
// XRAY-NOT: attributes [[OFF_ATTR]] {{.*}} "xray-skip-exit"
|
|
// XRAY-NOT: attributes [[OFF_ATTR]] {{.*}} "xray-skip-entry"
|
|
|
|
// XRAY: attributes [[ON_ATTR]] {{.*}} "function-instrument"="xray-always"
|
|
// XRAY-NOT: attributes [[ON_ATTR]] {{.*}} "function-instrument"="xray-never"
|
|
// XRAY-NOT: attributes [[ON_ATTR]] {{.*}} "xray-skip-exit"
|
|
// XRAY-NOT: attributes [[ON_ATTR]] {{.*}} "xray-skip-entry"
|