Skip to content

Commit 3f65114

Browse files
committed
coverage: Rename CrateCoverageContext to CguCoverageContext
This context is stored in `CodegenCx`, which makes it per-CGU rather than per-crate. A single crate can have multiple CGUs.
1 parent 5bbbc09 commit 3f65114

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

compiler/rustc_codegen_llvm/src/context.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -82,8 +82,8 @@ pub(crate) struct CodegenCx<'ll, 'tcx> {
8282

8383
pub isize_ty: &'ll Type,
8484

85-
/// Extra codegen state needed when coverage instrumentation is enabled.
86-
pub coverage_cx: Option<coverageinfo::CrateCoverageContext<'ll, 'tcx>>,
85+
/// Extra per-CGU codegen state needed when coverage instrumentation is enabled.
86+
pub coverage_cx: Option<coverageinfo::CguCoverageContext<'ll, 'tcx>>,
8787
pub dbg_cx: Option<debuginfo::CodegenUnitDebugContext<'ll, 'tcx>>,
8888

8989
eh_personality: Cell<Option<&'ll Value>>,
@@ -525,7 +525,7 @@ impl<'ll, 'tcx> CodegenCx<'ll, 'tcx> {
525525
let (llcx, llmod) = (&*llvm_module.llcx, llvm_module.llmod());
526526

527527
let coverage_cx =
528-
tcx.sess.instrument_coverage().then(coverageinfo::CrateCoverageContext::new);
528+
tcx.sess.instrument_coverage().then(coverageinfo::CguCoverageContext::new);
529529

530530
let dbg_cx = if tcx.sess.opts.debuginfo != DebugInfo::None {
531531
let dctx = debuginfo::CodegenUnitDebugContext::new(llmod);
@@ -576,7 +576,7 @@ impl<'ll, 'tcx> CodegenCx<'ll, 'tcx> {
576576
/// Extra state that is only available when coverage instrumentation is enabled.
577577
#[inline]
578578
#[track_caller]
579-
pub(crate) fn coverage_cx(&self) -> &coverageinfo::CrateCoverageContext<'ll, 'tcx> {
579+
pub(crate) fn coverage_cx(&self) -> &coverageinfo::CguCoverageContext<'ll, 'tcx> {
580580
self.coverage_cx.as_ref().expect("only called when coverage instrumentation is enabled")
581581
}
582582

compiler/rustc_codegen_llvm/src/coverageinfo/mod.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ mod llvm_cov;
2121
pub(crate) mod map_data;
2222
mod mapgen;
2323

24-
/// A context object for maintaining all state needed by the coverageinfo module.
25-
pub(crate) struct CrateCoverageContext<'ll, 'tcx> {
24+
/// Extra per-CGU context/state needed for coverage instrumentation.
25+
pub(crate) struct CguCoverageContext<'ll, 'tcx> {
2626
/// Coverage data for each instrumented function identified by DefId.
2727
pub(crate) function_coverage_map:
2828
RefCell<FxIndexMap<Instance<'tcx>, FunctionCoverageCollector<'tcx>>>,
@@ -32,7 +32,7 @@ pub(crate) struct CrateCoverageContext<'ll, 'tcx> {
3232
covfun_section_name: OnceCell<CString>,
3333
}
3434

35-
impl<'ll, 'tcx> CrateCoverageContext<'ll, 'tcx> {
35+
impl<'ll, 'tcx> CguCoverageContext<'ll, 'tcx> {
3636
pub(crate) fn new() -> Self {
3737
Self {
3838
function_coverage_map: Default::default(),

0 commit comments

Comments
 (0)