mirror of
https://github.com/allankoechke/rust.git
synced 2026-12-05 09:23:31 +00:00
fentry is essentially a simpler version of mcount where the counting function is called before any other function prologue actions happen. fentry is still used by the linux x86-64 kernel. It's unclear if or when patchable-function-entry will replace it. It is also used by clang for some x86-64 mingw toolchains. This is only supported on some x86, x86-64, and s390x targets.
57 lines
2.2 KiB
Rust
57 lines
2.2 KiB
Rust
// Verify the #[instrument_fn] applies the correct LLVM IR function attributes.
|
|
//
|
|
//@ revisions:XRAY MCOUNT FENTRY
|
|
//@ add-minicore
|
|
//@ compile-flags: -Copt-level=0
|
|
//@ [XRAY] compile-flags: -Zinstrument-xray --target=x86_64-unknown-linux-gnu
|
|
//@ [XRAY] needs-llvm-components: x86
|
|
//@ [FENTRY] compile-flags: -Zinstrument-mcount=fentry -Copt-level=0
|
|
//@ [FENTRY] compile-flags: --target=x86_64-unknown-linux-gnu
|
|
//@ [FENTRY] 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]]
|
|
// FENTRY: 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"=
|
|
|
|
// FENTRY: attributes [[DFLT_ATTR]] {{.*}} "fentry-call"="true"
|
|
// FENTRY-NOT: attributes [[OFF_ATTR]] {{.*}} "fentry-call"="true"
|
|
|
|
// 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"
|