@@ -11,7 +11,6 @@ use rustc_abi::Align;
1111use  rustc_codegen_ssa:: traits:: { 
1212    BaseTypeCodegenMethods  as  _,  ConstCodegenMethods ,  StaticCodegenMethods , 
1313} ; 
14- use  rustc_index:: IndexVec ; 
1514use  rustc_middle:: mir:: coverage:: { 
1615    BasicCoverageBlock ,  CovTerm ,  CoverageIdsInfo ,  Expression ,  FunctionCoverageInfo ,  Mapping , 
1716    MappingKind ,  Op , 
@@ -105,16 +104,6 @@ fn fill_region_tables<'tcx>(
105104    ids_info :  & ' tcx  CoverageIdsInfo , 
106105    covfun :  & mut  CovfunRecord < ' tcx > , 
107106)  { 
108-     // If this function is unused, replace all counters with zero. 
109-     let  counter_for_bcb = |bcb :  BasicCoverageBlock | -> ffi:: Counter  { 
110-         let  term = if  covfun. is_used  { 
111-             ids_info. term_for_bcb [ bcb] . expect ( "every BCB in a mapping was given a term" ) 
112-         }  else  { 
113-             CovTerm :: Zero 
114-         } ; 
115-         ffi:: Counter :: from_term ( term) 
116-     } ; 
117- 
118107    // Currently a function's mappings must all be in the same file, so use the 
119108    // first mapping's span to determine the file. 
120109    let  source_map = tcx. sess . source_map ( ) ; 
@@ -126,12 +115,6 @@ fn fill_region_tables<'tcx>(
126115
127116    let  local_file_id = covfun. virtual_file_mapping . push_file ( & source_file) ; 
128117
129-     // If this testing flag is set, add an extra unused entry to the local 
130-     // file table, to help test the code for detecting unused file IDs. 
131-     if  tcx. sess . coverage_inject_unused_local_file ( )  { 
132-         covfun. virtual_file_mapping . push_file ( & source_file) ; 
133-     } 
134- 
135118    // In rare cases, _all_ of a function's spans are discarded, and coverage 
136119    // codegen needs to handle that gracefully to avoid #133606. 
137120    // It's hard for tests to trigger this organically, so instead we set 
@@ -152,6 +135,16 @@ fn fill_region_tables<'tcx>(
152135    // For each counter/region pair in this function+file, convert it to a 
153136    // form suitable for FFI. 
154137    for  & Mapping  {  ref  kind,  span }  in  & fn_cov_info. mappings  { 
138+         // If this function is unused, replace all counters with zero. 
139+         let  counter_for_bcb = |bcb :  BasicCoverageBlock | -> ffi:: Counter  { 
140+             let  term = if  covfun. is_used  { 
141+                 ids_info. term_for_bcb [ bcb] . expect ( "every BCB in a mapping was given a term" ) 
142+             }  else  { 
143+                 CovTerm :: Zero 
144+             } ; 
145+             ffi:: Counter :: from_term ( term) 
146+         } ; 
147+ 
155148        let  Some ( coords)  = make_coords ( span)  else  {  continue  } ; 
156149        let  cov_span = coords. make_coverage_span ( local_file_id) ; 
157150
@@ -184,19 +177,6 @@ fn fill_region_tables<'tcx>(
184177    } 
185178} 
186179
187- /// LLVM requires all local file IDs to have at least one mapping region. 
188- /// If that's not the case, skip this function, to avoid an assertion failure 
189- /// (or worse) in LLVM. 
190- fn  check_local_file_table ( covfun :  & CovfunRecord < ' _ > )  -> bool  { 
191-     let  mut  local_file_id_seen =
192-         IndexVec :: < u32 ,  _ > :: from_elem_n ( false ,  covfun. virtual_file_mapping . local_file_table . len ( ) ) ; 
193-     for  cov_span in  covfun. regions . all_cov_spans ( )  { 
194-         local_file_id_seen[ cov_span. file_id ]  = true ; 
195-     } 
196- 
197-     local_file_id_seen. into_iter ( ) . all ( |seen| seen) 
198- } 
199- 
200180/// Generates the contents of the covfun record for this function, which 
201181/// contains the function's coverage mapping data. The record is then stored 
202182/// as a global variable in the `__llvm_covfun` section. 
@@ -205,10 +185,6 @@ pub(crate) fn generate_covfun_record<'tcx>(
205185    global_file_table :  & GlobalFileTable , 
206186    covfun :  & CovfunRecord < ' tcx > , 
207187)  { 
208-     if  !check_local_file_table ( covfun)  { 
209-         return ; 
210-     } 
211- 
212188    let  & CovfunRecord  { 
213189        mangled_function_name, 
214190        source_hash, 
0 commit comments