coverage: Don't store a body span in FunctionCoverageInfo
This commit is contained in:
parent
cd2b978433
commit
cc8336b6c1
10 changed files with 14 additions and 19 deletions
|
@ -105,9 +105,14 @@ fn fill_region_tables<'tcx>(
|
|||
ids_info: &'tcx CoverageIdsInfo,
|
||||
covfun: &mut CovfunRecord<'tcx>,
|
||||
) {
|
||||
// Currently a function's mappings must all be in the same file as its body span.
|
||||
// Currently a function's mappings must all be in the same file, so use the
|
||||
// first mapping's span to determine the file.
|
||||
let source_map = tcx.sess.source_map();
|
||||
let source_file = source_map.lookup_source_file(fn_cov_info.body_span.lo());
|
||||
let Some(first_span) = (try { fn_cov_info.mappings.first()?.span }) else {
|
||||
debug_assert!(false, "function has no mappings: {:?}", covfun.mangled_function_name);
|
||||
return;
|
||||
};
|
||||
let source_file = source_map.lookup_source_file(first_span.lo());
|
||||
|
||||
// Look up the global file ID for that file.
|
||||
let global_file_id = global_file_table.global_file_id_for_file(&source_file);
|
||||
|
|
|
@ -194,7 +194,6 @@ pub struct Mapping {
|
|||
#[derive(TyEncodable, TyDecodable, Hash, HashStable)]
|
||||
pub struct FunctionCoverageInfo {
|
||||
pub function_source_hash: u64,
|
||||
pub body_span: Span,
|
||||
|
||||
/// Used in conjunction with `priority_list` to create physical counters
|
||||
/// and counter expressions, after MIR optimizations.
|
||||
|
|
|
@ -620,9 +620,8 @@ fn write_function_coverage_info(
|
|||
function_coverage_info: &coverage::FunctionCoverageInfo,
|
||||
w: &mut dyn io::Write,
|
||||
) -> io::Result<()> {
|
||||
let coverage::FunctionCoverageInfo { body_span, mappings, .. } = function_coverage_info;
|
||||
let coverage::FunctionCoverageInfo { mappings, .. } = function_coverage_info;
|
||||
|
||||
writeln!(w, "{INDENT}coverage body span: {body_span:?}")?;
|
||||
for coverage::Mapping { kind, span } in mappings {
|
||||
writeln!(w, "{INDENT}coverage {kind:?} => {span:?};")?;
|
||||
}
|
||||
|
|
|
@ -107,7 +107,6 @@ fn instrument_function_for_coverage<'tcx>(tcx: TyCtxt<'tcx>, mir_body: &mut mir:
|
|||
|
||||
mir_body.function_coverage_info = Some(Box::new(FunctionCoverageInfo {
|
||||
function_source_hash: hir_info.function_source_hash,
|
||||
body_span: hir_info.body_span,
|
||||
|
||||
node_flow_data,
|
||||
priority_list,
|
||||
|
|
|
@ -26,7 +26,6 @@
|
|||
debug a => _9;
|
||||
}
|
||||
|
||||
+ coverage body span: $DIR/branch_match_arms.rs:14:11: 21:2 (#0)
|
||||
+ coverage Code { bcb: bcb0 } => $DIR/branch_match_arms.rs:14:1: 15:21 (#0);
|
||||
+ coverage Code { bcb: bcb1 } => $DIR/branch_match_arms.rs:16:17: 16:33 (#0);
|
||||
+ coverage Code { bcb: bcb3 } => $DIR/branch_match_arms.rs:17:17: 17:33 (#0);
|
||||
|
|
|
@ -4,8 +4,7 @@
|
|||
fn bar() -> bool {
|
||||
let mut _0: bool;
|
||||
|
||||
+ coverage body span: $DIR/instrument_coverage.rs:29:18: 31:2 (#0)
|
||||
+ coverage Code { bcb: bcb0 } => $DIR/instrument_coverage.rs:29:1: 31:2 (#0);
|
||||
+ coverage Code { bcb: bcb0 } => $DIR/instrument_coverage.rs:27:1: 29:2 (#0);
|
||||
+
|
||||
bb0: {
|
||||
+ Coverage::VirtualCounter(bcb0);
|
||||
|
|
|
@ -7,12 +7,11 @@
|
|||
let mut _2: bool;
|
||||
let mut _3: !;
|
||||
|
||||
+ coverage body span: $DIR/instrument_coverage.rs:14:11: 20:2 (#0)
|
||||
+ coverage Code { bcb: bcb0 } => $DIR/instrument_coverage.rs:14:1: 14:11 (#0);
|
||||
+ coverage Code { bcb: bcb1 } => $DIR/instrument_coverage.rs:16:12: 16:17 (#0);
|
||||
+ coverage Code { bcb: bcb2 } => $DIR/instrument_coverage.rs:17:13: 17:18 (#0);
|
||||
+ coverage Code { bcb: bcb3 } => $DIR/instrument_coverage.rs:18:10: 18:10 (#0);
|
||||
+ coverage Code { bcb: bcb2 } => $DIR/instrument_coverage.rs:20:2: 20:2 (#0);
|
||||
+ coverage Code { bcb: bcb0 } => $DIR/instrument_coverage.rs:13:1: 13:11 (#0);
|
||||
+ coverage Code { bcb: bcb1 } => $DIR/instrument_coverage.rs:15:12: 15:17 (#0);
|
||||
+ coverage Code { bcb: bcb2 } => $DIR/instrument_coverage.rs:16:13: 16:18 (#0);
|
||||
+ coverage Code { bcb: bcb3 } => $DIR/instrument_coverage.rs:17:10: 17:10 (#0);
|
||||
+ coverage Code { bcb: bcb2 } => $DIR/instrument_coverage.rs:19:2: 19:2 (#0);
|
||||
+
|
||||
bb0: {
|
||||
+ Coverage::VirtualCounter(bcb0);
|
||||
|
|
|
@ -7,7 +7,6 @@
|
|||
|
||||
// EMIT_MIR instrument_coverage.main.InstrumentCoverage.diff
|
||||
// CHECK-LABEL: fn main()
|
||||
// CHECK: coverage body span:
|
||||
// CHECK: coverage Code { bcb: bcb{{[0-9]+}} } =>
|
||||
// CHECK: bb0:
|
||||
// CHECK: Coverage::VirtualCounter
|
||||
|
@ -21,7 +20,6 @@ fn main() {
|
|||
|
||||
// EMIT_MIR instrument_coverage.bar.InstrumentCoverage.diff
|
||||
// CHECK-LABEL: fn bar()
|
||||
// CHECK: coverage body span:
|
||||
// CHECK: coverage Code { bcb: bcb{{[0-9]+}} } =>
|
||||
// CHECK: bb0:
|
||||
// CHECK: Coverage::VirtualCounter
|
||||
|
|
|
@ -7,7 +7,6 @@
|
|||
|
||||
coverage branch { true: BlockMarkerId(0), false: BlockMarkerId(1) } => $DIR/instrument_coverage_cleanup.rs:14:8: 14:36 (#0)
|
||||
|
||||
coverage body span: $DIR/instrument_coverage_cleanup.rs:13:11: 15:2 (#0)
|
||||
coverage Code { bcb: bcb0 } => $DIR/instrument_coverage_cleanup.rs:13:1: 14:36 (#0);
|
||||
coverage Code { bcb: bcb3 } => $DIR/instrument_coverage_cleanup.rs:14:37: 14:39 (#0);
|
||||
coverage Code { bcb: bcb1 } => $DIR/instrument_coverage_cleanup.rs:14:39: 14:39 (#0);
|
||||
|
|
|
@ -7,7 +7,6 @@
|
|||
|
||||
coverage branch { true: BlockMarkerId(0), false: BlockMarkerId(1) } => $DIR/instrument_coverage_cleanup.rs:14:8: 14:36 (#0)
|
||||
|
||||
+ coverage body span: $DIR/instrument_coverage_cleanup.rs:13:11: 15:2 (#0)
|
||||
+ coverage Code { bcb: bcb0 } => $DIR/instrument_coverage_cleanup.rs:13:1: 14:36 (#0);
|
||||
+ coverage Code { bcb: bcb3 } => $DIR/instrument_coverage_cleanup.rs:14:37: 14:39 (#0);
|
||||
+ coverage Code { bcb: bcb1 } => $DIR/instrument_coverage_cleanup.rs:14:39: 14:39 (#0);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue