-
Couldn't load subscription status.
- Fork 5.2k
Fix GC hole with rorx instruction
#114467
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
Conversation
The `rorx` instruction uses format IF_RWR_ARD_CNS. This format was not handled when killing GC refs in `emitOutputAM`. I added other cases of register write "ARD" address mode formats to the same case as "defense in depth" -- most or all of them are probably SIMD instructions with SIMD destination registers, and won't go down this code path. Diffs include cases in the HardwareIntrinsics tests, but also in the libraries code, for both x64 and x86.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Copilot reviewed 1 out of 1 changed files in this pull request and generated no comments.
Comments suppressed due to low confidence (1)
src/coreclr/jit/emitxarch.cpp:15334
- Ensure that the newly added case labels (IF_RWR_ARD_CNS, IF_RRW_ARD_CNS, etc.) correctly trigger the GC reference update as intended and that there are no side effects in the emitter's GC handling logic.
case IF_RWR_ARD_CNS:
|
Tagging subscribers to this area: @JulieLeeMSFT, @jakobbotsch |
|
The bug was introduced with #111778, cc @saucecontrol |
|
@kunalspathak @tannergooding PTAL |
| { | ||
| switch (id->idInsFmt()) | ||
| { | ||
| case IF_RWR_ARD: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This and other places likely shouldn't be switching on the format at all. The emitfmtsxarch.h entries (https://github.com/dotnet/runtime/blob/main/src/coreclr/jit/emitfmtsxarch.h) all have relevant flags indicating whether given registers a read, write, or read-write (tracked via IS_INFO).
We should probably have this be, instead:
if (id->idIsReg1Write())
{
emitGCregDeadUpd(id->idReg1(), dst);
}
if (id->idIsReg2Write())
{
emitGCregDeadUpd(id->idReg2(), dst);
}Technically we also define idIsReg3Write() and idIsReg4Write() for parity, but these are completely unused today and could be commented out.
Realistically we could be centralizing these checks for all instructions in some emitGCregDeadUpd(id, dst) helper given we don't need to be checking specific formats at all, which seems much more robust and less error prone.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM as it appears to fix the issue, but I think in general this is still error prone and could be made significantly more robust if we centralized the GC updates for all emitted instructions using the IS_INFO available for each instrDesc
|
I agree that a more robust, generalized checking refactoring would be good. It also seems weird to call |
The
rorxinstruction uses format IF_RWR_ARD_CNS. This format was not handled when killing GC refs inemitOutputAM.I added other cases of register write "ARD" address mode formats to the same case as "defense in depth" -- most or all of them are probably SIMD instructions with SIMD destination registers, and won't go down this code path.
Diffs include cases in the HardwareIntrinsics tests, but also in the libraries code, for both x64 and x86.
Fixes #114445