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.
This commit is contained in:
parent
0a1cd5baa4
commit
9fd6d97915
@ -864,15 +864,10 @@ fn debug_dump<'a, 'tcx: 'a>(tcx: TyCtxt<'tcx>, label: &str, cgus: &[CodegenUnit<
|
|||||||
cgu.size_estimate()
|
cgu.size_estimate()
|
||||||
);
|
);
|
||||||
|
|
||||||
// The order of `cgu.items()` is non-deterministic; sort it by name
|
for (item, linkage) in cgu.items_in_deterministic_order(tcx) {
|
||||||
// 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 {
|
|
||||||
let symbol_name = item.symbol_name(tcx).name;
|
let symbol_name = item.symbol_name(tcx).name;
|
||||||
let symbol_hash_start = symbol_name.rfind('h');
|
let symbol_hash_start = symbol_name.rfind('h');
|
||||||
let symbol_hash = symbol_hash_start.map_or("<no hash>", |i| &symbol_name[i..]);
|
let symbol_hash = symbol_hash_start.map_or("<no hash>", |i| &symbol_name[i..]);
|
||||||
|
|
||||||
let size = item.size_estimate(tcx);
|
let size = item.size_estimate(tcx);
|
||||||
let _ = with_no_trimmed_paths!(writeln!(
|
let _ = with_no_trimmed_paths!(writeln!(
|
||||||
s,
|
s,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user