Skip to content

Commit

Permalink
Auto merge of #122627 - RalfJung:collector-stack-space, r=<try>
Browse files Browse the repository at this point in the history
collector: move ensure_sufficient_stack out of the loop

According to the docs this call has some overhead to putting it inside the loop doesn't seem like a good idea.

r? `@oli-obk`
  • Loading branch information
bors committed Mar 17, 2024
2 parents 1eb882e + 15f5307 commit b089dda
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions compiler/rustc_monomorphize/src/collector.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1433,7 +1433,7 @@ fn create_mono_items_for_default_impls<'tcx>(
}
}

/// Scans the CTFE alloc in order to find function calls, closures, and drop-glue.
/// Scans the CTFE alloc in order to find function pointers and statics that must be monomorphized.
fn collect_alloc<'tcx>(tcx: TyCtxt<'tcx>, alloc_id: AllocId, output: &mut MonoItems<'tcx>) {
match tcx.global_alloc(alloc_id) {
GlobalAlloc::Static(def_id) => {
Expand All @@ -1446,11 +1446,11 @@ fn collect_alloc<'tcx>(tcx: TyCtxt<'tcx>, alloc_id: AllocId, output: &mut MonoIt
}
GlobalAlloc::Memory(alloc) => {
trace!("collecting {:?} with {:#?}", alloc_id, alloc);
for &prov in alloc.inner().provenance().ptrs().values() {
rustc_data_structures::stack::ensure_sufficient_stack(|| {
rustc_data_structures::stack::ensure_sufficient_stack(move || {
for &prov in alloc.inner().provenance().ptrs().values() {
collect_alloc(tcx, prov.alloc_id(), output);
});
}
}
});
}
GlobalAlloc::Function(fn_instance) => {
if should_codegen_locally(tcx, &fn_instance) {
Expand Down

0 comments on commit b089dda

Please sign in to comment.