diff options
| author | bors <bors@rust-lang.org> | 2020-07-19 07:25:18 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2020-07-19 07:25:18 +0000 |
| commit | 47ea6d90b073ab977cf072e2f5f46d63de532cc6 (patch) | |
| tree | d408537bbf5d8d3063d19914f6e30efe02c74681 /src/librustc_middle | |
| parent | 0701419e96d94e5493c7ebfcecb66511ab0aa778 (diff) | |
| parent | a6f8b8a2116f0ea7e31d572d3120508678ed8079 (diff) | |
| download | rust-47ea6d90b073ab977cf072e2f5f46d63de532cc6.tar.gz rust-47ea6d90b073ab977cf072e2f5f46d63de532cc6.zip | |
Auto merge of #74091 - richkadel:llvm-coverage-map-gen-4, r=tmandry
Generating the coverage map @tmandry @wesleywiser rustc now generates the coverage map and can support (limited) coverage report generation, at the function level. Example commands to generate a coverage report: ```shell $ BUILD=$HOME/rust/build/x86_64-unknown-linux-gnu $ $BUILD/stage1/bin/rustc -Zinstrument-coverage \ $HOME/rust/src/test/run-make-fulldeps/instrument-coverage/main.rs $ LLVM_PROFILE_FILE="main.profraw" ./main called $ $BUILD/llvm/bin/llvm-profdata merge -sparse main.profraw -o main.profdata $ $BUILD/llvm/bin/llvm-cov show --instr-profile=main.profdata main ```  r? @wesleywiser Rust compiler MCP rust-lang/compiler-team#278 Relevant issue: #34701 - Implement support for LLVMs code coverage instrumentation
Diffstat (limited to 'src/librustc_middle')
| -rw-r--r-- | src/librustc_middle/mir/coverage/mod.rs | 7 | ||||
| -rw-r--r-- | src/librustc_middle/mir/mono.rs | 2 | ||||
| -rw-r--r-- | src/librustc_middle/mir/query.rs | 8 |
3 files changed, 8 insertions, 9 deletions
diff --git a/src/librustc_middle/mir/coverage/mod.rs b/src/librustc_middle/mir/coverage/mod.rs index 327f321bd75..1e06dadfa24 100644 --- a/src/librustc_middle/mir/coverage/mod.rs +++ b/src/librustc_middle/mir/coverage/mod.rs @@ -2,9 +2,10 @@ /// Positional arguments to `libcore::count_code_region()` pub mod count_code_region_args { - pub const COUNTER_INDEX: usize = 0; - pub const START_BYTE_POS: usize = 1; - pub const END_BYTE_POS: usize = 2; + pub const FUNCTION_SOURCE_HASH: usize = 0; + pub const COUNTER_INDEX: usize = 1; + pub const START_BYTE_POS: usize = 2; + pub const END_BYTE_POS: usize = 3; } /// Positional arguments to `libcore::coverage_counter_add()` and diff --git a/src/librustc_middle/mir/mono.rs b/src/librustc_middle/mir/mono.rs index d22bde2ff8b..1ad5008d28a 100644 --- a/src/librustc_middle/mir/mono.rs +++ b/src/librustc_middle/mir/mono.rs @@ -86,7 +86,7 @@ impl<'tcx> MonoItem<'tcx> { .debugging_opts .inline_in_all_cgus .unwrap_or_else(|| tcx.sess.opts.optimize != OptLevel::No) - && !tcx.sess.opts.cg.link_dead_code; + && tcx.sess.opts.cg.link_dead_code != Some(true); match *self { MonoItem::Fn(ref instance) => { diff --git a/src/librustc_middle/mir/query.rs b/src/librustc_middle/mir/query.rs index 402a5c421a7..6ce5d61fbed 100644 --- a/src/librustc_middle/mir/query.rs +++ b/src/librustc_middle/mir/query.rs @@ -400,13 +400,11 @@ pub struct DestructuredConst<'tcx> { /// `InstrumentCoverage` MIR pass and can be retrieved via the `coverageinfo` query. #[derive(Clone, RustcEncodable, RustcDecodable, Debug, HashStable)] pub struct CoverageInfo { - /// A hash value that can be used by the consumer of the coverage profile data to detect - /// changes to the instrumented source of the associated MIR body (typically, for an - /// individual function). - pub hash: u64, - /// The total number of coverage region counters added to the MIR `Body`. pub num_counters: u32, + + /// The total number of coverage region counter expressions added to the MIR `Body`. + pub num_expressions: u32, } impl<'tcx> TyCtxt<'tcx> { |
