@@ -942,6 +942,7 @@ fn compute_storage_conflicts<'mir, 'tcx>(
942
942
body,
943
943
saved_locals : saved_locals,
944
944
local_conflicts : BitMatrix :: from_row_n ( & ineligible_locals, body. local_decls . len ( ) ) ,
945
+ eligible_storage_live : BitSet :: new_empty ( body. local_decls . len ( ) ) ,
945
946
} ;
946
947
947
948
requires_storage. visit_reachable_with ( body, & mut visitor) ;
@@ -978,6 +979,8 @@ struct StorageConflictVisitor<'mir, 'tcx, 's> {
978
979
// FIXME(tmandry): Consider using sparse bitsets here once we have good
979
980
// benchmarks for coroutines.
980
981
local_conflicts : BitMatrix < Local , Local > ,
982
+ // We keep this bitset as a buffer to avoid reallocating memory.
983
+ eligible_storage_live : BitSet < Local > ,
981
984
}
982
985
983
986
impl < ' mir , ' tcx , R > rustc_mir_dataflow:: ResultsVisitor < ' mir , ' tcx , R >
@@ -1009,19 +1012,19 @@ impl<'mir, 'tcx, R> rustc_mir_dataflow::ResultsVisitor<'mir, 'tcx, R>
1009
1012
impl StorageConflictVisitor < ' _ , ' _ , ' _ > {
1010
1013
fn apply_state ( & mut self , flow_state : & BitSet < Local > , loc : Location ) {
1011
1014
// Ignore unreachable blocks.
1012
- if self . body . basic_blocks [ loc. block ] . terminator ( ) . kind == TerminatorKind :: Unreachable {
1015
+ if let TerminatorKind :: Unreachable = self . body . basic_blocks [ loc. block ] . terminator ( ) . kind {
1013
1016
return ;
1014
1017
}
1015
1018
1016
- let mut eligible_storage_live = flow_state . clone ( ) ;
1017
- eligible_storage_live. intersect ( & * * self . saved_locals ) ;
1019
+ self . eligible_storage_live . clone_from ( flow_state ) ;
1020
+ self . eligible_storage_live . intersect ( & * * self . saved_locals ) ;
1018
1021
1019
- for local in eligible_storage_live. iter ( ) {
1020
- self . local_conflicts . union_row_with ( & eligible_storage_live, local) ;
1022
+ for local in self . eligible_storage_live . iter ( ) {
1023
+ self . local_conflicts . union_row_with ( & self . eligible_storage_live , local) ;
1021
1024
}
1022
1025
1023
- if eligible_storage_live. count ( ) > 1 {
1024
- trace ! ( "at {:?}, eligible_storage_live={:?}" , loc, eligible_storage_live) ;
1026
+ if self . eligible_storage_live . count ( ) > 1 {
1027
+ trace ! ( "at {:?}, eligible_storage_live={:?}" , loc, self . eligible_storage_live) ;
1025
1028
}
1026
1029
}
1027
1030
}
0 commit comments