Skip to content

Commit 576deef

Browse files
committed
mir: rename should_monomorphize_locally
This commit renames `should_monomorphize_locally` to `should_codegen_locally` which better describes what the function determines once polymorphization is added. Signed-off-by: David Wood <david@davidtw.co>
1 parent 996bc9a commit 576deef

File tree

1 file changed

+12
-13
lines changed

1 file changed

+12
-13
lines changed

src/librustc_mir/monomorphize/collector.rs

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -358,7 +358,7 @@ fn collect_items_rec<'tcx>(
358358
let instance = Instance::mono(tcx, def_id);
359359

360360
// Sanity check whether this ended up being collected accidentally
361-
debug_assert!(should_monomorphize_locally(tcx, &instance));
361+
debug_assert!(should_codegen_locally(tcx, &instance));
362362

363363
let ty = instance.monomorphic_ty(tcx);
364364
visit_drop_use(tcx, ty, true, starting_point.span, &mut neighbors);
@@ -371,7 +371,7 @@ fn collect_items_rec<'tcx>(
371371
}
372372
MonoItem::Fn(instance) => {
373373
// Sanity check whether this ended up being collected accidentally
374-
debug_assert!(should_monomorphize_locally(tcx, &instance));
374+
debug_assert!(should_codegen_locally(tcx, &instance));
375375

376376
// Keep track of the monomorphization recursion depth
377377
recursion_depth_reset =
@@ -584,7 +584,7 @@ impl<'a, 'tcx> MirVisitor<'tcx> for MirNeighborCollector<'a, 'tcx> {
584584
substs,
585585
ty::ClosureKind::FnOnce,
586586
);
587-
if should_monomorphize_locally(self.tcx, &instance) {
587+
if should_codegen_locally(self.tcx, &instance) {
588588
self.output.push(create_fn_mono_item(instance, span));
589589
}
590590
}
@@ -596,14 +596,14 @@ impl<'a, 'tcx> MirVisitor<'tcx> for MirNeighborCollector<'a, 'tcx> {
596596
let exchange_malloc_fn_def_id =
597597
tcx.require_lang_item(ExchangeMallocFnLangItem, None);
598598
let instance = Instance::mono(tcx, exchange_malloc_fn_def_id);
599-
if should_monomorphize_locally(tcx, &instance) {
599+
if should_codegen_locally(tcx, &instance) {
600600
self.output.push(create_fn_mono_item(instance, span));
601601
}
602602
}
603603
mir::Rvalue::ThreadLocalRef(def_id) => {
604604
assert!(self.tcx.is_thread_local_static(def_id));
605605
let instance = Instance::mono(self.tcx, def_id);
606-
if should_monomorphize_locally(self.tcx, &instance) {
606+
if should_codegen_locally(self.tcx, &instance) {
607607
trace!("collecting thread-local static {:?}", def_id);
608608
self.output.push(respan(span, MonoItem::Static(def_id)));
609609
}
@@ -664,7 +664,7 @@ impl<'a, 'tcx> MirVisitor<'tcx> for MirNeighborCollector<'a, 'tcx> {
664664
}
665665
mir::InlineAsmOperand::SymStatic { def_id } => {
666666
let instance = Instance::mono(self.tcx, def_id);
667-
if should_monomorphize_locally(self.tcx, &instance) {
667+
if should_codegen_locally(self.tcx, &instance) {
668668
trace!("collecting asm sym static {:?}", def_id);
669669
self.output.push(respan(source, MonoItem::Static(def_id)));
670670
}
@@ -735,7 +735,7 @@ fn visit_instance_use<'tcx>(
735735
output: &mut Vec<Spanned<MonoItem<'tcx>>>,
736736
) {
737737
debug!("visit_item_use({:?}, is_direct_call={:?})", instance, is_direct_call);
738-
if !should_monomorphize_locally(tcx, &instance) {
738+
if !should_codegen_locally(tcx, &instance) {
739739
return;
740740
}
741741

@@ -766,7 +766,7 @@ fn visit_instance_use<'tcx>(
766766
// Returns `true` if we should codegen an instance in the local crate.
767767
// Returns `false` if we can just link to the upstream crate and therefore don't
768768
// need a mono item.
769-
fn should_monomorphize_locally<'tcx>(tcx: TyCtxt<'tcx>, instance: &Instance<'tcx>) -> bool {
769+
fn should_codegen_locally<'tcx>(tcx: TyCtxt<'tcx>, instance: &Instance<'tcx>) -> bool {
770770
let def_id = match instance.def {
771771
ty::InstanceDef::Item(def) => def.did,
772772
ty::InstanceDef::DropGlue(def_id, Some(_)) => def_id,
@@ -944,7 +944,7 @@ fn create_mono_items_for_vtable_methods<'tcx>(
944944
)
945945
.unwrap()
946946
})
947-
.filter(|&instance| should_monomorphize_locally(tcx, &instance))
947+
.filter(|&instance| should_codegen_locally(tcx, &instance))
948948
.map(|item| create_fn_mono_item(item, source));
949949
output.extend(methods);
950950
}
@@ -1164,8 +1164,7 @@ fn create_mono_items_for_default_impls<'tcx>(
11641164
.unwrap();
11651165

11661166
let mono_item = create_fn_mono_item(instance, DUMMY_SP);
1167-
if mono_item.node.is_instantiable(tcx)
1168-
&& should_monomorphize_locally(tcx, &instance)
1167+
if mono_item.node.is_instantiable(tcx) && should_codegen_locally(tcx, &instance)
11691168
{
11701169
output.push(mono_item);
11711170
}
@@ -1186,7 +1185,7 @@ fn collect_miri<'tcx>(
11861185
GlobalAlloc::Static(def_id) => {
11871186
assert!(!tcx.is_thread_local_static(def_id));
11881187
let instance = Instance::mono(tcx, def_id);
1189-
if should_monomorphize_locally(tcx, &instance) {
1188+
if should_codegen_locally(tcx, &instance) {
11901189
trace!("collecting static {:?}", def_id);
11911190
output.push(dummy_spanned(MonoItem::Static(def_id)));
11921191
}
@@ -1200,7 +1199,7 @@ fn collect_miri<'tcx>(
12001199
}
12011200
}
12021201
GlobalAlloc::Function(fn_instance) => {
1203-
if should_monomorphize_locally(tcx, &fn_instance) {
1202+
if should_codegen_locally(tcx, &fn_instance) {
12041203
trace!("collecting {:?} with {:#?}", alloc_id, fn_instance);
12051204
output.push(create_fn_mono_item(fn_instance, DUMMY_SP));
12061205
}

0 commit comments

Comments
 (0)