Skip to content

Enter and leave analysis regions for receiver calls in a call chain - #86100

Merged
AlekseyTs merged 2 commits into
dotnet:mainfrom
nurullahturkoglu:fix/region-analysis-call-receiver-86099
Oct 20, 2026
Merged

AlekseyTs merged 2 commits into
dotnet:mainfrom
nurullahturkoglu:fix/region-analysis-call-receiver-86099

Conversation

@nurullahturkoglu

@nurullahturkoglu nurullahturkoglu commented Oct 17, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #86099

Since #67913, AbstractFlowPass.VisitCall walks a chain of receiver calls with an explicit stack, so the receiver calls never go through VisitAlways. When the region passed to AnalyzeDataFlow is one of those receivers, the region is never entered and the analysis returns Succeeded == false with empty results.

This calls EnterRegionIfNeeded for each receiver call on the way down the chain and LeaveRegionIfNeeded after each one is visited, like #76412 did for binary operators. The outermost call still goes through VisitAlways, so its region is left only after the state is restored for omitted calls.

Added Repro_86099, CallChainReceivers and CallChainReceiverWithOutArgument to RegionAnalysisTests. All three fail without the change and pass with it. The rest of the Emit3 tests pass on macOS arm64 (net10.0), except 263 tests that fail to start ilasm because only the osx-x64 binary is available here. I haven't run the tests on Windows.

I didn't add VB tests. From reading the code, VB's VisitCall visits the receiver recursively, so it shouldn't be affected.

Microsoft Reviewers: Open in CodeFlow

@nurullahturkoglu
nurullahturkoglu requested a review from a team as a code owner October 17, 2026 22:41
@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 1 pipeline(s).
1 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 dotnet-policy-service Bot added the Community The pull request was submitted by a contributor who is not a Microsoft employee. label Oct 17, 2026
@jjonescz
jjonescz requested a review from AlekseyTs October 19, 2026 08:32

VisitReceiverBeforeCall(node.ReceiverOpt, node.Method);

do

@AlekseyTs AlekseyTs Oct 20, 2026 •

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.

Please switch to while (true) loop. Something like:

                do
                {
                    visitArgumentsAndCompleteAnalysis(node);

                    if (!calls.Any())
                    {
                        break;
                    }

                    LeaveRegionIfNeeded(node);
                    node = calls.Pop();
                }

``` #Closed

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Done

@AlekseyTs

Copy link
Copy Markdown
Contributor

Done with review pass (commit 1)

@AlekseyTs AlekseyTs 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.

LGTM (commit 2)

@AlekseyTs
AlekseyTs merged commit a86ae2e into dotnet:main Oct 20, 2026
22 checks passed
@dotnet-policy-service dotnet-policy-service Bot added this to the Next milestone Oct 20, 2026
@AlekseyTs

Copy link
Copy Markdown
Contributor

@nurullahturkoglu Thank you for the contribution

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Area-Compilers Community The pull request was submitted by a contributor who is not a Microsoft employee.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

AnalyzeDataFlow should succeed when the region is the receiver of an instance method call

4 participants