Skip to content
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

Delete impCheckForNullPointer #61576

Merged

Conversation

SingleAccretion
Copy link
Contributor

@SingleAccretion SingleAccretion commented Nov 14, 2021

The comment above the method mentions "many problems" with leaving null pointers around, but it is unclear what kind of problems. I can only speculate those were the problems in legacy codegen which "could not handle constant op1".

It also mentions that "we cannot even fold (null+offset)", which is incorrect: "gtFoldExprConst" does in fact fold such expressions to zero byrefs. It is also the case that spilling the null into a local affects little as local assertion propagation happily propagates the null back into its original place.

There was also a little bug associated with the method that got fixed: morph was trying to use it, and in the process created uses of a local that was not initialized, since the statement list used by the method is the importer's one, invalid in morph.

One diff in the tests: MinOpts method no longer had the local spilled. It is expected we will not see a lot of diffs because of the aforementioned local assertion propagation (there are 6 additional text-only diffs which showed the local in question as zero-ref, as we'd expect).

The comment above the method mentions "many problems" with leaving
null pointers around, but it is unclear what kind of problems. I can
only speculate those were the problems in legacy codegen which "could
not handle constant op1".

It also mentions that "we cannot even fold (null+offset)", which is
incorrect: "gtFoldExprConst" does in fact fold such expressions to
zero byrefs. It is also the case that spilling the null into a local
affects little as local assertion propagation happily propagates the
null back into its original place.

There was also a little bug associated with the method that got fixed:
morph was trying to use it, and in the process created uses of a local
that was not initialized, since the statement list used by the method
is the importer's one, invalid in morph.
@ghost ghost added the community-contribution Indicates that the PR has been added by a community member label Nov 14, 2021
@dotnet-issue-labeler dotnet-issue-labeler bot added the area-CodeGen-coreclr CLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMI label Nov 14, 2021
@ghost
Copy link

ghost commented Nov 14, 2021

Tagging subscribers to this area: @JulieLeeMSFT
See info in area-owners.md if you want to be subscribed.

Issue Details

The comment above the method mentions "many problems" with leaving null pointers around, but it is unclear what kind of problems. I can only speculate those were the problems in legacy codegen which "could not handle constant op1".

It also mentions that "we cannot even fold (null+offset)", which is incorrect: "gtFoldExprConst" does in fact fold such expressions to zero byrefs. It is also the case that spilling the null into a local affects little as local assertion propagation happily propagates the null back into its original place.

There was also a little bug associated with the method that got fixed: morph was trying to use it, and in the process created uses of a local that was not initialized, since the statement list used by the method is the importer's one, invalid in morph.

One diff in the tests: MinOpts method no longer had the local spilled. It is expected we will not see a lot of diffs because of the aforementioned local assertion propagation (there are 6 additional diffs with text-only diffs which showed the local in question as zero-ref, as we'd expect).

Author: SingleAccretion
Assignees: -
Labels:

area-CodeGen-coreclr, community-contribution

Milestone: -

@@ -9236,10 +9236,8 @@ GenTree* Compiler::fgMorphCall(GenTreeCall* call)
fgWalkTreePost(&value, resetMorphedFlag);
#endif // DEBUG

GenTree* const nullCheckedArr = impCheckForNullPointer(arr);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the morph bug: it was creating an ASG in a statement that did not get properly prepended.

GenTree* const nullCheckedArr = impCheckForNullPointer(arr);
GenTree* const arrIndexNode = gtNewIndexRef(TYP_REF, nullCheckedArr, index);
GenTree* const arrStore = gtNewAssignNode(arrIndexNode, value);
arrStore->gtFlags |= GTF_ASG;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

gtNewAssignNode already marks the node with the flag.

@SingleAccretion SingleAccretion marked this pull request as ready for review November 15, 2021 11:16
@SingleAccretion
Copy link
Contributor Author

@dotnet/jit-contrib

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-CodeGen-coreclr CLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMI community-contribution Indicates that the PR has been added by a community member
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants