JIT: Fix async analysis filter dataflow - #132027
Draft
jakobbotsch wants to merge 1 commit into
Draft
Conversation
…tion The data flow used for default-value analysis and preserved-value analysis did not properly account for predecessors of filter handlers. Switch to `BlockPredsWithEH` which models all exceptional flow faithfully. Fix dotnet#132015 Fix dotnet#132016 Fix dotnet#132017
|
Azure Pipelines: Successfully started running 5 pipeline(s). 11 pipeline(s) were filtered out due to trigger conditions. There may be pipelines that require an authorized user to comment /azp run to run. |
Contributor
|
Tagging subscribers to this area: @JulieLeeMSFT, @jakobbotsch |
Contributor
There was a problem hiding this comment.
Pull request overview
This PR updates CoreCLR JIT async default/preserved-value dataflow to account for exceptional predecessors of handler blocks (via BlockPredsWithEH), and adds new async regression tests covering filtered/nested EH cases related to issues #132015/#132016/#132017.
Changes:
- Update
MutationDataFlowCallback::MergeHandlerin async analysis to merge usingBlockPredsWithEHrather than iterating the contiguous try block range. - Clear the
BlockPredsWithEHpredecessor cache before running async analyses to avoid using stale memoized results. - Add three new xUnit-based async regression tests (with minimal per-test csproj files) for the reported scenarios.
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| src/coreclr/jit/asyncanalysis.cpp | Switch handler-merge predecessor enumeration to BlockPredsWithEH for more faithful exceptional-flow modeling. |
| src/coreclr/jit/async.cpp | Clear m_blockToEHPreds cache before async analyses that rely on BlockPredsWithEH. |
| src/tests/async/regression/132015.csproj | Add new regression test project for #132015. |
| src/tests/async/regression/132015.cs | Add regression tests validating value visibility across async suspension with filters/finally. |
| src/tests/async/regression/132016.csproj | Add new regression test project for #132016. |
| src/tests/async/regression/132016.cs | Add regression test for nested catch/filter behavior across async suspension. |
| src/tests/async/regression/132017.csproj | Add new regression test project for #132017. |
| src/tests/async/regression/132017.cs | Add regression test for catch-filter + nested catch starting an un-awaited task. |
Comment on lines
39
to
+43
| void MergeHandler(BasicBlock* block, BasicBlock* firstTryBlock, BasicBlock* lastTryBlock) | ||
| { | ||
| // A handler can be reached from any point in the try region. | ||
| // A local is mutated at handler entry if it was mutated at try | ||
| // entry or mutated anywhere within the try region. | ||
| for (BasicBlock* tryBlock = firstTryBlock; tryBlock != lastTryBlock->Next(); tryBlock = tryBlock->Next()) | ||
| for (FlowEdge* pred = m_compiler->BlockPredsWithEH(block); pred != nullptr; pred = pred->getNextPredEdge()) | ||
| { | ||
| VarSetOps::UnionD(m_compiler, m_mutatedVarsIn[block->bbNum], m_mutatedVarsIn[tryBlock->bbNum]); | ||
| VarSetOps::UnionD(m_compiler, m_mutatedVarsIn[block->bbNum], m_mutatedVars[tryBlock->bbNum]); | ||
| Merge(block, pred->getSourceBlock(), pred->getDupCount()); |
Comment on lines
+27
to
+29
| test.M(false).GetAwaiter().GetResult(); | ||
| test.M(true).GetAwaiter().GetResult(); | ||
| s_pending.GetAwaiter().GetResult(); |
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
The data flow used for default-value analysis and preserved-value analysis did not properly account for predecessors of filter handlers. Switch to
BlockPredsWithEHwhich models all exceptional flow faithfully.Fix #132015
Fix #132016
Fix #132017