Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rollup of 8 pull requests #93287

Closed
wants to merge 35 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
18c14ad
Add a `try_clone()` function to `OwnedFd`.
sunfishcode Sep 9, 2021
622dfcc
Fix Windows compilation errors.
sunfishcode Sep 9, 2021
c986c6b
Fix more Windows compilation errors.
sunfishcode Sep 9, 2021
2d6a4c8
Fix another Windows compilation error.
sunfishcode Sep 9, 2021
53e072f
Fix compilation on WASI, which doesn't yet support `dup`.
sunfishcode Oct 5, 2021
83aebf8
Use the correct `cvt` for converting socket errors on Windows.
sunfishcode Jan 12, 2022
02f1a56
Properly track `DepNode`s in trait evaluation provisional cache
Aaron1011 Jan 19, 2022
f518827
Use impl1 and impl2 instead of a and b prefixes
spastorino Jan 21, 2022
052b31b
Move auxiliary fns out of overlap_with_probe
spastorino Jan 21, 2022
f4b4294
Remove FIXME and fix inconsistency of local blanket impls by using HI…
CraftSpider Jan 21, 2022
66d056a
Update test to include `self` case
CraftSpider Jan 21, 2022
1a0278e
Work around missing code coverage data causing llvm-cov failures
wesleywiser Jan 21, 2022
b2a45f0
Extract stable_disjoint fn
spastorino Jan 21, 2022
c2890ed
Add overlap mode
spastorino Jan 21, 2022
d2d25a5
Implement stable with negative coherence mode
spastorino Jan 21, 2022
1ec962f
Do not pass OverlapMode down, just create a closure to properly set t…
spastorino Jan 21, 2022
19e3c86
Make strict_disjoint use explicit_disjoint
spastorino Jan 21, 2022
e2567b0
Remove intermediate function doesn't make more sense
spastorino Jan 21, 2022
762bdbf
Change signature of point_at_arg_instead_of_call_if_possible
jackh726 Dec 25, 2021
ce31f68
Move param count error emission to near end of check_argument_types
jackh726 Jan 20, 2022
e5f2fdb
Restructure the code leveraging in abilities more than modes
spastorino Jan 22, 2022
9220631
Add has tests for blanket_with_local trait methods
CraftSpider Jan 23, 2022
7847ca8
Document OverlapMode
spastorino Jan 23, 2022
2693832
Rename strict_check to negative_impl_exists
spastorino Jan 23, 2022
8189bac
FIXME include regions too
spastorino Jan 23, 2022
11b17c6
rustdoc settings: use radio buttons for theme
jsha Jan 23, 2022
e02e958
Use error-on-mismatch policy for PAuth module flags.
jacobbramley Jan 19, 2022
f7f438b
Rollup merge of #88794 - sunfishcode:sunfishcode/try-clone, r=joshtri…
matthiaskrgr Jan 25, 2022
cdc0ddb
Rollup merge of #93064 - Aaron1011:provisional-dep-node, r=michaelwoe…
matthiaskrgr Jan 25, 2022
e47a373
Rollup merge of #93118 - jackh726:param-heuristics-3, r=estebank
matthiaskrgr Jan 25, 2022
8346977
Rollup merge of #93144 - wesleywiser:uninhabited_type_code_cov2, r=tm…
matthiaskrgr Jan 25, 2022
fa16356
Rollup merge of #93169 - CraftSpider:rustdoc-clean-inconsistency, r=G…
matthiaskrgr Jan 25, 2022
e4de1b5
Rollup merge of #93175 - spastorino:negative-traits-coherence-new, r=…
matthiaskrgr Jan 25, 2022
691bc38
Rollup merge of #93251 - jsha:theme-radio, r=GuillaumeGomez
matthiaskrgr Jan 25, 2022
3f4bf0e
Rollup merge of #93269 - jacobbramley:dev/pauth-option-1, r=petrochenkov
matthiaskrgr Jan 25, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Work around missing code coverage data causing llvm-cov failures
If we do not add code coverage instrumentation to the `Body` of a
function, then when we go to generate the function record for it, we
won't write any data and this later causes llvm-cov to fail when
processing data for the entire coverage report.

