Commit b80029cc authored by Matthew Dempsky's avatar Matthew Dempsky

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 <mdempsky@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: default avatarRobert Griesemer <gri@golang.org>
parent f58c6c99
...@@ -583,7 +583,7 @@ var inlgen int ...@@ -583,7 +583,7 @@ var inlgen int
// parameters. // parameters.
// The result of mkinlcall1 MUST be assigned back to n, e.g. // The result of mkinlcall1 MUST be assigned back to n, e.g.
// n.Left = mkinlcall1(n.Left, fn, isddd) // 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 { if fn.Func.Inl.Len() == 0 {
// No inlinable body. // No inlinable body.
return n return n
...@@ -769,29 +769,24 @@ func mkinlcall1(n *Node, fn *Node, isddd bool) *Node { ...@@ -769,29 +769,24 @@ func mkinlcall1(n *Node, fn *Node, isddd bool) *Node {
call.Type = n.Type call.Type = n.Type
call.SetTypecheck(1) call.SetTypecheck(1)
n = call
// transitive inlining // transitive inlining
// might be nice to do this before exporting the body, // might be nice to do this before exporting the body,
// but can't emit the body with inlining expanded. // but can't emit the body with inlining expanded.
// instead we emit the things that the body needs // instead we emit the things that the body needs
// and each use must redo the inlining. // and each use must redo the inlining.
// luckily these are small. // luckily these are small.
body = fn.Func.Inl.Slice()
fn.Func.Inl.Set(nil) // prevent infinite recursion (shouldn't happen anyway)
inlnodelist(call.Nbody) inlnodelist(call.Nbody)
for _, n := range call.Nbody.Slice() { for _, n := range call.Nbody.Slice() {
if n.Op == OINLCALL { if n.Op == OINLCALL {
inlconv2stmt(n) inlconv2stmt(n)
} }
} }
fn.Func.Inl.Set(body)
if Debug['m'] > 2 { 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, // Every time we expand a function we generate a new set of tmpnames,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment