Rollup merge of #105193 - tmiasko:naked-nocoverage, r=wesleywiser
Disable coverage instrumentation for naked functions Fixes #105170.
This commit is contained in:
commit
ed9a21eb0c
4 changed files with 30 additions and 11 deletions
|
@ -258,13 +258,12 @@ pub fn from_fn_attrs<'ll, 'tcx>(
|
||||||
OptimizeAttr::Speed => {}
|
OptimizeAttr::Speed => {}
|
||||||
}
|
}
|
||||||
|
|
||||||
let inline = if codegen_fn_attrs.flags.contains(CodegenFnAttrFlags::NAKED) {
|
let inline =
|
||||||
InlineAttr::Never
|
if codegen_fn_attrs.inline == InlineAttr::None && instance.def.requires_inline(cx.tcx) {
|
||||||
} else if codegen_fn_attrs.inline == InlineAttr::None && instance.def.requires_inline(cx.tcx) {
|
InlineAttr::Hint
|
||||||
InlineAttr::Hint
|
} else {
|
||||||
} else {
|
codegen_fn_attrs.inline
|
||||||
codegen_fn_attrs.inline
|
};
|
||||||
};
|
|
||||||
to_add.extend(inline_attr(cx, inline));
|
to_add.extend(inline_attr(cx, inline));
|
||||||
|
|
||||||
// The `uwtable` attribute according to LLVM is:
|
// The `uwtable` attribute according to LLVM is:
|
||||||
|
|
|
@ -2073,6 +2073,11 @@ fn codegen_fn_attrs(tcx: TyCtxt<'_>, did: DefId) -> CodegenFnAttrs {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if codegen_fn_attrs.flags.contains(CodegenFnAttrFlags::NAKED) {
|
||||||
|
codegen_fn_attrs.flags |= CodegenFnAttrFlags::NO_COVERAGE;
|
||||||
|
codegen_fn_attrs.inline = InlineAttr::Never;
|
||||||
|
}
|
||||||
|
|
||||||
// Weak lang items have the same semantics as "std internal" symbols in the
|
// 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
|
// sense that they're preserved through all our LTO passes and only
|
||||||
// strippable by the linker.
|
// strippable by the linker.
|
||||||
|
|
|
@ -363,10 +363,6 @@ impl<'tcx> Inliner<'tcx> {
|
||||||
return Err("C variadic");
|
return Err("C variadic");
|
||||||
}
|
}
|
||||||
|
|
||||||
if callee_attrs.flags.contains(CodegenFnAttrFlags::NAKED) {
|
|
||||||
return Err("naked");
|
|
||||||
}
|
|
||||||
|
|
||||||
if callee_attrs.flags.contains(CodegenFnAttrFlags::COLD) {
|
if callee_attrs.flags.contains(CodegenFnAttrFlags::COLD) {
|
||||||
return Err("cold");
|
return Err("cold");
|
||||||
}
|
}
|
||||||
|
|
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…
Add table
Add a link
Reference in a new issue