From 41ab6689edb1f51001feab0928e598050e2f6d32 Mon Sep 17 00:00:00 2001 From: Russ Cox Date: Tue, 24 Nov 2020 20:47:32 -0500 Subject: [PATCH] [dev.regabi] cmd/compile: rewrite a few ++/--/+=/-= to prep for getters/setters [generated] 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 Run-TryBot: Russ Cox TryBot-Result: Go Bot Reviewed-by: Matthew Dempsky --- src/cmd/compile/internal/gc/initorder.go | 4 ++-- src/cmd/compile/internal/gc/sinit.go | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/cmd/compile/internal/gc/initorder.go b/src/cmd/compile/internal/gc/initorder.go index 942cb95f20..62294b5a90 100644 --- a/src/cmd/compile/internal/gc/initorder.go +++ b/src/cmd/compile/internal/gc/initorder.go @@ -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) } diff --git a/src/cmd/compile/internal/gc/sinit.go b/src/cmd/compile/internal/gc/sinit.go index d78b509127..0ba7efb95e 100644 --- a/src/cmd/compile/internal/gc/sinit.go +++ b/src/cmd/compile/internal/gc/sinit.go @@ -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 } -- 2.48.1