diff options
| author | Nicholas Nethercote <n.nethercote@gmail.com> | 2023-06-02 14:12:05 +1000 |
|---|---|---|
| committer | Nicholas Nethercote <n.nethercote@gmail.com> | 2023-06-07 10:26:58 +1000 |
| commit | 9fd6d979152db51271b12ad66ab7e8352e2bbd4f (patch) | |
| tree | f203e52947ab7137a8822fba107e73efd85bde2f | |
| parent | 0a1cd5baa4d0ad4994f4038988a76770a6e2150c (diff) | |
| download | rust-9fd6d979152db51271b12ad66ab7e8352e2bbd4f.tar.gz rust-9fd6d979152db51271b12ad66ab7e8352e2bbd4f.zip | |
Improve sorting in `debug_dump`.
Currently it sorts by symbol name, which is a mangled name like `_ZN1a4main17hb29587cdb6db5f42E`, which leads to non-obvious orderings. This commit changes it to use the existing `items_in_deterministic_order`, which iterates in source code order.
| -rw-r--r-- | compiler/rustc_monomorphize/src/partitioning.rs | 7 |
1 files changed, 1 insertions, 6 deletions
diff --git a/compiler/rustc_monomorphize/src/partitioning.rs b/compiler/rustc_monomorphize/src/partitioning.rs index e99551410e0..2909042a931 100644 --- a/compiler/rustc_monomorphize/src/partitioning.rs +++ b/compiler/rustc_monomorphize/src/partitioning.rs @@ -864,15 +864,10 @@ fn debug_dump<'a, 'tcx: 'a>(tcx: TyCtxt<'tcx>, label: &str, cgus: &[CodegenUnit< cgu.size_estimate() ); - // The order of `cgu.items()` is non-deterministic; sort it by name - // to give deterministic output. - let mut items: Vec<_> = cgu.items().iter().collect(); - items.sort_by_key(|(item, _)| item.symbol_name(tcx).name); - for (item, linkage) in items { + for (item, linkage) in cgu.items_in_deterministic_order(tcx) { let symbol_name = item.symbol_name(tcx).name; let symbol_hash_start = symbol_name.rfind('h'); let symbol_hash = symbol_hash_start.map_or("<no hash>", |i| &symbol_name[i..]); - let size = item.size_estimate(tcx); let _ = with_no_trimmed_paths!(writeln!( s, |
