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
Do inline for the variable initialization with NRVO function call #2592
Conversation
I'm not sure what problem this is solving? |
@WalterBright From the comment in The problem here is that if the initializer is a
function call that returns a struct S with a cpctor:
S s = foo();
the postblit is done by the return statement in foo()
in s2ir.c, the intermediate code generator.
But, if foo() is inlined and now the code looks like:
S s = x;
the postblit is not there, because such assignments
are rewritten as s.cpctor(&x) by the front end.
So, the inlining won't get the postblit called.
Work around by not inlining these cases.
A proper fix would be to move all the postblit
additions to the front end. Historically, NRVO had mostly been handled in glue layer. However recently, all of NRVO handling were properly moved to front-end layer. So, to solve the comment issue, and to increase inline-ability, I opened this PR. |
I found one more fixable issue by this. |
Updated to fix issue 11394, and for that, now this is based on #2702. |
If `nrvo_var != NULL`, inlining can directly replace it to the substituted variable.
Pass `eret` as an additional inlining context, if it is found.
Do inline for the variable initialization with NRVO function call
Uhhh... |
|
Ah, that makes sense. I run my tests locally without the permuted args. |
This made me curious since I couldn't remember the details. The auto-tester tests pull requests with a subset of the permuted args set, but it does include -inline: ARGS="-O -inline -release". It's purely a throughput/thoroughness trade off. |
Yeah. I would make it do one run with all of the permutable args, but -O really hurts the compile time on my crappy desktop. It doesn't help that I'm using dm make and can't use |
This pull request introduced a regression: |
Support more inlining.