Functions inlined into reachable functions are reachable
Consider functions to be reachable for code coverage purposes, either when they reach the code generation directly, or indirectly as inlined part of another function.
This commit is contained in:
parent
1796cc0e6c
commit
5a9538acb5
3 changed files with 34 additions and 1 deletions
|
@ -424,8 +424,33 @@ fn collect_and_partition_mono_items<'tcx>(
|
|||
(tcx.arena.alloc(mono_items), codegen_units)
|
||||
}
|
||||
|
||||
fn codegened_and_inlined_items<'tcx>(tcx: TyCtxt<'tcx>, cnum: CrateNum) -> &'tcx DefIdSet {
|
||||
let (items, cgus) = tcx.collect_and_partition_mono_items(cnum);
|
||||
let mut visited = DefIdSet::default();
|
||||
let mut result = items.clone();
|
||||
|
||||
for cgu in cgus {
|
||||
for (item, _) in cgu.items() {
|
||||
if let MonoItem::Fn(ref instance) = item {
|
||||
let did = instance.def_id();
|
||||
if !visited.insert(did) {
|
||||
continue;
|
||||
}
|
||||
for scope in &tcx.instance_mir(instance.def).source_scopes {
|
||||
if let Some((ref inlined, _)) = scope.inlined {
|
||||
result.insert(inlined.def_id());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
tcx.arena.alloc(result)
|
||||
}
|
||||
|
||||
pub fn provide(providers: &mut Providers) {
|
||||
providers.collect_and_partition_mono_items = collect_and_partition_mono_items;
|
||||
providers.codegened_and_inlined_items = codegened_and_inlined_items;
|
||||
|
||||
providers.is_codegened_item = |tcx, def_id| {
|
||||
let (all_mono_items, _) = tcx.collect_and_partition_mono_items(LOCAL_CRATE);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue