coverage: Avoid creating func_coverage
for marker statements
Coverage marker statements should have no effect on codegen, but in some cases they could have the side-effect of creating a `func_coverage` entry for their enclosing function. That can lead to an ICE for functions that don't actually have any coverage spans.
This commit is contained in:
parent
dfa6441354
commit
c57f28bbf7
@ -85,6 +85,14 @@ impl<'tcx> CoverageInfoBuilderMethods<'tcx> for Builder<'_, '_, 'tcx> {
|
|||||||
|
|
||||||
let bx = self;
|
let bx = self;
|
||||||
|
|
||||||
|
match coverage.kind {
|
||||||
|
// Marker statements have no effect during codegen,
|
||||||
|
// so return early and don't create `func_coverage`.
|
||||||
|
CoverageKind::SpanMarker => return,
|
||||||
|
// Match exhaustively to ensure that newly-added kinds are classified correctly.
|
||||||
|
CoverageKind::CounterIncrement { .. } | CoverageKind::ExpressionUsed { .. } => {}
|
||||||
|
}
|
||||||
|
|
||||||
let Some(function_coverage_info) =
|
let Some(function_coverage_info) =
|
||||||
bx.tcx.instance_mir(instance.def).function_coverage_info.as_deref()
|
bx.tcx.instance_mir(instance.def).function_coverage_info.as_deref()
|
||||||
else {
|
else {
|
||||||
@ -100,9 +108,9 @@ impl<'tcx> CoverageInfoBuilderMethods<'tcx> for Builder<'_, '_, 'tcx> {
|
|||||||
|
|
||||||
let Coverage { kind } = coverage;
|
let Coverage { kind } = coverage;
|
||||||
match *kind {
|
match *kind {
|
||||||
// Span markers are only meaningful during MIR instrumentation,
|
CoverageKind::SpanMarker => unreachable!(
|
||||||
// and have no effect during codegen.
|
"unexpected marker statement {kind:?} should have caused an early return"
|
||||||
CoverageKind::SpanMarker => {}
|
),
|
||||||
CoverageKind::CounterIncrement { id } => {
|
CoverageKind::CounterIncrement { id } => {
|
||||||
func_coverage.mark_counter_id_seen(id);
|
func_coverage.mark_counter_id_seen(id);
|
||||||
// We need to explicitly drop the `RefMut` before calling into `instrprof_increment`,
|
// We need to explicitly drop the `RefMut` before calling into `instrprof_increment`,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user