]> Cypherpunks repositories - gostls13.git/commitdiff
[dev.regabi] cmd/compile: rewrite a few ++/--/+=/-= to prep for getters/setters ...
authorRuss Cox <rsc@golang.org>
Wed, 25 Nov 2020 01:47:32 +0000 (20:47 -0500)
committerRuss Cox <rsc@golang.org>
Wed, 25 Nov 2020 17:30:38 +0000 (17:30 +0000)
These are trivial rewrites that are only OK because it turns out that n has no side effects.
Separated into a different CL for easy inspection.

[git-generate]
cd src/cmd/compile/internal/gc
rf '
        ex . ../ir ../ssa {
                import "cmd/compile/internal/ir"
                var n *ir.Node
var i int64

                n.Xoffset++ -> n.Xoffset = n.Xoffset + 1
                n.Xoffset-- -> n.Xoffset = n.Xoffset - 1
                n.Xoffset += i -> n.Xoffset = n.Xoffset + i
                n.Xoffset -= i -> n.Xoffset = n.Xoffset - i
}
'

Change-Id: If7b4b7f7cbdafeee988e04d03924ef0e1dd867b0
Reviewed-on: https://go-review.googlesource.com/c/go/+/272932
Trust: Russ Cox <rsc@golang.org>
Run-TryBot: Russ Cox <rsc@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
src/cmd/compile/internal/gc/initorder.go
src/cmd/compile/internal/gc/sinit.go

index 942cb95f2077b535456956712d839cc9b855bfb7..62294b5a90e53b8a2026c5dd1be93f65c2fd8da7 100644 (file)
@@ -142,7 +142,7 @@ func (o *InitOrder) processAssign(n *ir.Node) {
                if dep.Class() != ir.PEXTERN || defn.Initorder() == InitDone {
                        continue
                }
-               n.Xoffset++
+               n.Xoffset = n.Xoffset + 1
                o.blocking[defn] = append(o.blocking[defn], n)
        }
 
@@ -169,7 +169,7 @@ func (o *InitOrder) flushReady(initialize func(*ir.Node)) {
                delete(o.blocking, n)
 
                for _, m := range blocked {
-                       m.Xoffset--
+                       m.Xoffset = m.Xoffset - 1
                        if m.Xoffset == 0 {
                                heap.Push(&o.ready, m)
                        }
index d78b509127675b4e4d2ca955e448c18fcd9f1f6e..0ba7efb95ec7131d437c71dd94ec666eb366ac9e 100644 (file)
@@ -157,7 +157,7 @@ func (s *InitSchedule) staticcopy(l *ir.Node, r *ir.Node) bool {
                        // copying someone else's computation.
                        rr := ir.SepCopy(orig)
                        rr.Type = ll.Type
-                       rr.Xoffset += e.Xoffset
+                       rr.Xoffset = rr.Xoffset + e.Xoffset
                        setlineno(rr)
                        s.append(ir.Nod(ir.OAS, ll, rr))
                }
@@ -301,7 +301,7 @@ func (s *InitSchedule) staticassign(l *ir.Node, r *ir.Node) bool {
 
                // Emit itab, advance offset.
                addrsym(n, itab.Left) // itab is an OADDR node
-               n.Xoffset += int64(Widthptr)
+               n.Xoffset = n.Xoffset + int64(Widthptr)
 
                // Emit data.
                if isdirectiface(val.Type) {
@@ -1017,7 +1017,7 @@ func stataddr(n *ir.Node) *ir.Node {
                if nam == nil {
                        break
                }
-               nam.Xoffset += n.Xoffset
+               nam.Xoffset = nam.Xoffset + n.Xoffset
                nam.Type = n.Type
                return nam
 
@@ -1038,7 +1038,7 @@ func stataddr(n *ir.Node) *ir.Node {
                if n.Type.Width != 0 && thearch.MAXWIDTH/n.Type.Width <= int64(l) {
                        break
                }
-               nam.Xoffset += int64(l) * n.Type.Width
+               nam.Xoffset = nam.Xoffset + int64(l)*n.Type.Width
                nam.Type = n.Type
                return nam
        }