From b80029ccf422cfdfa758838fd18a219901cda839 Mon Sep 17 00:00:00 2001 From: Matthew Dempsky Date: Mon, 9 Oct 2017 11:06:52 -0700 Subject: [PATCH] cmd/compile: simplify mkinlcall1 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 TryBot-Result: Gobot Gobot Reviewed-by: Robert Griesemer --- src/cmd/compile/internal/gc/inl.go | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/src/cmd/compile/internal/gc/inl.go b/src/cmd/compile/internal/gc/inl.go index c65eb14413..da02f73ecd 100644 --- a/src/cmd/compile/internal/gc/inl.go +++ b/src/cmd/compile/internal/gc/inl.go @@ -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, -- 2.48.1