File tree 3 files changed +34
-1
lines changed
rustc_codegen_llvm/src/coverageinfo
rustc_mir/src/monomorphize/partitioning
3 files changed +34
-1
lines changed Original file line number Diff line number Diff line change @@ -284,7 +284,7 @@ fn add_unreachable_coverage<'tcx>(
284
284
let all_def_ids: DefIdSet =
285
285
tcx. mir_keys ( LOCAL_CRATE ) . iter ( ) . map ( |local_def_id| local_def_id. to_def_id ( ) ) . collect ( ) ;
286
286
287
- let ( codegenned_def_ids, _ ) = tcx. collect_and_partition_mono_items ( LOCAL_CRATE ) ;
287
+ let codegenned_def_ids = tcx. codegened_and_inlined_items ( LOCAL_CRATE ) ;
288
288
289
289
let mut unreachable_def_ids_by_file: FxHashMap < Symbol , Vec < DefId > > = FxHashMap :: default ( ) ;
290
290
for & non_codegenned_def_id in all_def_ids. difference ( codegenned_def_ids) {
Original file line number Diff line number Diff line change @@ -1397,6 +1397,14 @@ rustc_queries! {
1397
1397
query is_codegened_item( def_id: DefId ) -> bool {
1398
1398
desc { |tcx| "determining whether `{}` needs codegen" , tcx. def_path_str( def_id) }
1399
1399
}
1400
+
1401
+ /// All items participating in code generation together with items inlined into them.
1402
+ query codegened_and_inlined_items( _: CrateNum )
1403
+ -> & ' tcx DefIdSet {
1404
+ eval_always
1405
+ desc { "codegened_and_inlined_items" }
1406
+ }
1407
+
1400
1408
query codegen_unit( _: Symbol ) -> & ' tcx CodegenUnit <' tcx> {
1401
1409
desc { "codegen_unit" }
1402
1410
}
Original file line number Diff line number Diff line change @@ -424,8 +424,33 @@ fn collect_and_partition_mono_items<'tcx>(
424
424
( tcx. arena . alloc ( mono_items) , codegen_units)
425
425
}
426
426
427
+ fn codegened_and_inlined_items < ' tcx > ( tcx : TyCtxt < ' tcx > , cnum : CrateNum ) -> & ' tcx DefIdSet {
428
+ let ( items, cgus) = tcx. collect_and_partition_mono_items ( cnum) ;
429
+ let mut visited = DefIdSet :: default ( ) ;
430
+ let mut result = items. clone ( ) ;
431
+
432
+ for cgu in cgus {
433
+ for ( item, _) in cgu. items ( ) {
434
+ if let MonoItem :: Fn ( ref instance) = item {
435
+ let did = instance. def_id ( ) ;
436
+ if !visited. insert ( did) {
437
+ continue ;
438
+ }
439
+ for scope in & tcx. instance_mir ( instance. def ) . source_scopes {
440
+ if let Some ( ( ref inlined, _) ) = scope. inlined {
441
+ result. insert ( inlined. def_id ( ) ) ;
442
+ }
443
+ }
444
+ }
445
+ }
446
+ }
447
+
448
+ tcx. arena . alloc ( result)
449
+ }
450
+
427
451
pub fn provide ( providers : & mut Providers ) {
428
452
providers. collect_and_partition_mono_items = collect_and_partition_mono_items;
453
+ providers. codegened_and_inlined_items = codegened_and_inlined_items;
429
454
430
455
providers. is_codegened_item = |tcx, def_id| {
431
456
let ( all_mono_items, _) = tcx. collect_and_partition_mono_items ( LOCAL_CRATE ) ;
You can’t perform that action at this time.
0 commit comments