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

Ensure that JIT and other IL compilers preserve order of data dependent memory accesses #79764

Open
VSadov opened this issue Dec 16, 2022 · 3 comments
Assignees
Labels
area-CodeGen-coreclr CLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMI memory model issues associated with memory model Priority:3 Work that is nice to have
Milestone

Comments

@VSadov
Copy link
Member

VSadov commented Dec 16, 2022

Re: #75790 (comment)

There is a concern about compiler optimization honoring ordering of data-dependent reads (and writes to object fields to a lesser degree). We expect that from the hardware (for writes we insert fences if needed). The question was whether compiler itself may violate such ordering in some optimizations and whether it is costly to prevent that if it does. I think the concern was mostly about reads as writing has obvious sideeffects, which limits what optimizations can do.

Preliminary conclusion was that compiler honors data dependency because the internal representations are tree-based, but it needs to be confirmed.

If that is the case we need to make it more intentional that compilers avoid invalid optimizations in the future.
If compiler actually violate the order and fixing is not feasible, we may consider adjusting the documentation.

This also applies to Mono LLVM-based codegen.

@VSadov VSadov added the memory model issues associated with memory model label Dec 16, 2022
@dotnet-issue-labeler
Copy link

I couldn't figure out the best area label to add to this issue. If you have write-permissions please help me learn by adding exactly one area label.

@ghost ghost added the untriaged New issue has not been triaged by the area owner label Dec 16, 2022
@jkotas jkotas added the area-CodeGen-coreclr CLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMI label Dec 17, 2022
@ghost
Copy link

ghost commented Dec 17, 2022

Tagging subscribers to this area: @JulieLeeMSFT, @jakobbotsch, @kunalspathak
See info in area-owners.md if you want to be subscribed.

Issue Details

Re: #75790 (comment)

There was a concern about compiler optimization honoring ordering of data-dependent reads (and writes to object fields to a lesser degree). We expect that from the hardware (for writes we insert fences if needed). The question was whether compiler itself may violate such ordering in some optimizations and whether it is costly to prevent that if it does. I think the concern was mostly about reads as writing has obvious sideeffects, which limits what optimizations can do.

Preliminary conclusion was that compiler honors data dependency because the internal representations are tree-based, but it needs to be confirmed.

If that is the case we need to make it more intentional that compilers avoid invalid optimizations in the future.
If compiler actually violate the order and fixing is not feasible, we may consider adjusting the documentation.

This also applies to Mono LLVM-based codegen.

Author: VSadov
Assignees: -
Labels:

area-CodeGen-coreclr, untriaged, memory model

Milestone: -

@JulieLeeMSFT
Copy link
Member

cc @dotnet/jit-contrib.

@JulieLeeMSFT JulieLeeMSFT removed the untriaged New issue has not been triaged by the area owner label Jan 3, 2023
@JulieLeeMSFT JulieLeeMSFT added this to the 8.0.0 milestone Jan 3, 2023
@jakobbotsch jakobbotsch added the Priority:3 Work that is nice to have label Jun 6, 2023
@jakobbotsch jakobbotsch modified the milestones: 8.0.0, 9.0.0 Aug 7, 2023
@jakobbotsch jakobbotsch modified the milestones: 9.0.0, 10.0.0 Jul 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-CodeGen-coreclr CLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMI memory model issues associated with memory model Priority:3 Work that is nice to have
Projects
None yet
Development

No branches or pull requests

5 participants