removeDeadCode checks for dead values and also removes the ones that are partially allowed.
(folded map[ssa.Value]struct{})
| 8 | |
| 9 | // removeDeadCode checks for dead values and also removes the ones that are partially allowed. |
| 10 | func (f *Function) removeDeadCode(folded map[ssa.Value]struct{}) error { |
| 11 | for { |
| 12 | count := f.CountValues() |
| 13 | |
| 14 | for _, block := range slices.Backward(f.Blocks) { |
| 15 | var errors []error |
| 16 | |
| 17 | for i, value := range slices.Backward(block.Instructions) { |
| 18 | err := f.removeDeadValue(block, i, value, folded) |
| 19 | |
| 20 | if err != nil { |
| 21 | errors = append(errors, err) |
| 22 | } |
| 23 | } |
| 24 | |
| 25 | if len(errors) > 0 { |
| 26 | return errors[len(errors)-1] |
| 27 | } |
| 28 | |
| 29 | block.RemoveNilValues() |
| 30 | } |
| 31 | |
| 32 | if f.CountValues() == count { |
| 33 | return nil |
no test coverage detected