MCPcopy Create free account
hub / github.com/akyoto/q / removeDeadCode

Method removeDeadCode

src/core/removeDeadCode.go:10–30  ·  view source on GitHub ↗

removeDeadCode checks for dead values and also removes the ones that are partially allowed.

(folded map[ssa.Value]struct{})

Source from the content-addressed store, hash-verified

8
9// removeDeadCode checks for dead values and also removes the ones that are partially allowed.
10func (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

Callers 1

optimizeMethod · 0.95

Calls 2

removeDeadValueMethod · 0.95
RemoveNilValuesMethod · 0.80

Tested by

no test coverage detected