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

[RyuJIT] Eliminate unecessary copies when passing structs #9839

Closed
CarolEidt opened this issue Feb 27, 2018 · 4 comments · Fixed by #79346
Closed

[RyuJIT] Eliminate unecessary copies when passing structs #9839

CarolEidt opened this issue Feb 27, 2018 · 4 comments · Fixed by #79346
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 optimization tenet-performance Performance related issue
Milestone

Comments

@CarolEidt
Copy link
Contributor

CarolEidt commented Feb 27, 2018

Currently the JIT introduces unnecessary copies when passing structs by value.
This impacts both the by-ref passing as in the x86/64 windows ABI, as well as the x86/64 unix ABI - though the impact is worse in the latter case.
This is especially problematic for small structs on x86/64 unix, which are passed in registers but needlessly forced to memory. Span<T> and similar types are specific examples of this.
This issue started as https://github.com/dotnet/corefx/issues/27238, but is fundamentally a coreclr JIT issue.
The issues linked in this issue have largely been addressed, but this test case still shows unneessary copies: tests/src/JIT/Regression/JitBlue/DevDiv_590358/DevDiv_590358.cs

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

@CarolEidt CarolEidt self-assigned this Feb 27, 2018
@fiigii
Copy link
Contributor

fiigii commented Feb 27, 2018

Maybe related to https://github.com/dotnet/coreclr/issues/11030 (dotnet/coreclr#11133 solved part of the problem).

@CarolEidt
Copy link
Contributor Author

CarolEidt commented Feb 27, 2018

@fiigii thanks for adding those links (especially pointing to the existing issues that @RussKeldorph had linked to).
#7897 had to do with struct returns, which have similar issues, but somewhat different causes.
I'm going to keep this open, as there are ineffiences on Windows as well as Unix, whereas the existng issues are described as Unix-specific. However, I'm going to explicitly link those issues here for cross-reference purposes:
#2908
#5785
#6316
#6265
#6266
It may be that some of the specific issues can be addressed individually, while this overall issue remains open.

@CarolEidt
Copy link
Contributor Author

A simple example illustrating the excessive copies can be seen with the test case introduced in PR dotnet/coreclr#17418 - tests/src/JIT/Regression/JitBlue/DevDiv_590358/DevDiv_590358.cs

@msftgits msftgits transferred this issue from dotnet/coreclr Jan 31, 2020
@msftgits msftgits added this to the Future milestone Jan 31, 2020
@CarolEidt CarolEidt removed their assignment Dec 4, 2020
@jakobbotsch
Copy link
Member

The main sysV problem was fixed with multireg work, I believe. The implicit byrefs case should be fixed by #79346, will leave it open for that.

@ghost ghost added the in-pr There is an active PR which will close this issue when it is merged label Dec 14, 2022
@ghost ghost removed the in-pr There is an active PR which will close this issue when it is merged label Jan 11, 2023
@ghost ghost locked as resolved and limited conversation to collaborators Feb 10, 2023
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 optimization tenet-performance Performance related issue
Projects
Archived in project
4 participants