]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/compile: simplify mkinlcall1
authorMatthew Dempsky <mdempsky@google.com>
Mon, 9 Oct 2017 18:06:52 +0000 (11:06 -0700)
committerMatthew Dempsky <mdempsky@google.com>
Tue, 10 Oct 2017 17:53:27 +0000 (17:53 +0000)
mkinlcall1 already guards against recursively inlining functions into
themselves, so there's no need to clear and restore fn.Func.Inl during
recursive inlining.

Passes toolstash-check.

Change-Id: I8bf0c8dea8788d94d3ea5670610b4acb1d26d2fb
Reviewed-on: https://go-review.googlesource.com/69310
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
src/cmd/compile/internal/gc/inl.go

index c65eb144137aad1bf8e4afae8bf12b68aa1e7656..da02f73ecd593ad55474bf007bdd92d87b4a2a4c 100644 (file)
@@ -583,7 +583,7 @@ var inlgen int
 // parameters.
 // The result of mkinlcall1 MUST be assigned back to n, e.g.
 //     n.Left = mkinlcall1(n.Left, fn, isddd)
-func mkinlcall1(n *Node, fn *Node, isddd bool) *Node {
+func mkinlcall1(n, fn *Node, isddd bool) *Node {
        if fn.Func.Inl.Len() == 0 {
                // No inlinable body.
                return n
@@ -769,29 +769,24 @@ func mkinlcall1(n *Node, fn *Node, isddd bool) *Node {
        call.Type = n.Type
        call.SetTypecheck(1)
 
-       n = call
-
        // transitive inlining
        // might be nice to do this before exporting the body,
        // but can't emit the body with inlining expanded.
        // instead we emit the things that the body needs
        // and each use must redo the inlining.
        // luckily these are small.
-       body = fn.Func.Inl.Slice()
-       fn.Func.Inl.Set(nil) // prevent infinite recursion (shouldn't happen anyway)
        inlnodelist(call.Nbody)
        for _, n := range call.Nbody.Slice() {
                if n.Op == OINLCALL {
                        inlconv2stmt(n)
                }
        }
-       fn.Func.Inl.Set(body)
 
        if Debug['m'] > 2 {
-               fmt.Printf("%v: After inlining %+v\n\n", n.Line(), n)
+               fmt.Printf("%v: After inlining %+v\n\n", call.Line(), call)
        }
 
-       return n
+       return call
 }
 
 // Every time we expand a function we generate a new set of tmpnames,