Skip to content

Commit 155e6b9

Browse files
committed
Auto merge of #141560 - compiler-errors:incr-more-characteristic, r=<try>
[PERF] partition shims into CGU of their characteristic types, if possible We throw all non-`InstanceKind::Item` mono items into the same fallback CGU. This seems to have been a thing since #32779. This PR investigates: what happens to incremental codegen if we didn't do that, but tried a bit harder to partition shims into the same CGU as their characteristic types? r? `@ghost`
2 parents 283db70 + 3695a33 commit 155e6b9

File tree

1 file changed

+12
-20
lines changed

1 file changed

+12
-20
lines changed

compiler/rustc_monomorphize/src/partitioning.rs

Lines changed: 12 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -633,21 +633,24 @@ fn characteristic_def_id_of_mono_item<'tcx>(
633633
match mono_item {
634634
MonoItem::Fn(instance) => {
635635
let def_id = match instance.def {
636-
ty::InstanceKind::Item(def) => def,
637-
ty::InstanceKind::VTableShim(..)
636+
ty::InstanceKind::Item(..)
637+
| ty::InstanceKind::VTableShim(..)
638638
| ty::InstanceKind::ReifyShim(..)
639-
| ty::InstanceKind::FnPtrShim(..)
639+
| ty::InstanceKind::Virtual(..)
640640
| ty::InstanceKind::ClosureOnceShim { .. }
641641
| ty::InstanceKind::ConstructCoroutineInClosureShim { .. }
642-
| ty::InstanceKind::Intrinsic(..)
643-
| ty::InstanceKind::DropGlue(..)
644-
| ty::InstanceKind::Virtual(..)
645-
| ty::InstanceKind::CloneShim(..)
646-
| ty::InstanceKind::ThreadLocalShim(..)
642+
| ty::InstanceKind::CloneShim(..) => instance.def_id(),
643+
ty::InstanceKind::ThreadLocalShim(def_id) => def_id,
644+
ty::InstanceKind::Intrinsic(..)
645+
| ty::InstanceKind::FnPtrShim(..)
647646
| ty::InstanceKind::FnPtrAddrShim(..)
648647
| ty::InstanceKind::FutureDropPollShim(..)
649648
| ty::InstanceKind::AsyncDropGlue(..)
650-
| ty::InstanceKind::AsyncDropGlueCtorShim(..) => return None,
649+
| ty::InstanceKind::AsyncDropGlueCtorShim(..)
650+
| ty::InstanceKind::DropGlue(_, None) => return None,
651+
ty::InstanceKind::DropGlue(_, Some(ty)) => {
652+
return characteristic_def_id_of_type(ty);
653+
}
651654
};
652655

653656
// If this is a method, we want to put it into the same module as
@@ -661,17 +664,6 @@ fn characteristic_def_id_of_mono_item<'tcx>(
661664
}
662665

663666
if let Some(impl_def_id) = tcx.impl_of_method(def_id) {
664-
if tcx.sess.opts.incremental.is_some()
665-
&& tcx
666-
.trait_id_of_impl(impl_def_id)
667-
.is_some_and(|def_id| tcx.is_lang_item(def_id, LangItem::Drop))
668-
{
669-
// Put `Drop::drop` into the same cgu as `drop_in_place`
670-
// since `drop_in_place` is the only thing that can
671-
// call it.
672-
return None;
673-
}
674-
675667
// This is a method within an impl, find out what the self-type is:
676668
let impl_self_ty = tcx.instantiate_and_normalize_erasing_regions(
677669
instance.args,

0 commit comments

Comments
 (0)