@@ -5218,6 +5218,7 @@ impl Function {
52185218 // pass, unnecessary means that a store to an offset is not utilized by
52195219 // other HIR instructions before a second store to the same offset occurs.
52205220 // Removing one of these two stores does not alter program behavior.
5221+ // TODO: Improve comments and clean up algorithm sketch
52215222 fn eliminate_dead_stores ( & mut self ) {
52225223 #[ derive( PartialEq , Eq , Hash ) ]
52235224 struct StoreHeap {
@@ -5237,15 +5238,8 @@ impl Function {
52375238 let mut dead_stores: HashSet < InsnId > = HashSet :: new ( ) ;
52385239 let mut active_stores: HashMap < StoreHeap , InsnId > = HashMap :: new ( ) ;
52395240 let mut insns = std:: mem:: take ( & mut self . blocks [ block. 0 ] . insns ) ;
5240- // Iterate over the instructions backwards
5241- // If we find a store
5242- // If it's not in current_stores, add it with StoreStatus::Used
5243- // If it is, check if we can eliminate it and add it to dead_stores based on current_stores. also update current_stores
5244- // cases:
5245- // - it's used. Reset the current_stores entry with the new store.
5246- // - it's not used. Add the new store to dead_stores and leave current_stores the same.
5247- // If we find an effectful instruction, mark any stores in the heap as used
5248- // If we find a load, mark the relevant store in the heap as used
5241+ // TODO: Figure out if we should make the pass run backwards and do it all in one sweep
5242+ // Or if we should do it from top to bottom for readability, but require a second pass
52495243 for i in ( 0 ..insns. len ( ) ) . rev ( ) {
52505244 let insn_id = insns[ i] ;
52515245 match self . find ( insn_id) {
0 commit comments