mirror of
https://github.com/rust-lang/rust.git
synced 2025-02-16 17:03:35 +00:00
Disable coverage instrumentation for naked functions
This commit is contained in:
parent
32e613bbaa
commit
c955add18c
@ -2073,6 +2073,10 @@ fn codegen_fn_attrs(tcx: TyCtxt<'_>, did: DefId) -> CodegenFnAttrs {
|
||||
}
|
||||
}
|
||||
|
||||
if codegen_fn_attrs.flags.contains(CodegenFnAttrFlags::NAKED) {
|
||||
codegen_fn_attrs.flags |= CodegenFnAttrFlags::NO_COVERAGE;
|
||||
}
|
||||
|
||||
// Weak lang items have the same semantics as "std internal" symbols in the
|
||||
// sense that they're preserved through all our LTO passes and only
|
||||
// strippable by the linker.
|
||||
|
19
src/test/codegen/naked-nocoverage.rs
Normal file
19
src/test/codegen/naked-nocoverage.rs
Normal file
@ -0,0 +1,19 @@
|
||||
// Checks that naked functions are not instrumented by -Cinstrument-coverage.
|
||||
// Regression test for issue #105170.
|
||||
//
|
||||
// needs-asm-support
|
||||
// needs-profiler-support
|
||||
// compile-flags: -Cinstrument-coverage
|
||||
#![crate_type = "lib"]
|
||||
#![feature(naked_functions)]
|
||||
use std::arch::asm;
|
||||
|
||||
#[naked]
|
||||
#[no_mangle]
|
||||
pub unsafe extern "C" fn f() {
|
||||
// CHECK: define void @f()
|
||||
// CHECK-NEXT: start:
|
||||
// CHECK-NEXT: call void asm
|
||||
// CHECK-NEXT: unreachable
|
||||
asm!("", options(noreturn));
|
||||
}
|
Loading…
Reference in New Issue
Block a user