]> Cypherpunks repositories - gostls13.git/commitdiff
[dev.regabi] cmd/compile: replace inlcopy with ir.DeepCopy
authorRuss Cox <rsc@golang.org>
Thu, 3 Dec 2020 03:54:33 +0000 (22:54 -0500)
committerRuss Cox <rsc@golang.org>
Fri, 4 Dec 2020 16:52:47 +0000 (16:52 +0000)
Now inlcopy and ir.DeepCopy are semantically the same,
so drop the inlcopy implementation.

Passes buildall w/ toolstash -cmp.

Change-Id: Id2abb39a412a8e57167a29be5ecf76e990dc9d3d
Reviewed-on: https://go-review.googlesource.com/c/go/+/275310
Trust: Russ Cox <rsc@golang.org>
Run-TryBot: Russ Cox <rsc@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
src/cmd/compile/internal/gc/inl.go

index 980ba7429ae91adadae6b700dc6c59fa241a904a..efd6fea84453800a5d0983c3c9d5a5aca9322a97 100644 (file)
@@ -218,7 +218,7 @@ func caninl(fn *ir.Func) {
        n.Func().Inl = &ir.Inline{
                Cost: inlineMaxBudget - visitor.budget,
                Dcl:  pruneUnusedAutos(n.Defn.Func().Dcl, &visitor),
-               Body: inlcopylist(fn.Body().Slice()),
+               Body: ir.DeepCopyList(src.NoXPos, fn.Body().Slice()),
        }
 
        if base.Flag.LowerM > 1 {
@@ -447,41 +447,6 @@ func (v *hairyVisitor) visit(n ir.Node) bool {
                v.visitList(n.Init()) || v.visitList(n.Body())
 }
 
-// inlcopylist (together with inlcopy) recursively copies a list of nodes, except
-// that it keeps the same ONAME, OTYPE, and OLITERAL nodes. It is used for copying
-// the body and dcls of an inlineable function.
-func inlcopylist(ll []ir.Node) []ir.Node {
-       s := make([]ir.Node, 0, len(ll))
-       for _, n := range ll {
-               s = append(s, inlcopy(n))
-       }
-       return s
-}
-
-func inlcopy(n ir.Node) ir.Node {
-       if n == nil {
-               return nil
-       }
-
-       switch n.Op() {
-       case ir.ONAME, ir.OTYPE, ir.OLITERAL, ir.ONIL:
-               return n
-       }
-
-       m := ir.Copy(n)
-       if n.Op() != ir.OCALLPART && m.Func() != nil {
-               base.Fatalf("unexpected Func: %v", m)
-       }
-       m.SetLeft(inlcopy(n.Left()))
-       m.SetRight(inlcopy(n.Right()))
-       m.PtrList().Set(inlcopylist(n.List().Slice()))
-       m.PtrRlist().Set(inlcopylist(n.Rlist().Slice()))
-       m.PtrInit().Set(inlcopylist(n.Init().Slice()))
-       m.PtrBody().Set(inlcopylist(n.Body().Slice()))
-
-       return m
-}
-
 func countNodes(n ir.Node) int {
        if n == nil {
                return 0