Skip to content

[RyuJIT] Eliminate unecessary copies when passing structs #9839

Closed

Description

@CarolEidt

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

Activity

  1. self-assigned this
    on Feb 27, 2018
  2. fiigii commented on Feb 27, 2018

    @fiigii
    Contributor
  3. CarolEidt commented on Feb 27, 2018

    @CarolEidt
    ContributorAuthor

    @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.

  4. CarolEidt commented on Apr 6, 2018

    @CarolEidt
    ContributorAuthor

    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

  5. transferred this issue fromdotnet/coreclron Jan 31, 2020
  6. added this to the Future milestone on Jan 31, 2020
  7. removed their assignment
    on Dec 4, 2020
  8. jakobbotsch commented on Dec 14, 2022

    @jakobbotsch
    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.

  9. ghost added
    in-prThere is an active PR which will close this issue when it is merged
    on Dec 14, 2022
  10. ghost removed
    in-prThere is an active PR which will close this issue when it is merged
    on Jan 11, 2023
  11. ghost locked as resolved and limited conversation to collaborators on Feb 10, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area-CodeGen-coreclrCLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMIenhancementProduct code improvement that does NOT require public API changes/additionsoptimizationtenet-performancePerformance related issue

    Type

    No type

    Projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions