@@ -599,10 +599,11 @@ impl Map {
599
599
tcx : TyCtxt < ' tcx > ,
600
600
body : & Body < ' tcx > ,
601
601
filter : impl FnMut ( Ty < ' tcx > ) -> bool ,
602
+ place_limit : Option < usize > ,
602
603
) -> Self {
603
604
let mut map = Self :: new ( ) ;
604
605
let exclude = excluded_locals ( body) ;
605
- map. register_with_filter ( tcx, body, filter, exclude) ;
606
+ map. register_with_filter ( tcx, body, filter, exclude, place_limit ) ;
606
607
debug ! ( "registered {} places ({} nodes in total)" , map. value_count, map. places. len( ) ) ;
607
608
map
608
609
}
@@ -614,12 +615,20 @@ impl Map {
614
615
body : & Body < ' tcx > ,
615
616
mut filter : impl FnMut ( Ty < ' tcx > ) -> bool ,
616
617
exclude : BitSet < Local > ,
618
+ place_limit : Option < usize > ,
617
619
) {
618
620
// We use this vector as stack, pushing and popping projections.
619
621
let mut projection = Vec :: new ( ) ;
620
622
for ( local, decl) in body. local_decls . iter_enumerated ( ) {
621
623
if !exclude. contains ( local) {
622
- self . register_with_filter_rec ( tcx, local, & mut projection, decl. ty , & mut filter) ;
624
+ self . register_with_filter_rec (
625
+ tcx,
626
+ local,
627
+ & mut projection,
628
+ decl. ty ,
629
+ & mut filter,
630
+ place_limit,
631
+ ) ;
623
632
}
624
633
}
625
634
}
@@ -634,7 +643,12 @@ impl Map {
634
643
projection : & mut Vec < PlaceElem < ' tcx > > ,
635
644
ty : Ty < ' tcx > ,
636
645
filter : & mut impl FnMut ( Ty < ' tcx > ) -> bool ,
646
+ place_limit : Option < usize > ,
637
647
) {
648
+ if let Some ( place_limit) = place_limit && self . value_count >= place_limit {
649
+ return
650
+ }
651
+
638
652
// We know that the projection only contains trackable elements.
639
653
let place = self . make_place ( local, projection) . unwrap ( ) ;
640
654
@@ -672,13 +686,13 @@ impl Map {
672
686
projection. push ( PlaceElem :: Downcast ( None , variant) ) ;
673
687
let _ = self . make_place ( local, projection) ;
674
688
projection. push ( PlaceElem :: Field ( field, ty) ) ;
675
- self . register_with_filter_rec ( tcx, local, projection, ty, filter) ;
689
+ self . register_with_filter_rec ( tcx, local, projection, ty, filter, place_limit ) ;
676
690
projection. pop ( ) ;
677
691
projection. pop ( ) ;
678
692
return ;
679
693
}
680
694
projection. push ( PlaceElem :: Field ( field, ty) ) ;
681
- self . register_with_filter_rec ( tcx, local, projection, ty, filter) ;
695
+ self . register_with_filter_rec ( tcx, local, projection, ty, filter, place_limit ) ;
682
696
projection. pop ( ) ;
683
697
} ) ;
684
698
}
0 commit comments