about summary refs log tree commit diff
path: root/compiler/rustc_mir/src/transform/coverage/graph.rs
AgeCommit message (Collapse)AuthorLines
2021-09-07Move rustc_mir::transform to rustc_mir_transform.Camille GILLOT-769/+0
2021-08-18Remove box syntax from rustc_mirest31-9/+13
2021-07-25use vec![] macro to create Vector with first item inside instead of pushing ↵Matthias Krüger-2/+2
to an empty vec![] slightly reduces code bloat
2021-05-07Avoid predecessors having Drop implsMark Rousskov-2/+2
2021-03-10Rename Option::get_or_insert_defaultCameron Steffen-1/+2
2021-03-08Use Option::get_or_defaultCameron Steffen-4/+1
2021-01-03remove redundant closures (clippy::redundant_closure)Matthias Krüger-1/+1
2020-12-11Fixes reported bugs in Rust CoverageRich Kadel-12/+16
Fixes: #79569 Fixes: #79566 Fixes: #79565 For the first issue (#79569), I got hit a `debug_assert!()` before encountering the reported error message (because I have `debug = true` enabled in my config.toml). The assertion showed me that some `SwitchInt`s can have more than one target pointing to the same `BasicBlock`. I had thought that was invalid, but since it seems to be possible, I'm allowing this now. I added a new test for this. ---- In the last two cases above, both tests (intentionally) fail to compile, but the `InstrumentCoverage` pass is invoked anyway. The MIR starts with an `Unreachable` `BasicBlock`, which I hadn't encountered before. (I had assumed the `InstrumentCoverage` pass would only be invoked with MIRs from successful compilations.) I don't have test infrastructure set up to test coverage on files that fail to compile, so I didn't add a new test.
2020-12-07Fixes to Rust coverageRich Kadel-2/+4
Fixes: #79725 Some macros can create a situation where `fn_sig_span` and `body_span` map to different files. New documentation on coverage tests incorrectly assumed multiple test binaries could just be listed at the end of the `llvm-cov` command, but it turns out each binary needs a `--object` prefix. This PR fixes the bug and updates the documentation to correct that issue. It also fixes a few other minor issues in internal implementation comments, and adds documentation on getting coverage results for doc tests.
2020-12-03Addressed feedback from 2020-12-01Rich Kadel-1/+3
Added one more test (two files) showing coverage of generics and unused functions across crates. Created and referenced new Issues, as requested. Added comments. Added a note about the possible effects of compiler options on LLVM coverage maps.
2020-12-03Combination of commitsRich Kadel-10/+10
Fixes multiple issue with counters, with simplification Includes a change to the implicit else span in ast_lowering, so coverage of the implicit else no longer spans the `then` block. Adds coverage for unused closures and async function bodies. Fixes: #78542 Adding unreachable regions for known MIR missing from coverage map Cleaned up PR commits, and removed link-dead-code requirement and tests Coverage no longer depends on Issue #76038 (`-C link-dead-code` is no longer needed or enforced, so MSVC can use the same tests as Linux and MacOS now) Restrict adding unreachable regions to covered files Improved the code that adds coverage for uncalled functions (with MIR but not-codegenned) to avoid generating coverage in files not already included in the files with covered functions. Resolved last known issue requiring --emit llvm-ir workaround Fixed bugs in how unreachable code spans were added.
2020-11-11Added some unit tests as requestedRich Kadel-8/+8
As discussed in PR #78267, for example: * https://github.com/rust-lang/rust/pull/78267#discussion_r515404722 * https://github.com/rust-lang/rust/pull/78267#discussion_r515405958
2020-11-05Responded to all feedback as of 2020-10-30Rich Kadel-21/+45
2020-11-05Injecting expressions in place of counters where helpfulRich Kadel-2/+319
Implementing the Graph traits for the BasicCoverageBlock graph. optimized replacement of counters with expressions plus new BCB graphviz * Avoid adding coverage to unreachable blocks. * Special case for Goto at the end of the body. Make it non-reportable. Improved debugging and formatting options (from env) Don't automatically add counters to BCBs without CoverageSpans. They may still get counters but only if there are dependencies from other BCBs that have spans, I think. Make CodeRegions optional for Counters too. It is possible to inject counters (`llvm.instrprof.increment` intrinsic calls without corresponding code regions in the coverage map. An expression can still uses these counter values. Refactored instrument_coverage.rs -> instrument_coverage/mod.rs, and then broke up the mod into multiple files. Compiling with coverage, with the expression optimization, works on the json5format crate and its dependencies. Refactored debug features from mod.rs to debug.rs
2020-11-05Implemented CoverageGraph of BasicCoverageBlocksRich Kadel-157/+301
2020-11-05Splitting transform/instrument_coverage.rs into transform/coverage/...Rich Kadel-0/+274