@@ -5036,6 +5036,7 @@ impl Function {
50365036 // pass, unnecessary means that a store to an offset is not utilized by
50375037 // other HIR instructions before a second store to the same offset occurs.
50385038 // Removing one of these two stores does not alter program behavior.
5039+ // TODO: Improve comments and clean up algorithm sketch
50395040 fn eliminate_dead_stores ( & mut self ) {
50405041 #[ derive( PartialEq , Eq , Hash ) ]
50415042 struct StoreHeap {
@@ -5055,15 +5056,8 @@ impl Function {
50555056 let mut dead_stores: HashSet < InsnId > = HashSet :: new ( ) ;
50565057 let mut active_stores: HashMap < StoreHeap , InsnId > = HashMap :: new ( ) ;
50575058 let mut insns = std:: mem:: take ( & mut self . blocks [ block. 0 ] . insns ) ;
5058- // Iterate over the instructions backwards
5059- // If we find a store
5060- // If it's not in current_stores, add it with StoreStatus::Used
5061- // If it is, check if we can eliminate it and add it to dead_stores based on current_stores. also update current_stores
5062- // cases:
5063- // - it's used. Reset the current_stores entry with the new store.
5064- // - it's not used. Add the new store to dead_stores and leave current_stores the same.
5065- // If we find an effectful instruction, mark any stores in the heap as used
5066- // If we find a load, mark the relevant store in the heap as used
5059+ // TODO: Figure out if we should make the pass run backwards and do it all in one sweep
5060+ // Or if we should do it from top to bottom for readability, but require a second pass
50675061 for i in ( 0 ..insns. len ( ) ) . rev ( ) {
50685062 let insn_id = insns[ i] ;
50695063 match self . find ( insn_id) {
0 commit comments