Skip to content
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

Add optimization to avoid copying a struct if passed by reference and there are no writes to and no reads after passed to a callee. #4524

Closed
LLITCHEV opened this issue Sep 27, 2015 · 5 comments
Labels
area-CodeGen-coreclr CLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMI enhancement Product code improvement that does NOT require public API changes/additions needs-author-action An issue or pull request that requires more info or actions from the author. optimization tenet-performance Performance related issue
Milestone

Comments

@LLITCHEV
Copy link
Contributor

On Windows structs are allocated on the caller stack and passed by ref to the callee.

If a struct is passed to a callee (callee1), which passes it to another callee (calee2), and there are no writes before the call to callee2, and there are no reads after passing to the callee2, the callee1 could pass to calee2 the reference that was passed to it, without need to allocate a new struct on the callee1 stack and copy the data.

category:cq
theme:structs
skill-level:expert
cost:extra-large

@omariom
Copy link
Contributor

omariom commented Sep 28, 2015

@LLITCHEV
Copy link
Contributor Author

@omariom Yes... It is very similar. This optimization should result in better codegen for handful of cases not described in 1133, I think.

Thank you for pointing out the existing Issue and linking them together.

@CarolEidt
Copy link
Contributor

This is really a distinct issue from #4308. In that issue, what's at issue is that:

  • First, the inliner creates copies for all struct parameters, and
  • Second, value numbering is not fully enabled for structs, so the copies do not get eliminated.

Addressing this issue requires a different kind of analysis, to determine that the struct being passed is not modified, and is not read after the call to callee1.

A repro, in particular one that reflects an actual real-world scenario, would be useful in prioritizing this.

@msftgits msftgits transferred this issue from dotnet/coreclr Jan 30, 2020
@msftgits msftgits added this to the Future milestone Jan 30, 2020
@ghost ghost added the no-recent-activity label Oct 9, 2021
@ghost
Copy link

ghost commented Oct 9, 2021

This issue has been automatically marked no recent activity because it has been marked as needs more info but has not had any activity for 14 days. It will be closed if no further activity occurs within 14 more days. Any new comment (by anyone, not necessarily the author) will remove no recent activity.

Please refer to our contribution guidelines for tips on what information might be required.

@ghost
Copy link

ghost commented Nov 5, 2021

This issue will now be closed since it had been marked no recent activity but received no further activity in the past 14 days. It is still possible to reopen or comment on the issue, but please note that the issue will be locked if it remains inactive for another 30 days.

@ghost ghost closed this as completed Nov 5, 2021
@ghost ghost locked as resolved and limited conversation to collaborators Dec 5, 2021
@eiriktsarpalis eiriktsarpalis added needs-author-action An issue or pull request that requires more info or actions from the author. and removed needs more info labels Jan 19, 2022
@ghost ghost removed the no-recent-activity label Jan 19, 2022
This issue was closed.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-CodeGen-coreclr CLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMI enhancement Product code improvement that does NOT require public API changes/additions needs-author-action An issue or pull request that requires more info or actions from the author. optimization tenet-performance Performance related issue
Projects
None yet
Development

No branches or pull requests

6 participants