@@ -10,8 +10,8 @@ use std::sync::Arc;
1010use rustc_abi:: Align ;
1111use rustc_codegen_ssa:: traits:: { BaseTypeCodegenMethods as _, ConstCodegenMethods } ;
1212use rustc_middle:: mir:: coverage:: {
13- BasicCoverageBlock , CovTerm , CoverageIdsInfo , Expression , FunctionCoverageInfo , Mapping ,
14- MappingKind , Op ,
13+ BasicCoverageBlock , CounterId , CovTerm , CoverageIdsInfo , Expression , ExpressionId ,
14+ FunctionCoverageInfo , Mapping , MappingKind , Op ,
1515} ;
1616use rustc_middle:: ty:: { Instance , TyCtxt } ;
1717use rustc_span:: { SourceFile , Span } ;
@@ -36,7 +36,7 @@ pub(crate) struct CovfunRecord<'tcx> {
3636
3737 virtual_file_mapping : VirtualFileMapping ,
3838 expressions : Vec < ffi:: CounterExpression > ,
39- regions : ffi :: Regions ,
39+ regions : llvm_cov :: Regions ,
4040}
4141
4242impl < ' tcx > CovfunRecord < ' tcx > {
@@ -64,7 +64,7 @@ pub(crate) fn prepare_covfun_record<'tcx>(
6464 is_used,
6565 virtual_file_mapping : VirtualFileMapping :: default ( ) ,
6666 expressions,
67- regions : ffi :: Regions :: default ( ) ,
67+ regions : llvm_cov :: Regions :: default ( ) ,
6868 } ;
6969
7070 fill_region_tables ( tcx, fn_cov_info, ids_info, & mut covfun) ;
@@ -77,10 +77,21 @@ pub(crate) fn prepare_covfun_record<'tcx>(
7777 Some ( covfun)
7878}
7979
80+ pub ( crate ) fn counter_for_term ( term : CovTerm ) -> ffi:: Counter {
81+ use ffi:: Counter ;
82+ match term {
83+ CovTerm :: Zero => Counter :: ZERO ,
84+ CovTerm :: Counter ( id) => {
85+ Counter { kind : ffi:: CounterKind :: CounterValueReference , id : CounterId :: as_u32 ( id) }
86+ }
87+ CovTerm :: Expression ( id) => {
88+ Counter { kind : ffi:: CounterKind :: Expression , id : ExpressionId :: as_u32 ( id) }
89+ }
90+ }
91+ }
92+
8093/// Convert the function's coverage-counter expressions into a form suitable for FFI.
8194fn prepare_expressions ( ids_info : & CoverageIdsInfo ) -> Vec < ffi:: CounterExpression > {
82- let counter_for_term = ffi:: Counter :: from_term;
83-
8495 // We know that LLVM will optimize out any unused expressions before
8596 // producing the final coverage map, so there's no need to do the same
8697 // thing on the Rust side unless we're confident we can do much better.
@@ -113,7 +124,7 @@ fn fill_region_tables<'tcx>(
113124 } else {
114125 CovTerm :: Zero
115126 } ;
116- ffi :: Counter :: from_term ( term)
127+ counter_for_term ( term)
117128 } ;
118129
119130 // Currently a function's mappings must all be in the same file, so use the
@@ -136,7 +147,7 @@ fn fill_region_tables<'tcx>(
136147 if discard_all { None } else { spans:: make_coords ( source_map, & source_file, span) }
137148 } ;
138149
139- let ffi :: Regions {
150+ let llvm_cov :: Regions {
140151 code_regions,
141152 expansion_regions : _, // FIXME(Zalathar): Fill out support for expansion regions
142153 branch_regions,
0 commit comments