Skip to content

JIT: Fix async analysis filter dataflow - #132027

Draft
jakobbotsch wants to merge 1 commit into
dotnet:mainfrom
jakobbotsch:fix-132015
Draft

JIT: Fix async analysis filter dataflow#132027
jakobbotsch wants to merge 1 commit into
dotnet:mainfrom
jakobbotsch:fix-132015

Conversation

@jakobbotsch

Copy link
Copy Markdown
Member

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 #132015
Fix #132016
Fix #132017

…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
Copilot AI review requested due to automatic review settings August 7, 2026 20:24
@github-actions github-actions Bot added the area-CodeGen-coreclr CLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMI label Aug 7, 2026
@azure-pipelines

Copy link
Copy Markdown
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.

@dotnet-policy-service

Copy link
Copy Markdown
Contributor

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

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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::MergeHandler in async analysis to merge using BlockPredsWithEH rather than iterating the contiguous try block range.
  • Clear the BlockPredsWithEH predecessor 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();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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.

Unskip NestedCatch_DuplicateLocal_NoAwaitInNestedCatch Unskip NestedCatch_DuplicateLocal_Level2 Unskip AsyncInCatchFilter

2 participants