]> Cypherpunks.ru repositories - gostls13.git/commitdiff
cmd/compile: cleanup uses of ir.Orig and ir.SepCopy
authorMatthew Dempsky <mdempsky@google.com>
Wed, 6 Sep 2023 23:11:34 +0000 (16:11 -0700)
committerGopher Robot <gobot@golang.org>
Fri, 8 Sep 2023 18:57:57 +0000 (18:57 +0000)
Mostly automated refactoring with gofmt:

gofmt -r 'ir.Orig(n) -> n'
gofmt -r 'ir.SepCopy(n) -> ir.Copy(n)'

Followed by some manual cleanups.

Change-Id: Ib35abeba9e60b70ba463e161fb39358fb058a83e
Reviewed-on: https://go-review.googlesource.com/c/go/+/526398
Reviewed-by: Keith Randall <khr@golang.org>
Auto-Submit: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Keith Randall <khr@google.com>
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>

src/cmd/compile/internal/ir/copy.go
src/cmd/compile/internal/ir/fmt.go
src/cmd/compile/internal/ir/node.go
src/cmd/compile/internal/noder/reader.go
src/cmd/compile/internal/ssagen/ssa.go
src/cmd/compile/internal/typecheck/func.go
src/cmd/compile/internal/walk/order.go

index 9d3a13665739635f2622c63d7ee7b88b9ad649b7..d30f7bc688093834e271cd2caf3dd96b75ed62b9 100644 (file)
@@ -8,20 +8,6 @@ import (
        "cmd/internal/src"
 )
 
-// Orig returns n.
-//
-// TODO(mdempsky): Remove.
-func Orig(n Node) Node {
-       return n
-}
-
-// SepCopy returns a shallow copy of n.
-//
-// TODO(mdempsky): Replace with Copy.
-func SepCopy(n Node) Node {
-       return n.copy()
-}
-
 // Copy returns a shallow copy of n.
 func Copy(n Node) Node {
        return n.copy()
index 2eed9e467fcd84bca497df9b40a1104136e862ca..b8a175471218abb640c0b1949020643f5ac2141b 100644 (file)
@@ -526,12 +526,6 @@ func exprFmt(n Node, s fmt.State, prec int) {
                        return
                }
 
-               // We always want the original, if any.
-               if o := Orig(n); o != n {
-                       n = o
-                       continue
-               }
-
                // Skip implicit operations introduced during typechecking.
                switch nn := n; nn.Op() {
                case OADDR:
index d8508e04926f50b8ba3f937aeb20b845bc9d974f..f91b6f44b38bb02cea848e3806d3dbbb2a390b76 100644 (file)
@@ -470,9 +470,7 @@ func IsConst(n Node, ct constant.Kind) bool {
 
 // IsNil reports whether n represents the universal untyped zero value "nil".
 func IsNil(n Node) bool {
-       // Check n.Orig because constant propagation may produce typed nil constants,
-       // which don't exist in the Go spec.
-       return n != nil && Orig(n).Op() == ONIL
+       return n != nil && n.Op() == ONIL
 }
 
 func IsBlank(n Node) bool {
index 8e28260499465c24013fa9ad34724ac97187e9cd..bf7bfb7d488b65019136d48df84e3055fbc8306f 100644 (file)
@@ -3053,7 +3053,7 @@ func (r *reader) compLit() ir.Node {
 func wrapName(pos src.XPos, x ir.Node) ir.Node {
        // These nodes do not carry line numbers.
        // Introduce a wrapper node to give them the correct line.
-       switch ir.Orig(x).Op() {
+       switch x.Op() {
        case ir.OTYPE, ir.OLITERAL:
                if x.Sym() == nil {
                        break
index 1f06290dc334746ba95cf82d5326de81cf34c829..6f8487757d78226c957bb1f6b67b25e21c7257b1 100644 (file)
@@ -7658,16 +7658,10 @@ func AddAux2(a *obj.Addr, v *ssa.Value, offset int64) {
        case *ir.Name:
                if n.Class == ir.PPARAM || (n.Class == ir.PPARAMOUT && !n.IsOutputParamInRegisters()) {
                        a.Name = obj.NAME_PARAM
-                       a.Sym = ir.Orig(n).(*ir.Name).Linksym()
-                       a.Offset += n.FrameOffset()
-                       break
-               }
-               a.Name = obj.NAME_AUTO
-               if n.Class == ir.PPARAMOUT {
-                       a.Sym = ir.Orig(n).(*ir.Name).Linksym()
                } else {
-                       a.Sym = n.Linksym()
+                       a.Name = obj.NAME_AUTO
                }
+               a.Sym = n.Linksym()
                a.Offset += n.FrameOffset()
        default:
                v.Fatalf("aux in %s not implemented %#v", v, v.Aux)
index c4b053e690a0dfd34fa90e7c1bef83486cf7b700..4f076c485406f7097486e2f6afb4523ac236bfa2 100644 (file)
@@ -255,7 +255,7 @@ func tcCall(n *ir.CallExpr, top int) ir.Node {
        default:
                n.SetOp(ir.OCALLFUNC)
                if t.Kind() != types.TFUNC {
-                       if o := ir.Orig(l); o.Name() != nil && types.BuiltinPkg.Lookup(o.Sym().Name).Def != nil {
+                       if o := l; o.Name() != nil && types.BuiltinPkg.Lookup(o.Sym().Name).Def != nil {
                                // be more specific when the non-function
                                // name matches a predeclared function
                                base.Errorf("cannot call non-function %L, declared at %s",
index 11c1e21e1714b4fa17c4900748b28f0b90b8aa39..c2ed528f330284c0d36004349505ac3fb04053c7 100644 (file)
@@ -128,7 +128,7 @@ func (o *orderState) cheapExpr(n ir.Node) ir.Node {
                if l == n.X {
                        return n
                }
-               a := ir.SepCopy(n).(*ir.UnaryExpr)
+               a := ir.Copy(n).(*ir.UnaryExpr)
                a.X = l
                return typecheck.Expr(a)
        }
@@ -154,7 +154,7 @@ func (o *orderState) safeExpr(n ir.Node) ir.Node {
                if l == n.X {
                        return n
                }
-               a := ir.SepCopy(n).(*ir.UnaryExpr)
+               a := ir.Copy(n).(*ir.UnaryExpr)
                a.X = l
                return typecheck.Expr(a)
 
@@ -164,7 +164,7 @@ func (o *orderState) safeExpr(n ir.Node) ir.Node {
                if l == n.X {
                        return n
                }
-               a := ir.SepCopy(n).(*ir.SelectorExpr)
+               a := ir.Copy(n).(*ir.SelectorExpr)
                a.X = l
                return typecheck.Expr(a)
 
@@ -174,7 +174,7 @@ func (o *orderState) safeExpr(n ir.Node) ir.Node {
                if l == n.X {
                        return n
                }
-               a := ir.SepCopy(n).(*ir.SelectorExpr)
+               a := ir.Copy(n).(*ir.SelectorExpr)
                a.X = l
                return typecheck.Expr(a)
 
@@ -184,7 +184,7 @@ func (o *orderState) safeExpr(n ir.Node) ir.Node {
                if l == n.X {
                        return n
                }
-               a := ir.SepCopy(n).(*ir.StarExpr)
+               a := ir.Copy(n).(*ir.StarExpr)
                a.X = l
                return typecheck.Expr(a)
 
@@ -200,7 +200,7 @@ func (o *orderState) safeExpr(n ir.Node) ir.Node {
                if l == n.X && r == n.Index {
                        return n
                }
-               a := ir.SepCopy(n).(*ir.IndexExpr)
+               a := ir.Copy(n).(*ir.IndexExpr)
                a.X = l
                a.Index = r
                return typecheck.Expr(a)