-
Notifications
You must be signed in to change notification settings - Fork 18k
cmd/compile: relax recursive restriction while inlining #29737
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
This might also help with a problem @CAFxX ran into (which also has another possible solution). |
Nothing planned for 1.13, punting. |
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). In the spirit of @josharian's CL this would require filtering out not just functions marked as noinline, but also any function that effectively has no chances of being inlined. |
Change https://golang.org/cl/226818 mentions this issue: |
Change https://golang.org/cl/227346 mentions this issue: |
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 <mpratt@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Dan Scales <danscales@google.com> Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
The compiler refuses to inline anything in this example:
There's no reason to not inline, e.g.,
g
intof
.As long as we're not inlining a function into itself, it should be ok (and even that might be ok, as long as we don't do it an infinite number of times).
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
runtime.pcdatavalue
. I had a CL (CL 157799) which modified it, and the modified version should have inlined. It didn't because of this issue, becausepcdatavalue
it is part of a reasonably large recursive loop.The text was updated successfully, but these errors were encountered: