@@ -11,7 +11,6 @@ use rustc_abi::Align;
11
11
use rustc_codegen_ssa:: traits:: {
12
12
BaseTypeCodegenMethods as _, ConstCodegenMethods , StaticCodegenMethods ,
13
13
} ;
14
- use rustc_index:: IndexVec ;
15
14
use rustc_middle:: mir:: coverage:: {
16
15
BasicCoverageBlock , CovTerm , CoverageIdsInfo , Expression , FunctionCoverageInfo , Mapping ,
17
16
MappingKind , Op ,
@@ -105,16 +104,6 @@ fn fill_region_tables<'tcx>(
105
104
ids_info : & ' tcx CoverageIdsInfo ,
106
105
covfun : & mut CovfunRecord < ' tcx > ,
107
106
) {
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
-
118
107
// Currently a function's mappings must all be in the same file, so use the
119
108
// first mapping's span to determine the file.
120
109
let source_map = tcx. sess . source_map ( ) ;
@@ -126,12 +115,6 @@ fn fill_region_tables<'tcx>(
126
115
127
116
let local_file_id = covfun. virtual_file_mapping . push_file ( & source_file) ;
128
117
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
-
135
118
// In rare cases, _all_ of a function's spans are discarded, and coverage
136
119
// codegen needs to handle that gracefully to avoid #133606.
137
120
// It's hard for tests to trigger this organically, so instead we set
@@ -152,6 +135,16 @@ fn fill_region_tables<'tcx>(
152
135
// For each counter/region pair in this function+file, convert it to a
153
136
// form suitable for FFI.
154
137
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
+
155
148
let Some ( coords) = make_coords ( span) else { continue } ;
156
149
let cov_span = coords. make_coverage_span ( local_file_id) ;
157
150
@@ -184,19 +177,6 @@ fn fill_region_tables<'tcx>(
184
177
}
185
178
}
186
179
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
-
200
180
/// Generates the contents of the covfun record for this function, which
201
181
/// contains the function's coverage mapping data. The record is then stored
202
182
/// as a global variable in the `__llvm_covfun` section.
@@ -205,10 +185,6 @@ pub(crate) fn generate_covfun_record<'tcx>(
205
185
global_file_table : & GlobalFileTable ,
206
186
covfun : & CovfunRecord < ' tcx > ,
207
187
) {
208
- if !check_local_file_table ( covfun) {
209
- return ;
210
- }
211
-
212
188
let & CovfunRecord {
213
189
mangled_function_name,
214
190
source_hash,
0 commit comments