rust/compiler
bors a1dfd2490a Auto merge of #77080 - richkadel:llvm-coverage-counters-2, r=tmandry
Working branch-level code coverage

Add a generalized implementation for computing branch-level coverage spans.

This iteration resolves some of the challenges I had identified a few weeks ago.

I've tried to implement a solution that is general enough to work for a lot of different graphs/patterns. It's encouraging to see the results on fairly large and complex crates seem to meet my expectations. This may be a "functionally complete" implementation.

Except for bug fixes or edge cases I haven't run into yet, the next and essentially final step, I think, is to replace some Counters with CounterExpressions (where their counter values can be computed by adding or subtracting other counters/expressions).

Examples of branch-level coverage support enabled in this PR:

* https://github.com/richkadel/rust/blob/llvm-coverage-counters-2/src/test/run-make-fulldeps/instrument-coverage-cov-reports-base/expected_show_coverage.coverage_of_drop_trait.txt
* https://github.com/richkadel/rust/blob/llvm-coverage-counters-2/src/test/run-make-fulldeps/instrument-coverage-cov-reports-base/expected_show_coverage.coverage_of_if.txt
* https://github.com/richkadel/rust/blob/llvm-coverage-counters-2/src/test/run-make-fulldeps/instrument-coverage-cov-reports-base/expected_show_coverage.coverage_of_if_else.txt
* https://github.com/richkadel/rust/blob/llvm-coverage-counters-2/src/test/run-make-fulldeps/instrument-coverage-cov-reports-base/expected_show_coverage.coverage_of_simple_loop.txt
* https://github.com/richkadel/rust/blob/llvm-coverage-counters-2/src/test/run-make-fulldeps/instrument-coverage-cov-reports-base/expected_show_coverage.coverage_of_simple_match.txt
* ... _and others in the same directory_

Examples of coverage analysis results (MIR spanview files) used to inject counters in the right `BasicBlocks`:

* https://htmlpreview.github.io/?https://github.com/richkadel/rust/blob/llvm-coverage-counters-2/src/test/run-make-fulldeps/instrument-coverage-mir-cov-html-base/expected_mir_dump.coverage_of_drop_trait/coverage_of_drop_trait.main.-------.InstrumentCoverage.0.html
* https://htmlpreview.github.io/?https://github.com/richkadel/rust/blob/llvm-coverage-counters-2/src/test/run-make-fulldeps/instrument-coverage-mir-cov-html-base/expected_mir_dump.coverage_of_if/coverage_of_if.main.-------.InstrumentCoverage.0.html
* https://htmlpreview.github.io/?https://github.com/richkadel/rust/blob/llvm-coverage-counters-2/src/test/run-make-fulldeps/instrument-coverage-mir-cov-html-base/expected_mir_dump.coverage_of_if_else/coverage_of_if_else.main.-------.InstrumentCoverage.0.html
* https://htmlpreview.github.io/?https://github.com/richkadel/rust/blob/llvm-coverage-counters-2/src/test/run-make-fulldeps/instrument-coverage-mir-cov-html-base/expected_mir_dump.coverage_of_simple_loop/coverage_of_simple_loop.main.-------.InstrumentCoverage.0.html
* https://htmlpreview.github.io/?https://github.com/richkadel/rust/blob/llvm-coverage-counters-2/src/test/run-make-fulldeps/instrument-coverage-mir-cov-html-base/expected_mir_dump.coverage_of_simple_match/coverage_of_simple_match.main.-------.InstrumentCoverage.0.html
* ... _and others in the same directory_

Here is some sample coverage output after compiling a few real-world crates with the new branch-level coverage features:

<img width="801" alt="Screen Shot 2020-09-25 at 1 03 11 PM" src="https://user-images.githubusercontent.com/3827298/94316848-fd882c00-ff39-11ea-9cff-0402d3abd1e7.png">
<img width="721" alt="Screen Shot 2020-09-25 at 1 00 36 PM" src="https://user-images.githubusercontent.com/3827298/94316886-11cc2900-ff3a-11ea-9d03-80b26c8a5173.png">
<img width="889" alt="Screen Shot 2020-09-25 at 12 54 57 PM" src="https://user-images.githubusercontent.com/3827298/94316900-18f33700-ff3a-11ea-8a80-58f67d84b8de.png">

