1
Fork 0

Run LLVM coverage instrumentation passes before optimization passes

This matches the behavior of Clang and allows us to remove several
hacks which were needed to ensure functions weren't optimized away
before reaching the instrumentation pass.
This commit is contained in:
Amanieu d'Antras 2021-03-27 05:04:32 +00:00
parent 3debe9acb8
commit 26d260bfa4
9 changed files with 91 additions and 138 deletions

View file

@ -2889,17 +2889,7 @@ fn codegen_fn_attrs(tcx: TyCtxt<'_>, id: DefId) -> CodegenFnAttrs {
.emit();
InlineAttr::None
} else if list_contains_name(&items[..], sym::always) {
if tcx.sess.instrument_coverage() {
// Fixes Issue #82875. Forced inlining allows LLVM to discard functions
// marked with `#[inline(always)]`, which can break coverage reporting if
// that function was referenced from a coverage map.
//
// FIXME(#83429): Is there a better place, e.g., in codegen, to check and
// convert `Always` to `Hint`?
InlineAttr::Hint
} else {
InlineAttr::Always
}
InlineAttr::Always
} else if list_contains_name(&items[..], sym::never) {
InlineAttr::Never
} else {