Skip to content

Commit 72e6841

Browse files
michaelwoeristeralexcrichton
authored andcommitted
Add symbol hash to trans::partitioning debug output.
1 parent 0386875 commit 72e6841

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
@@ -267,14 +267,14 @@ pub fn partition<'a, 'tcx, I>(scx: &SharedCrateContext<'a, 'tcx>,
267267
let mut initial_partitioning = place_root_translation_items(scx,
268268
trans_items);
269269

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

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

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

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

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

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

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

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

570581
debug!("");

0 commit comments

Comments
 (0)