mirror of
https://github.com/golang/go.git
synced 2024-09-21 10:28:27 +00:00
[dev.regabi] cmd/compile: replace inlcopy with ir.DeepCopy
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>
This commit is contained in:
parent
989a3f5041
commit
7fcf5b994c
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user