I've identified two main cases where we do not currently add code
coverage instrumentation to the `Body` of a function:

  1. If the function has a single `BasicBlock` and it ends with a
     `TerminatorKind::Unreachable`.

  2. If the function is created using a proc macro of some kind.

For case 1, this typically not important as this most often occurs as
the result of function definitions that take or return uninhabited
types. These kinds of functions, by definition, cannot even be called so
they logically should not be counted in code coverage statistics.

For case 2, I haven't looked into this very much but I've noticed while
testing this patch that (other than functions which are covered by case
1) the skipped function coverage debug message is occasionally triggered
in large crate graphs by functions generated from a proc macro. This may
have something to do with weird spans being generated by the proc macro
but this is just a guess.

I think it's reasonable to land this change since currently, we fail to
generate *any* results from llvm-cov when a function has no coverage
instrumentation applied to it. With this change, we get coverage data
for all functions other than the two cases discussed above.
  • Loading branch information
wesleywiser committed Jan 21, 2022
commit 1a0278e1d17f66ddc5975f38387746f85c6602ce
17 changes: 13 additions & 4 deletions compiler/rustc_codegen_llvm/src/coverageinfo/mapgen.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ use rustc_data_structures::fx::FxIndexSet;
use rustc_hir::def::DefKind;
use rustc_hir::def_id::DefIdSet;
use rustc_llvm::RustString;
use rustc_middle::bug;
use rustc_middle::middle::codegen_fn_attrs::CodegenFnAttrFlags;
use rustc_middle::mir::coverage::CodeRegion;
use rustc_middle::ty::TyCtxt;
Expand Down Expand Up @@ -76,10 +77,18 @@ pub fn finalize<'ll, 'tcx>(cx: &CodegenCx<'ll, 'tcx>) {
let coverage_mapping_buffer = llvm::build_byte_buffer(|coverage_mapping_buffer| {
mapgen.write_coverage_mapping(expressions, counter_regions, coverage_mapping_buffer);
});
debug_assert!(
!coverage_mapping_buffer.is_empty(),
"Every `FunctionCoverage` should have at least one counter"
);

if coverage_mapping_buffer.is_empty() {
if function_coverage.is_used() {
bug!(
"A used function should have had coverage mapping data but did not: {}",
mangled_function_name
);
} else {
debug!("unused function had no coverage mapping data: {}", mangled_function_name);
continue;
}
}

function_data.push((mangled_function_name, source_hash, is_used, coverage_mapping_buffer));
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
1| |// Regression test for #93054: Functions using uninhabited types often only have a single,
2| |// unreachable basic block which doesn't get instrumented. This should not cause llvm-cov to fail.
3| |// Since these kinds functions can't be invoked anyway, it's ok to not have coverage data for them.
4| |
5| |// compile-flags: --edition=2021
6| |
7| |enum Never { }
8| |
9| |impl Never {
10| | fn foo(self) {
11| | match self { }
12| | make().map(|never| match never { });
13| | }
14| |
15| | fn bar(&self) {
16| | match *self { }
17| | }
18| |}
19| |
20| 0|async fn foo2(never: Never) {
21| | match never { }
22| |}
23| |
24| 0|fn make() -> Option<Never> {
25| 0| None
26| 0|}
27| |
28| 1|fn main() { }

28 changes: 28 additions & 0 deletions src/test/run-make-fulldeps/coverage/issue-93054.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
// Regression test for #93054: Functions using uninhabited types often only have a single,
// unreachable basic block which doesn't get instrumented. This should not cause llvm-cov to fail.
// Since these kinds functions can't be invoked anyway, it's ok to not have coverage data for them.

// compile-flags: --edition=2021

enum Never { }

impl Never {
fn foo(self) {
match self { }
make().map(|never| match never { });
}

fn bar(&self) {
match *self { }
}
}

async fn foo2(never: Never) {
match never { }
}

fn make() -> Option<Never> {
None
}

fn main() { }