Skip to content

Fix flags in EarlyProp after nullcheck is removed #112717

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

Merged
merged 2 commits into from
Feb 20, 2025

Conversation

EgorBo
Copy link
Member

@EgorBo EgorBo commented Feb 19, 2025

Fixes #112333

When we have:

NULLCHECK(addr)
IND(addr)

if we decide to remove the nullcheck (when it is followed by an indirect which is recognized as an implicit nullcheck for the same address), we should update the flags in that indirect as it's no longer non-faulting.

@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 Feb 19, 2025
@EgorBo
Copy link
Member Author

EgorBo commented Feb 20, 2025

/azp run runtime-coreclr jitstress-random

Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@EgorBo EgorBo marked this pull request as ready for review February 20, 2025 09:24
@Copilot Copilot AI review requested due to automatic review settings February 20, 2025 09:24
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Copilot wasn't able to review any files in this pull request.

Files not reviewed (1)
  • src/coreclr/jit/earlyprop.cpp: Language not supported

@EgorBo
Copy link
Member Author

EgorBo commented Feb 20, 2025

PTAL @jakobbotsch cc @dotnet/jit-contrib
the fix that you've suggested

A few diffs, surprisingly, improvements. I guess it's CSE failing for mismatching exception sets?

@@ -457,6 +457,10 @@ bool Compiler::optFoldNullCheck(GenTree* tree, LocalNumberToNullCheckTreeMap* nu
nullCheckTree->SetHasOrderingSideEffect();
nullCheckTree->gtFlags |= GTF_IND_NONFAULTING;

// The current indir is no longer non-faulting.
tree->gtFlags &= ~GTF_IND_NONFAULTING;
tree->SetIndirExceptionFlags(this);
Copy link
Member Author

@EgorBo EgorBo Feb 20, 2025

Choose a reason for hiding this comment

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

I presume in theory we can avoid removing GTF_IND_NONFAULTING and adding GTF_EXCEPT if the leading (if it is in fact leading) nullcheck had them, but wanted to be on a safer side

Copy link
Member

@jakobbotsch jakobbotsch Feb 20, 2025

Choose a reason for hiding this comment

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

Is the SetIndirExceptionFlags necessary? I assume it should be recomputed below when all side effect flags are updated.

Copy link
Member Author

Choose a reason for hiding this comment

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

Correct, GTF_EXCEPT is set later via gtUpdateNodeOperSideEffects, so this one is redundant

@EgorBo EgorBo merged commit 2d73b37 into dotnet:main Feb 20, 2025
108 of 112 checks passed
@EgorBo EgorBo deleted the fix-earlyprop-bug branch February 20, 2025 13:45
@github-actions github-actions bot locked and limited conversation to collaborators Mar 23, 2025
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
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Test failure: JIT/Regression/JitBlue/Runtime_82535/Runtime_82535/Runtime_82535.dll
2 participants