@@ -646,14 +646,11 @@ impl<'mir, 'tcx, M: Machine<'mir, 'tcx>> Memory<'mir, 'tcx, M> {
646
646
647
647
fn dump_alloc_helper < Tag , Extra > (
648
648
& self ,
649
- allocs_seen : & mut FxHashSet < AllocId > ,
650
649
allocs_to_print : & mut VecDeque < AllocId > ,
651
650
alloc : & Allocation < Tag , Extra > ,
652
651
) {
653
652
for & ( _, target_id) in alloc. relocations ( ) . values ( ) {
654
- if allocs_seen. insert ( target_id) {
655
- allocs_to_print. push_back ( target_id) ;
656
- }
653
+ allocs_to_print. push_back ( target_id) ;
657
654
}
658
655
crate :: util:: pretty:: write_allocation ( self . tcx . tcx , alloc, & mut std:: io:: stderr ( ) , "" )
659
656
. unwrap ( ) ;
@@ -666,9 +663,14 @@ impl<'mir, 'tcx, M: Machine<'mir, 'tcx>> Memory<'mir, 'tcx, M> {
666
663
allocs. sort ( ) ;
667
664
allocs. dedup ( ) ;
668
665
let mut allocs_to_print = VecDeque :: from ( allocs) ;
669
- let mut allocs_seen = FxHashSet :: default ( ) ;
666
+ // `allocs_printed` contains all allocations that we have already printed.
667
+ let mut allocs_printed = FxHashSet :: default ( ) ;
670
668
671
669
while let Some ( id) = allocs_to_print. pop_front ( ) {
670
+ if !allocs_printed. insert ( id) {
671
+ // Already printed, so skip this.
672
+ continue ;
673
+ }
672
674
eprint ! ( "Alloc {:<5}: " , id) ;
673
675
fn msg < Tag , Extra > ( alloc : & Allocation < Tag , Extra > , extra : & str ) {
674
676
eprintln ! (
@@ -688,14 +690,14 @@ impl<'mir, 'tcx, M: Machine<'mir, 'tcx>> Memory<'mir, 'tcx, M> {
688
690
MemoryKind :: CallerLocation => msg ( alloc, " (caller_location)" ) ,
689
691
MemoryKind :: Machine ( m) => msg ( alloc, & format ! ( " ({:?})" , m) ) ,
690
692
} ;
691
- self . dump_alloc_helper ( & mut allocs_seen , & mut allocs_to_print, alloc) ;
693
+ self . dump_alloc_helper ( & mut allocs_to_print, alloc) ;
692
694
}
693
695
Err ( ( ) ) => {
694
696
// global alloc?
695
697
match self . tcx . alloc_map . lock ( ) . get ( id) {
696
698
Some ( GlobalAlloc :: Memory ( alloc) ) => {
697
699
msg ( alloc, " (immutable)" ) ;
698
- self . dump_alloc_helper ( & mut allocs_seen , & mut allocs_to_print, alloc) ;
700
+ self . dump_alloc_helper ( & mut allocs_to_print, alloc) ;
699
701
}
700
702
Some ( GlobalAlloc :: Function ( func) ) => {
701
703
eprintln ! ( "{}" , func) ;
@@ -722,8 +724,8 @@ impl<'mir, 'tcx, M: Machine<'mir, 'tcx>> Memory<'mir, 'tcx, M> {
722
724
} ) ;
723
725
while let Some ( id) = todo. pop ( ) {
724
726
if reachable. insert ( id) {
727
+ // This is a new allocation, add its relocations to `todo`.
725
728
if let Some ( ( _, alloc) ) = self . alloc_map . get ( id) {
726
- // This is a new allocation, add its relocations to `todo`.
727
729
todo. extend ( alloc. relocations ( ) . values ( ) . map ( |& ( _, target_id) | target_id) ) ;
728
730
}
729
731
}
0 commit comments