File tree Expand file tree Collapse file tree 1 file changed +9
-3
lines changed
compiler/rustc_middle/src/mir Expand file tree Collapse file tree 1 file changed +9
-3
lines changed Original file line number Diff line number Diff line change @@ -566,10 +566,16 @@ impl<'tcx> CodegenUnit<'tcx> {
566566
567567 let mut items: Vec < _ > = self . items ( ) . iter ( ) . map ( |( & i, & data) | ( i, data) ) . collect ( ) ;
568568 if !tcx. sess . opts . unstable_opts . codegen_source_order {
569- // It's already deterministic, so we can just use it.
570- return items;
569+ // The input item list is already produced in a deterministic matter, so we can just
570+ // use it.
571+ // However, it seems that actually moving related things (probably mainly different
572+ // monomorphizations of the same item) close to one another is actually beneficial for
573+ // perf.
574+ // Sorting by symbol name should not incur any non-determinism.
575+ items. sort_by_cached_key ( |& ( i, _) | i. symbol_name ( tcx) ) ;
576+ } else {
577+ items. sort_by_cached_key ( |& ( i, _) | item_sort_key ( tcx, i) ) ;
571578 }
572- items. sort_by_cached_key ( |& ( i, _) | item_sort_key ( tcx, i) ) ;
573579 items
574580 }
575581
You can’t perform that action at this time.
0 commit comments