Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.Sign up
cmd/compile: relax recursive restriction while inlining #29737
The compiler refuses to inline anything in this example:
There's no reason to not inline, e.g.,
This comes up only with mid-stack inlining. When we only inlined leaves, it was perfectly reasonable to abort on recursion. Now we don't have to.
This came up when looking at
I just ran into a similar problem again; also in my case the recursion loop was fairly big and, crucially, it contained non-inlineable functions (both way over budget as well as containing non-inlineable constructs).
Following CL 226818, the compiler will allow inlining a single cycle in an inline chain. Immediately-recursive functions are still disallowed, which is what this heuristic refers to. Add a regression test for this case. Note that in addition to this check, if the compiler were to inline multiple cycles via a loop (i.e., rather than appending duplicate code), much more work would be required here to handle a single address appearing in multiple different inline frames. Updates #29737 Change-Id: I88de15cfbeabb9c04381e1c12cc36778623132a5 Reviewed-on: https://go-review.googlesource.com/c/go/+/227346 Run-TryBot: Michael Pratt <email@example.com> TryBot-Result: Gobot Gobot <firstname.lastname@example.org> Reviewed-by: Dan Scales <email@example.com> Reviewed-by: Hyang-Ah Hana Kim <firstname.lastname@example.org>