// dse does dead-store elimination on the Function. // Dead stores are those which are unconditionally followed by // another store to the same location, with no intervening load. // This implementation only works within a basic block. TODO: use something more global. func dse(f *Func) { … } type shadowRange … func (sr shadowRange) lo() int64 { … } func (sr shadowRange) hi() int64 { … } // contains reports whether [lo:hi] is completely within sr. func (sr shadowRange) contains(lo, hi int64) bool { … } // merge returns the union of sr and [lo:hi]. // merge is allowed to return something smaller than the union. func (sr shadowRange) merge(lo, hi int64) shadowRange { … } // elimDeadAutosGeneric deletes autos that are never accessed. To achieve this // we track the operations that the address of each auto reaches and if it only // reaches stores then we delete all the stores. The other operations will then // be eliminated by the dead code elimination pass. func elimDeadAutosGeneric(f *Func) { … } // elimUnreadAutos deletes stores (and associated bookkeeping ops VarDef and VarKill) // to autos that are never read from. func elimUnreadAutos(f *Func) { … }