Skip to content

Commit 4570199

Browse files
Add symbol hash to trans::partitioning debug output.
1 parent 29212ec commit 4570199

File tree

1 file changed

+16
-5
lines changed

1 file changed

+16
-5
lines changed

src/librustc_trans/partitioning.rs

+16-5
Original file line numberDiff line numberDiff line change
@@ -266,14 +266,14 @@ pub fn partition<'a, 'tcx, I>(scx: &SharedCrateContext<'a, 'tcx>,
266266
let mut initial_partitioning = place_root_translation_items(scx,
267267
trans_items);
268268

269-
debug_dump(tcx, "INITIAL PARTITONING:", initial_partitioning.codegen_units.iter());
269+
debug_dump(scx, "INITIAL PARTITONING:", initial_partitioning.codegen_units.iter());
270270

271271
// If the partitioning should produce a fixed count of codegen units, merge
272272
// until that count is reached.
273273
if let PartitioningStrategy::FixedUnitCount(count) = strategy {
274274
merge_codegen_units(&mut initial_partitioning, count, &tcx.crate_name[..]);
275275

276-
debug_dump(tcx, "POST MERGING:", initial_partitioning.codegen_units.iter());
276+
debug_dump(scx, "POST MERGING:", initial_partitioning.codegen_units.iter());
277277
}
278278

279279
// In the next step, we use the inlining map to determine which addtional
@@ -283,7 +283,7 @@ pub fn partition<'a, 'tcx, I>(scx: &SharedCrateContext<'a, 'tcx>,
283283
let post_inlining = place_inlined_translation_items(initial_partitioning,
284284
inlining_map);
285285

286-
debug_dump(tcx, "POST INLINING:", post_inlining.0.iter());
286+
debug_dump(scx, "POST INLINING:", post_inlining.0.iter());
287287

288288
// Finally, sort by codegen unit name, so that we get deterministic results
289289
let mut result = post_inlining.0;
@@ -551,7 +551,7 @@ fn numbered_codegen_unit_name(crate_name: &str, index: usize) -> InternedString
551551
index)[..])
552552
}
553553

554-
fn debug_dump<'a, 'b, 'tcx, I>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
554+
fn debug_dump<'a, 'b, 'tcx, I>(scx: &SharedCrateContext<'a, 'tcx>,
555555
label: &str,
556556
cgus: I)
557557
where I: Iterator<Item=&'b CodegenUnit<'tcx>>,
@@ -560,10 +560,21 @@ fn debug_dump<'a, 'b, 'tcx, I>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
560560
if cfg!(debug_assertions) {
561561
debug!("{}", label);
562562
for cgu in cgus {
563+
let symbol_map = SymbolMap::build(scx, cgu.items
564+
.iter()
565+
.map(|(&trans_item, _)| trans_item));
563566
debug!("CodegenUnit {}:", cgu.name);
564567

565568
for (trans_item, linkage) in &cgu.items {
566-
debug!(" - {} [{:?}]", trans_item.to_string(tcx), linkage);
569+
let symbol_name = symbol_map.get_or_compute(scx, *trans_item);
570+
let symbol_hash_start = symbol_name.rfind('h');
571+
let symbol_hash = symbol_hash_start.map(|i| &symbol_name[i ..])
572+
.unwrap_or("<no hash>");
573+
574+
debug!(" - {} [{:?}] [{}]",
575+
trans_item.to_string(scx.tcx()),
576+
linkage,
577+
symbol_hash);
567578
}
568579

569580
debug!("");

0 commit comments

Comments
 (0)