@@ -142,18 +142,38 @@ where
142142 dirty_queue. insert ( bb) ;
143143 }
144144
145- while let Some ( bb) = dirty_queue. pop ( ) {
146- let bb_data = & self . body [ bb] ;
147- let on_entry = & self . entry_sets [ bb] ;
148-
149- temp_state. overwrite ( on_entry) ;
150- self . apply_whole_block_effect ( & mut temp_state, bb, bb_data) ;
145+ // The `trans_for_block` check is manually hoisted out of the loop for performance.
146+ // FIXME: Make this more DRY.
147+ if let Some ( trans_for_block) = self . trans_for_block . take ( ) {
148+ while let Some ( bb) = dirty_queue. pop ( ) {
149+ let bb_data = & self . body [ bb] ;
150+ let on_entry = & self . entry_sets [ bb] ;
151+
152+ temp_state. overwrite ( on_entry) ;
153+ trans_for_block[ bb] . apply ( & mut temp_state) ;
154+
155+ self . propagate_bits_into_graph_successors_of (
156+ & mut temp_state,
157+ ( bb, bb_data) ,
158+ & mut dirty_queue,
159+ ) ;
160+ }
151161
152- self . propagate_bits_into_graph_successors_of (
153- & mut temp_state,
154- ( bb, bb_data) ,
155- & mut dirty_queue,
156- ) ;
162+ self . trans_for_block = Some ( trans_for_block) ;
163+ } else {
164+ while let Some ( bb) = dirty_queue. pop ( ) {
165+ let bb_data = & self . body [ bb] ;
166+ let on_entry = & self . entry_sets [ bb] ;
167+
168+ temp_state. overwrite ( on_entry) ;
169+ self . apply_whole_block_effect ( & mut temp_state, bb, bb_data) ;
170+
171+ self . propagate_bits_into_graph_successors_of (
172+ & mut temp_state,
173+ ( bb, bb_data) ,
174+ & mut dirty_queue,
175+ ) ;
176+ }
157177 }
158178
159179 let Engine { tcx, body, def_id, trans_for_block, entry_sets, analysis, .. } = self ;
@@ -175,14 +195,6 @@ where
175195 block : BasicBlock ,
176196 block_data : & mir:: BasicBlockData < ' tcx > ,
177197 ) {
178- // Use the cached block transfer function if available.
179- if let Some ( trans_for_block) = & self . trans_for_block {
180- trans_for_block[ block] . apply ( state) ;
181- return ;
182- }
183-
184- // Otherwise apply effects one-by-one.
185-
186198 for ( statement_index, statement) in block_data. statements . iter ( ) . enumerate ( ) {
187199 let location = Location { block, statement_index } ;
188200 self . analysis . apply_before_statement_effect ( state, statement, location) ;
0 commit comments