Apply suggestions from oli-obk's review
Co-authored-by: Oli Scherer <github35764891676564198441@oli-obk.de>
This commit is contained in:
parent
af10880f6b
commit
1a8eae1aba
@ -470,22 +470,16 @@ fn upstream_drop_glue_for_provider<'tcx>(
|
|||||||
tcx: TyCtxt<'tcx>,
|
tcx: TyCtxt<'tcx>,
|
||||||
args: GenericArgsRef<'tcx>,
|
args: GenericArgsRef<'tcx>,
|
||||||
) -> Option<CrateNum> {
|
) -> Option<CrateNum> {
|
||||||
if let Some(def_id) = tcx.lang_items().drop_in_place_fn() {
|
let def_id = tcx.lang_items().drop_in_place_fn()?;
|
||||||
tcx.upstream_monomorphizations_for(def_id).and_then(|monos| monos.get(&args).cloned())
|
tcx.upstream_monomorphizations_for(def_id)?.get(&args).cloned()
|
||||||
} else {
|
|
||||||
None
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn upstream_async_drop_glue_for_provider<'tcx>(
|
fn upstream_async_drop_glue_for_provider<'tcx>(
|
||||||
tcx: TyCtxt<'tcx>,
|
tcx: TyCtxt<'tcx>,
|
||||||
args: GenericArgsRef<'tcx>,
|
args: GenericArgsRef<'tcx>,
|
||||||
) -> Option<CrateNum> {
|
) -> Option<CrateNum> {
|
||||||
if let Some(def_id) = tcx.lang_items().async_drop_in_place_fn() {
|
let def_id = tcx.lang_items().async_drop_in_place_fn()?;
|
||||||
tcx.upstream_monomorphizations_for(def_id).and_then(|monos| monos.get(&args).cloned())
|
tcx.upstream_monomorphizations_for(def_id)?.get(&args).cloned()
|
||||||
} else {
|
|
||||||
None
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn is_unreachable_local_definition_provider(tcx: TyCtxt<'_>, def_id: LocalDefId) -> bool {
|
fn is_unreachable_local_definition_provider(tcx: TyCtxt<'_>, def_id: LocalDefId) -> bool {
|
||||||
|
@ -314,7 +314,9 @@ pub fn generates_cgu_internal_copy(&self, tcx: TyCtxt<'tcx>) -> bool {
|
|||||||
if self.requires_inline(tcx) {
|
if self.requires_inline(tcx) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if let ty::InstanceKind::DropGlue(.., Some(ty)) = *self {
|
if let ty::InstanceKind::DropGlue(.., Some(ty))
|
||||||
|
| ty::InstanceKind::AsyncDropGlueCtorShim(.., Some(ty)) = *self
|
||||||
|
{
|
||||||
// Drop glue generally wants to be instantiated at every codegen
|
// Drop glue generally wants to be instantiated at every codegen
|
||||||
// unit, but without an #[inline] hint. We should make this
|
// unit, but without an #[inline] hint. We should make this
|
||||||
// available to normal end-users.
|
// available to normal end-users.
|
||||||
@ -329,29 +331,14 @@ pub fn generates_cgu_internal_copy(&self, tcx: TyCtxt<'tcx>) -> bool {
|
|||||||
// drops of `Option::None` before LTO. We also respect the intent of
|
// drops of `Option::None` before LTO. We also respect the intent of
|
||||||
// `#[inline]` on `Drop::drop` implementations.
|
// `#[inline]` on `Drop::drop` implementations.
|
||||||
return ty.ty_adt_def().map_or(true, |adt_def| {
|
return ty.ty_adt_def().map_or(true, |adt_def| {
|
||||||
adt_def
|
match *self {
|
||||||
.destructor(tcx)
|
ty::InstanceKind::DropGlue(..) => adt_def.destructor(tcx).map(|dtor| dtor.did),
|
||||||
.map_or_else(|| adt_def.is_enum(), |dtor| tcx.cross_crate_inlinable(dtor.did))
|
ty::InstanceKind::AsyncDropGlueCtorShim(..) => {
|
||||||
});
|
adt_def.async_destructor(tcx).map(|dtor| dtor.ctor)
|
||||||
}
|
}
|
||||||
if let ty::InstanceKind::AsyncDropGlueCtorShim(.., Some(ty)) = *self {
|
_ => unreachable!(),
|
||||||
// Async drop glue generally wants to be instantiated at
|
|
||||||
// every codegen unit, but without an #[inline] hint. We
|
|
||||||
// should make this available to normal end-users.
|
|
||||||
if tcx.sess.opts.incremental.is_none() {
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
// When compiling with incremental, we can generate a *lot* of
|
.map_or_else(|| adt_def.is_enum(), |did| tcx.cross_crate_inlinable(did))
|
||||||
// codegen units. Including drop glue into all of them has a
|
|
||||||
// considerable compile time cost.
|
|
||||||
//
|
|
||||||
// We include enums without destructors to allow, say, optimizing
|
|
||||||
// drops of `Option::None` before LTO. We also respect the intent of
|
|
||||||
// `#[inline]` on `Drop::drop` implementations.
|
|
||||||
return ty.ty_adt_def().map_or(true, |adt_def| {
|
|
||||||
adt_def
|
|
||||||
.async_destructor(tcx)
|
|
||||||
.map_or_else(|| adt_def.is_enum(), |dtor| tcx.cross_crate_inlinable(dtor.ctor))
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
if let ty::InstanceKind::ThreadLocalShim(..) = *self {
|
if let ty::InstanceKind::ThreadLocalShim(..) = *self {
|
||||||
|
Loading…
Reference in New Issue
Block a user