Ignore PhiArgs without matching actual preds#125093
Ignore PhiArgs without matching actual preds#125093EgorBo wants to merge 13 commits intodotnet:mainfrom
Conversation
|
Tagging subscribers to this area: @JulieLeeMSFT, @jakobbotsch |
There was a problem hiding this comment.
Pull request overview
Updates CoreCLR JIT’s assertion propagation through SSA PHI nodes to be more conservative when PHI arguments don’t correspond to actual CFG predecessors, and adds a regression test for #124507.
Changes:
- Add a guard in
optVisitReachingAssertionsto abort PHI-based assertion inference when aPhiArgreferences a non-predecessor block. - Add a new JIT regression test
Runtime_124507. - Wire the new test into
Regression_ro_2.csproj.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| src/coreclr/jit/compiler.hpp | Abort PHI reaching-assertions walk when a PHI arg pred block is not an actual predecessor. |
| src/tests/JIT/Regression/Regression_ro_2.csproj | Includes the new Runtime_124507 regression test source file. |
| src/tests/JIT/Regression/JitBlue/Runtime_124507/Runtime_124507.cs | Adds a reduced repro as an xUnit test entry point for #124507. |
…ntime-1 into fix-optVisitReachingAssertions
|
PTAL @AndyAyersMS @dotnet/jit-contrib Also, I was not brave enough to just ignore PhiArgs without matching pred blocks (but if I do it, I get -200kb diff improvement). |
|
Can you describe what goes wrong without this fix? Naively I'd expect that if we considered assertions from preds that no longer reached we would only be more conservative. |
|
@AndyAyersMS it turned out the actual bug was in I propose we still keep the optVisitReachingAssertions change (it's no longer necessary to fix the bug) since the regression is pretty small just in case. We can alter the PhiVN if we want and remove dead preds somewhere (e.g. in GlobalAP) |
| ASSERT_VALRET_TP Compiler::optGetEdgeAssertions(const BasicBlock* block, const BasicBlock* blockPred) const | ||
| { | ||
| if ((blockPred->KindIs(BBJ_COND) && blockPred->TrueTargetIs(block))) | ||
| if (blockPred->KindIs(BBJ_COND)) |
There was a problem hiding this comment.
It seems odd that we're only suspicious of BBJ_COND preds here. Shouldn't we do the same check no matter what kind of pred it is?
If block is not a successor of blockPred, return an empty BV.
There was a problem hiding this comment.
@AndyAyersMS oops, that was exactly what I had in my mind, but I put it under a wrong branch. Fixed. thanks for noticing
src/coreclr/jit/assertionprop.cpp
Outdated
| // Return empty set if the edge doesn't exist | ||
| // (e.g. a stale PHI arg pred after edge redirection by RBO). | ||
| if (!blockPred->FalseTargetIs(block)) | ||
| if (blockPred->GetUniqueSucc() == block) |
There was a problem hiding this comment.
This may be too restrictive now?
It should still be ok to propagate assertions from BBJ_SWITCH or even maybe even BBJ_EHINALLYRET which can have multiple successors, so long as block is one of them.
Fixes #124507
A couple of diffs