| // Copyright 2015 The Go Authors. All rights reserved. |
| // Use of this source code is governed by a BSD-style |
| // license that can be found in the LICENSE file. |
| // copyelim removes all copies from f. |
| for _, b := range f.Blocks { |
| for _, v := range b.Values { |
| if v != nil && v.Op == OpCopy { |
| for _, name := range f.Names { |
| values := f.NamedValues[name] |
| for i, v := range values { |
| func copyelimValue(v *Value) bool { |
| // elide any copies generated during rewriting |
| for i, a := range v.Args { |
| // Rewriting can generate OpCopy loops. |
| // They are harmless (see removePredecessor), |
| // but take care to stop if we find a cycle. |
| slow := a // advances every other iteration |