-
Notifications
You must be signed in to change notification settings - Fork 5.3k
Fix impGetNodeAddr flag handling for volatile, unaligned, and initclass accesses #122381
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
base: main
Are you sure you want to change the base?
Conversation
Co-authored-by: jakobbotsch <[email protected]>
src/coreclr/jit/importer.cpp
Outdated
| if (!allowVolatileUnaligned && ((flags & (GTF_IND_VOLATILE | GTF_IND_UNALIGNED)) != 0)) | ||
| { | ||
| break; | ||
| } |
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 On second thought this needs to check GTF_IND_INITCLASS as well. Can you rename allowVolatileUnaligned to allowConfiguredDerefs at the same time.
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.
Done in commit 7c2aedd. The parameter is now renamed to allowConfiguredDerefs and the check now includes GTF_IND_INITCLASS in addition to volatile and unaligned flags.
Co-authored-by: jakobbotsch <[email protected]>
Co-authored-by: jakobbotsch <[email protected]>
…IND_INITCLASS Co-authored-by: jakobbotsch <[email protected]>
impGetNodeAddrreturnsGTF_IND_COPYABLE_FLAGS(volatile, unaligned, nonfaulting, initclass) from the original access, but five call sites were ignoring these flags, potentially leading to incorrect semantics for volatile/unaligned/initclass operations.Changes:
Added
allowConfiguredDerefsparameter toimpGetNodeAddr: Whenfalse, indirections with volatile, unaligned, or initclass flags fall through to temp creation instead of returning the address directly. Defaults totruefor backward compatibility.Return buffers (3 sites): Set
allowConfiguredDerefs = falsewhen obtaining addresses for return buffer arguments passed to helpers. VM helpers cannot handle addresses with volatile, unaligned, or initclass flags.Struct field access on instance: Combine flags from
impGetNodeAddrwith prefix flags when creating the field indirection:GenTreeFlags objAddrFlags = GTF_EMPTY; obj = impGetNodeAddr(obj, CHECK_SPILL_ALL, &objAddrFlags); indirFlags |= objAddrFlags; // Combine with prefix flagsBox-isinst optimization: Transfer flags to the hasValue field indirection:
objToBox = impGetNodeAddr(objToBox, CHECK_SPILL_ALL, &indirFlags); impPushOnStack(gtNewIndir(TYP_UBYTE, objToBox, indirFlags), ...);Fixed recursive call: Preserve
allowConfiguredDerefsin GT_COMMA case to maintain semantics through comma expressions.All five
TODO-Bug?: verify if flags matter herecomments resolved.Original prompt
💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.