Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit cef4697

Browse files
committedOct 31, 2024·
coverage: Avoid ICE when coverage_cx is unexpectedly unavailable
1 parent 75eff9a commit cef4697

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed
 

‎compiler/rustc_codegen_llvm/src/coverageinfo/mapgen.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,11 @@ pub(crate) fn finalize(cx: &CodegenCx<'_, '_>) {
5454
add_unused_functions(cx);
5555
}
5656

57-
let function_coverage_map = cx.coverage_cx().take_function_coverage_map();
57+
// FIXME(#132395): Can this be none even when coverage is enabled?
58+
let function_coverage_map = match cx.coverage_cx {
59+
Some(ref cx) => cx.take_function_coverage_map(),
60+
None => return,
61+
};
5862
if function_coverage_map.is_empty() {
5963
// This module has no functions with coverage instrumentation
6064
return;

‎compiler/rustc_codegen_llvm/src/coverageinfo/mod.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,12 @@ impl<'tcx> CoverageInfoBuilderMethods<'tcx> for Builder<'_, '_, 'tcx> {
152152
return;
153153
};
154154

155-
let mut coverage_map = bx.coverage_cx().function_coverage_map.borrow_mut();
155+
// FIXME(#132395): Unwrapping `coverage_cx` here has led to ICEs in the
156+
// wild, so keep this early-return until we understand why.
157+
let mut coverage_map = match bx.coverage_cx {
158+
Some(ref cx) => cx.function_coverage_map.borrow_mut(),
159+
None => return,
160+
};
156161
let func_coverage = coverage_map
157162
.entry(instance)
158163
.or_insert_with(|| FunctionCoverageCollector::new(instance, function_coverage_info));

0 commit comments

Comments
 (0)
Please sign in to comment.