rust/tests/mir-opt/instrument_coverage.main.InstrumentCoverage.diff
Zalathar 6da319f635 coverage: Store all of a function's mappings in function coverage info
Previously, mappings were attached to individual coverage statements in MIR.
That necessitated special handling in MIR optimizations to avoid deleting those
statements, since otherwise codegen would be unable to reassemble the original
list of mappings.

With this change, a function's list of mappings is now attached to its MIR
body, and survives intact even if individual statements are deleted by
optimizations.
2023-10-18 23:42:39 +11:00

54 lines
1.3 KiB
Diff

- // MIR for `main` before InstrumentCoverage
+ // MIR for `main` after InstrumentCoverage
fn main() -> () {
let mut _0: ();
let mut _1: ();
let mut _2: bool;
let mut _3: !;
+ coverage Counter(0) => /the/src/instrument_coverage.rs:11:1 - 11:11;
+ coverage Expression(0) => /the/src/instrument_coverage.rs:12:5 - 13:17;
+ coverage Expression(1) => /the/src/instrument_coverage.rs:14:13 - 14:18;
+ coverage Expression(1) => /the/src/instrument_coverage.rs:17:1 - 17:2;
+ coverage Counter(1) => /the/src/instrument_coverage.rs:15:10 - 15:11;
+
bb0: {
+ Coverage::CounterIncrement(0);
goto -> bb1;
}
bb1: {
+ Coverage::Expression(0) = Counter(0) + Counter(1);
falseUnwind -> [real: bb2, unwind: bb6];
}
bb2: {
StorageLive(_2);
_2 = bar() -> [return: bb3, unwind: bb6];
}
bb3: {
switchInt(move _2) -> [0: bb5, otherwise: bb4];
}
bb4: {
+ Coverage::Expression(1) = Expression(0) - Counter(1);
_0 = const ();
StorageDead(_2);
return;
}
bb5: {
+ Coverage::CounterIncrement(1);
_1 = const ();
StorageDead(_2);
goto -> bb1;
}
bb6 (cleanup): {
resume;
}
}