-
Notifications
You must be signed in to change notification settings - Fork 5.3k
Don't remove dead indirections that may throw. #40226
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
|
x64 pmi framework diffs: |
|
No x64 pmi benchmark diffs. |
|
@sandreenko @dotnet/jit-contrib PTAL |
sandreenko
left a comment
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
src/tests/JIT/Regression/JitBlue/GitHub_39823/GitHub_39823.csproj
Outdated
Show resolved
Hide resolved
|
@sandreenko I tweaked my fix so that the representation of unconsumed indirections is consistent. The diffs are the same as with the previous version of my changes. PTAL. |
sandreenko
left a comment
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, I will use this function to fix follow up for https://github.com/dotnet/runtime/pull/39824/files
src/coreclr/src/jit/compiler.cpp
Outdated
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.
I think that the logic for when to generate GT_IND vs. GT_NULLCHECK shoud remain in Lowering - see Lowering::LowerIndir(). Also, I found that if I changed dead indirections to GT_NULLCHECK too early in the compile, CSE would miss out on opportunities to CSE dead indirections in loops.
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.
I need to call this function from liveness that’s running during lower, that’s why I placed on Compiler. If I kept it in Lower, I would have to pass an instance of Lower to liveness, which would be odd.
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.
@CarolEidt it appeared that these unused IND could appear after lowering so we can't rely on LowerIndir to replace NULLCHECK with IND for arm32.
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.
I see. That said, I still think that we should 1) avoid generating GT_NULLCHECK when not in LIR form, and 2) leave the method on Lowering that determines whether to transform to GT_NULLCHECK as it is target-dependent. It can be static, and then this method can do the actual transformation, since it updates block and Compiler state (that said, it seems to me that if we care about whether the method or block has a nullcheck, that should be set for the GT_IND form of nullcheck as well). As much as possible, I'd like to keep the target-dependent code in the backend files.
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.
Also, I found that if I changed dead indirections to GT_NULLCHECK too early in the compile, CSE would miss out on opportunities to CSE dead indirections in loops.
we have optimizations in earlyProp that prefer NULLCHECK over IND, see OMF_HAS_NULLCHECK. So if we stop generating NULLCHECK before lowering we would get both regressions and improvements.
Also, the importer generates null checks in some cases instead of GT_IND and GT_FIELD.
I agree that it is error-prone and confusing, would be nice to find a better way to handle this.
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.
- We intentionally generate
GT_NULLCHECKbefore LIR in many places because both earlyProp (gtFoldNullCheck) and assertion propagation have optimizations to eliminate redundant null checks. - I can make the method static on Lower and pass Compiler and block instances to it. Would that address your concern?
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.
Currently the nullcheck flags on the compiler instance and basic block are only used by earlyProp. Still, I'd like to keep them up-to-date.
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.
@erozenfeld - that would be fine, but it would also be fine to have a static method on Lowering that simply determined which option to use.
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.
@CarolEidt I addressed your feedback. PTAL.
Liveness incorrectly removed indirection rhs's of dead assignments. This change fixes that. Fixes dotnet#39823.
CarolEidt
left a comment
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 - thanks
Liveness incorrectly removed indirection rhs's of dead assignments. This change fixes that. Fixes dotnet#39823.
Liveness incorrectly removed indirection rhs's of dead assignments.
This change fixes that.
Fixes #39823.