-
Notifications
You must be signed in to change notification settings - Fork 5.4k
Fix PHI non-null pattern #104493
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
Closed
Closed
Fix PHI non-null pattern #104493
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1635,7 +1635,33 @@ bool ValueNumStore::IsKnownNonNull(ValueNum vn) | |
| } | ||
|
|
||
| VNFuncApp funcAttr; | ||
| return GetVNFunc(vn, &funcAttr) && (s_vnfOpAttribs[funcAttr.m_func] & VNFOA_KnownNonNull) != 0; | ||
| if (!GetVNFunc(vn, &funcAttr)) | ||
| { | ||
| return false; | ||
| } | ||
|
|
||
| if ((s_vnfOpAttribs[funcAttr.m_func] & VNFOA_KnownNonNull) != 0) | ||
| { | ||
| return true; | ||
| } | ||
|
|
||
| // TODO-VN: we can add more cases, e.g. "VNF_ADD(KnownNotNull, smallCns)" | ||
|
|
||
| if (funcAttr.m_func == VNF_Cast) | ||
| { | ||
| var_types castFromType = TypeOfVN(vn); | ||
| var_types castToType; | ||
| bool srcIsUnsigned; | ||
| GetCastOperFromVN(funcAttr.m_args[1], &castToType, &srcIsUnsigned); | ||
|
|
||
| // Any integral cast from a known non-null value is always non-null. | ||
| if (varTypeIsIntegralOrI(castFromType) && varTypeIsIntegralOrI(castToType)) | ||
| { | ||
| return IsKnownNonNull(funcAttr.m_args[0]); | ||
| } | ||
| } | ||
|
|
||
| return false; | ||
| } | ||
|
|
||
| bool ValueNumStore::IsSharedStatic(ValueNum vn) | ||
|
|
@@ -11136,12 +11162,6 @@ void Compiler::fgValueNumberStore(GenTree* store) | |
|
|
||
| valueVNPair.SetBoth(initObjVN); | ||
| } | ||
| else if (value->TypeGet() == TYP_REF) | ||
| { | ||
| // If we have an unsafe IL store of a TYP_REF to a non-ref (typically a TYP_BYREF) | ||
| // then don't propagate this ValueNumber to the lhs, instead create a new unique VN. | ||
| valueVNPair.SetBoth(vnStore->VNForExpr(compCurBB, store->TypeGet())); | ||
| } | ||
|
Comment on lines
-11139
to
-11144
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Might be a good idea to see if you can dig up why this was added to verify it won't cause any problems to remove it. |
||
| else | ||
| { | ||
| // This means that there is an implicit cast on the value. | ||
|
|
||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Is this change ok?
LCL_FLDwill create an assertion about the parent local without encoding any information about the offset, which seems odd.