r? `@tmandry`
FYI: `@wesleywiser`
2020-10-05 19:34:44 +00:00
..
rustc just max_level_info 2020-09-11 09:37:51 -07:00
rustc_apfloat Backport another LLVM commit to rustc_apfloat 2020-10-04 02:02:25 +02:00
rustc_arena Remove unused #[allow(...)] statements from compiler/ 2020-09-26 01:25:55 +02:00
rustc_ast tidy 2020-09-23 22:08:30 +02:00
rustc_ast_lowering simplfy condition in ItemLowerer::with_trait_impl_ref() 2020-09-16 23:09:57 +02:00
rustc_ast_passes use matches!() macro for simple if let conditions 2020-09-18 20:28:35 +02:00
rustc_ast_pretty Fully integrate token collection for additional AST structs 2020-09-10 17:58:14 -04:00
rustc_attr Remove rustc_allow_const_fn_ptr 2020-09-27 10:46:41 -07:00
rustc_builtin_macros expand: Stop un-interpolating NtIdents before passing them to built-in macros 2020-09-28 23:10:44 +03:00
rustc_codegen_llvm Updates to experimental coverage counter injection 2020-10-05 08:02:58 -07:00
rustc_codegen_ssa Auto merge of #77080 - richkadel:llvm-coverage-counters-2, r=tmandry 2020-10-05 19:34:44 +00:00
rustc_data_structures Auto merge of #77080 - richkadel:llvm-coverage-counters-2, r=tmandry 2020-10-05 19:34:44 +00:00
rustc_driver Rollup merge of #75143 - oli-obk:tracing, r=RalfJung 2020-10-04 11:44:49 +09:00
rustc_error_codes Create E0777 error code for "invalid literal in derive" 2020-10-01 20:41:57 +02:00
rustc_errors /nightly/nightly-rustc 2020-09-23 21:51:56 +02:00
rustc_expand Improve E0777 help message 2020-10-02 16:33:44 +02:00
rustc_feature Rollup merge of #77439 - varkor:min_const_generics-tests, r=lcnr,estebank 2020-10-05 02:29:36 +02:00
rustc_fs_util mv compiler to compiler/ 2020-08-30 18:45:07 +03:00
rustc_graphviz /nightly/nightly-rustc 2020-09-23 21:51:56 +02:00
rustc_hir Rollup merge of #77514 - scottmcm:less-once-chain-once, r=estebank 2020-10-05 02:29:42 +02:00
rustc_hir_pretty mv compiler to compiler/ 2020-08-30 18:45:07 +03:00
rustc_incremental /nightly/nightly-rustc 2020-09-23 21:51:56 +02:00
rustc_index cache types during normalization 2020-09-19 17:27:13 +02:00
rustc_infer Auto merge of #77171 - VFLashM:better_sso_structures, r=oli-obk 2020-10-05 17:18:01 +00:00
rustc_interface Add -Zprecise-enum-drop-elaboration 2020-10-01 11:31:43 -07:00
rustc_lexer Fix typo in rustc_lexer docs 2020-09-21 05:43:39 +02:00
rustc_lint Uplift drop-bounds lint from clippy 2020-10-01 12:06:33 -07:00
rustc_llvm Update LLVM and add Unsupported diagnostic 2020-09-30 14:57:37 +01:00
rustc_macros Remove unused #[allow(...)] statements from compiler/ 2020-09-26 01:25:55 +02:00
rustc_metadata rustc_metadata: Do not forget to encode inherent impls for foreign types 2020-09-30 22:58:35 +03:00
rustc_middle Auto merge of #77080 - richkadel:llvm-coverage-counters-2, r=tmandry 2020-10-05 19:34:44 +00:00
rustc_mir Renamed tests to avoid exceeding Windows max path limit 2020-10-05 09:40:25 -07:00
rustc_mir_build Auto merge of #77552 - ecstatic-morse:body-def-id, r=lcnr 2020-10-05 09:26:32 +00:00
rustc_parse Rollup merge of #77444 - estebank:pat-field-label, r=davidtwco 2020-10-02 20:27:16 +02:00
rustc_parse_format /nightly/nightly-rustc 2020-09-23 21:51:56 +02:00
rustc_passes Rollup merge of #76329 - GuillaumeGomez:doc-alias-crate-level, r=matthewjasper 2020-10-05 02:29:27 +02:00
rustc_plugin_impl /nightly/nightly-rustc 2020-09-23 21:51:56 +02:00
rustc_privacy /nightly/nightly-rustc 2020-09-23 21:51:56 +02:00
rustc_query_system update the version of itertools and parking_lot 2020-09-12 08:26:53 +02:00
rustc_resolve Rollup merge of #77439 - varkor:min_const_generics-tests, r=lcnr,estebank 2020-10-05 02:29:36 +02:00
rustc_save_analysis /nightly/nightly-rustc 2020-09-23 21:51:56 +02:00
rustc_serialize Deduplicate and generalize some (de/)serializer impls 2020-09-26 14:55:42 +02:00
rustc_session Updates to experimental coverage counter injection 2020-10-05 08:02:58 -07:00
rustc_span Updates to experimental coverage counter injection 2020-10-05 08:02:58 -07:00
rustc_symbol_mangling Permit ty::Bool in const generics for v0 mangling 2020-10-02 09:45:48 -04:00
rustc_target Returns values up to 2*usize by value 2020-10-02 00:23:25 +02:00
rustc_trait_selection Auto merge of #77171 - VFLashM:better_sso_structures, r=oli-obk 2020-10-05 17:18:01 +00:00
rustc_traits Update chalk to 0.29.0 2020-09-27 15:54:07 +02:00
rustc_ty Rollup merge of #77155 - lcnr:ImplSource, r=ecstatic-morse 2020-09-25 19:42:48 +02:00
rustc_typeck Rollup merge of #77514 - scottmcm:less-once-chain-once, r=estebank 2020-10-05 02:29:42 +02:00