mirror of
https://github.com/rust-lang/rust.git
synced 2025-06-05 11:48:30 +00:00
Merge the two loops in internalize_symbols
.
Because they have a lot of overlap.
This commit is contained in:
parent
392045b7e7
commit
fe3b646565
@ -486,21 +486,7 @@ fn internalize_symbols<'tcx>(
|
|||||||
mono_item_placements: FxHashMap<MonoItem<'tcx>, MonoItemPlacement>,
|
mono_item_placements: FxHashMap<MonoItem<'tcx>, MonoItemPlacement>,
|
||||||
internalization_candidates: FxHashSet<MonoItem<'tcx>>,
|
internalization_candidates: FxHashSet<MonoItem<'tcx>>,
|
||||||
) {
|
) {
|
||||||
if codegen_units.len() == 1 {
|
let single_codegen_unit = codegen_units.len() == 1;
|
||||||
// Fast path for when there is only one codegen unit. In this case we
|
|
||||||
// can internalize all candidates, since there is nowhere else they
|
|
||||||
// could be used from.
|
|
||||||
for cgu in codegen_units {
|
|
||||||
for (item, linkage_and_visibility) in cgu.items_mut() {
|
|
||||||
if !internalization_candidates.contains(item) {
|
|
||||||
// This item is no candidate for internalizing, so skip it.
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
*linkage_and_visibility = (Linkage::Internal, Visibility::Default);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// For each internalization candidates in each codegen unit, check if it is
|
// For each internalization candidates in each codegen unit, check if it is
|
||||||
// used from outside its defining codegen unit.
|
// used from outside its defining codegen unit.
|
||||||
@ -512,21 +498,24 @@ fn internalize_symbols<'tcx>(
|
|||||||
// This item is no candidate for internalizing, so skip it.
|
// This item is no candidate for internalizing, so skip it.
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
debug_assert_eq!(mono_item_placements[item], home_cgu);
|
|
||||||
|
|
||||||
if let Some(user_items) = cx.usage_map.get_user_items(*item) {
|
if !single_codegen_unit {
|
||||||
if user_items
|
debug_assert_eq!(mono_item_placements[item], home_cgu);
|
||||||
.iter()
|
|
||||||
.filter_map(|user_item| {
|
if let Some(user_items) = cx.usage_map.get_user_items(*item) {
|
||||||
// Some user mono items might not have been
|
if user_items
|
||||||
// instantiated. We can safely ignore those.
|
.iter()
|
||||||
mono_item_placements.get(user_item)
|
.filter_map(|user_item| {
|
||||||
})
|
// Some user mono items might not have been
|
||||||
.any(|placement| *placement != home_cgu)
|
// instantiated. We can safely ignore those.
|
||||||
{
|
mono_item_placements.get(user_item)
|
||||||
// Found a user from another CGU, so skip to the next item
|
})
|
||||||
// without marking this one as internal.
|
.any(|placement| *placement != home_cgu)
|
||||||
continue;
|
{
|
||||||
|
// Found a user from another CGU, so skip to the next item
|
||||||
|
// without marking this one as internal.
|
||||||
|
continue;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user