]> Cypherpunks repositories - gostls13.git/commitdiff
[dev.ssa] cmd/internal/ssa: minor cleanup
authorJosh Bleecher Snyder <josharian@gmail.com>
Mon, 16 Mar 2015 23:31:13 +0000 (16:31 -0700)
committerJosh Bleecher Snyder <josharian@gmail.com>
Tue, 17 Mar 2015 16:08:53 +0000 (16:08 +0000)
These were review comments for CL 6681 that didn't get sent in time.

Change-Id: If161af3655770487f3ba34535d3fb55dbfde7917
Reviewed-on: https://go-review.googlesource.com/7644
Reviewed-by: Keith Randall <khr@golang.org>
src/cmd/internal/ssa/deadcode.go
src/cmd/internal/ssa/op.go
src/cmd/internal/ssa/type.go
src/cmd/internal/ssa/value.go

index 1647ea955da79bdc0bd8a4a78b62e811403c6589..e8c8bfcc0373fc648dc7b61c63d5ba55cd396ecc 100644 (file)
@@ -86,8 +86,10 @@ func deadcode(f *Func) {
                                f.vid.put(v.ID)
                        }
                }
-               for j := i; j < len(b.Values); j++ {
-                       b.Values[j] = nil // aid GC
+               // aid GC
+               tail := b.Values[i:]
+               for j := range tail {
+                       tail[j] = nil
                }
                b.Values = b.Values[:i]
        }
@@ -105,9 +107,10 @@ func deadcode(f *Func) {
                        f.bid.put(b.ID)
                }
        }
-       // zero remainder to help gc
-       for j := i; j < len(f.Blocks); j++ {
-               f.Blocks[j] = nil
+       // zero remainder to help GC
+       tail := f.Blocks[i:]
+       for j := range tail {
+               tail[j] = nil
        }
        f.Blocks = f.Blocks[:i]
 
index a4364b1c5cb3c8e5e20eb8666da54d22e6e1ba48..905d62b69cf488139077a3a0ea2a67e3b5f5917a 100644 (file)
@@ -82,7 +82,7 @@ const (
        OpStoreFP
        OpStoreSP
 
-       // spill&restore ops for the register allocator.  These are
+       // spill and restore ops for the register allocator.  These are
        // semantically identical to OpCopy - they do not take/return
        // stores like regular memory ops do.  We can get away with that because
        // we know there is no aliasing to spill slots on the stack.
index 3389622c7474cbf341f2cb99e23f4a2ec517710b..e9c017d38ad0c91dcef68fa3c18aba6259df8bc4 100644 (file)
@@ -34,7 +34,7 @@ var (
        TypeFlags = &Flags{}
 )
 
-// typeIdentical returns whether it two arguments are the same type.
+// typeIdentical reports whether its two arguments are the same type.
 func typeIdentical(t, u Type) bool {
        if t == TypeMem {
                return u == TypeMem
index 740525a5f53ee4f5034833cc63660d02cd5d261c..f6f099cd32de780dd970da28d74e54bbd6d7519b 100644 (file)
@@ -24,7 +24,7 @@ type Value struct {
        // are a few other pseudo-types, see type.go.
        Type Type
 
-       // Auxiliary info for this value.  The type of this information depends on the opcode (& type).
+       // Auxiliary info for this value.  The type of this information depends on the opcode and type.
        Aux interface{}
 
        // Arguments of this value
@@ -67,9 +67,15 @@ func (v *Value) LongString() string {
 }
 
 func (v *Value) AddArg(w *Value) {
+       if v.Args == nil {
+               v.resetArgs() // use argstorage
+       }
        v.Args = append(v.Args, w)
 }
 func (v *Value) AddArgs(a ...*Value) {
+       if v.Args == nil {
+               v.resetArgs() // use argstorage
+       }
        v.Args = append(v.Args, a...)
 }
 func (v *Value) SetArg(i int, w *Value) {
@@ -77,6 +83,7 @@ func (v *Value) SetArg(i int, w *Value) {
 }
 func (v *Value) RemoveArg(i int) {
        copy(v.Args[i:], v.Args[i+1:])
+       v.Args[len(v.Args)-1] = nil // aid GC
        v.Args = v.Args[:len(v.Args)-1]
 }
 func (v *Value) SetArgs1(a *Value) {