-
Notifications
You must be signed in to change notification settings - Fork 4.9k
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
Question about GetFoldedArithOpResultHandleFlags() #100059
Comments
Tagging subscribers to this area: @JulieLeeMSFT, @jakobbotsch |
For any constant arithmetic on a handle, lose the handle type: it's unreliable. Eliminates problems seen in dotnet#100059
For any constant arithmetic on a handle, lose the handle type: it's unreliable. Eliminates problems seen in dotnet#100059
Losing the handle-ness seems ok to me in runtime JIT. Is it also ok during AOT?
Yes, when accessing fields off of I don't see how #70452 is related to the issue at hand. The problem exists before that PR. Instead of mapping the handle resulting of the addition from As a general note: we keep running into problems around these handles and their representation. Most of the problems seem to be rooted in the fact that we need to treat some handles opaquely during prejit. I think we should introduce a separate node, e.g. |
#100060 is the right fix for this problem. It was never correct to "derive" handle kinds from the inputs, we just haven't run into problems because the handle kinds on VNs are sparsely used. #100060 will also fix the problem seen in #99011 (comment). |
I'll verify that after it's merged FYI (I have a reliable repro for it (that works even without |
During AOT
True, it was a problem beforehand. I just found this function/PR when I noticed the mapping causing unexpected behavior (before, the unexpected handle type still would have appeared). |
For any constant arithmetic on a handle, lose the handle type: it's unreliable. Eliminates problems seen in #100059
Fixed by #100060 |
Can confirm the assert in my sample is gone now. |
#70452 introduced
GetFoldedArithOpResultHandleFlags()
that loses specific handle types and seems to associate incorrect handle types with arithmetic operations on handles. This problem is seen during OptRepeat compilations with shared constant CSE.Consider:
This tree defines
V134 tmp133
as a base constant for shared constant CSE:This tree defines
V38 tmp37
as an offset fromV134 tmp133
:Node
[000624]
usesV38 tmp37
. Note in particular theIND
is NOT invariant:After VN-based fold of
[000624]
:Note in particular that the replacement has
const ptr
handle type, and because of that, theIND
is marked invariant (#
flag). The computed constant starts asGTF_ICON_CLASS_HDL
, the handle type of the constant assigned toV134 tmp133
. With shared constant CSE, we add492
to get the actual value, which originally was:Then
GetFoldedArithOpResultHandleFlags
mapsGTF_ICON_CLASS_HDL
toGTF_ICON_CONST_PTR
.Of course, this is wrong. But also, because it is "constant" and the IND marked invariant, that means the IND can later be CSE'd, incorrectly.
Question: wouldn't it be safer, in the presence of shared constant CSE, to always fold handle types to (mutable)
GTF_ICON_GLOBAL_PTR
? Or lose the handle-ness of them entirely?For instance, what does it mean for unary op neg/not/bswap16/bswap on a handle constant? How can the result be a handle? And what does it mean to add some arbitrary number N to a class handle? Are there cases where it makes sense?
@jakobbotsch @AndyAyersMS @EgorBo @SingleAccretion
The text was updated successfully, but these errors were encountered: