Skip to content

Migrate analyzer local state to a structured value lattice - #134468

Draft
jtschuster wants to merge 1 commit into
tuple-deconstruction-testsfrom
tuple-localvalue-lattice
Draft

jtschuster wants to merge 1 commit into
tuple-deconstruction-testsfrom
tuple-localvalue-lattice

Conversation

@jtschuster

@jtschuster jtschuster commented Sep 22, 2026

Copy link
Copy Markdown
Member

Summary

In the analyzer, we see ITupleOperations that could be lowered to ValueTuple construction and destruction, or lowered to assignments to local variables -- but there is no way to know for sure. However, the basic (and relatively common) case of (a, b) = (b, a) should be supported. This requires us to model a Tuple value in dataflow. In the current implementation, we can model it in Deconstruction evaluation, but it's not a first-class concept in the dataflow visitor. This PR stack makes the concept of a Tuple of TValue a first-class concept.

ITupleOperations are treated as Top in the lattice for all cases except for when it is the outer operation on a DeconstructionOperation (i.e. an expression in the form of (a, b) = (b, a)). If the TupleOperation appears elsewhere in the deconstruction (for example, within a ternary that is deconstructed (a, b) = c ? (x, y) : (b, a)), we make no assumption about whether or not a ValueTuple is created.

This PR introduces a recursive LocalValue and its lattice for local state, r-value captures, and hoisted state, while preserving existing deconstruction behavior. This LocalValue implements the first-class support for Tuples of TValue in the dataflow visitor. Also adds equality, deep-copy, and lattice-law tests.

Validation

  • Analyzer DataFlow: 85 passed, 2 skipped.
  • ILLink DataFlow0: 42 passed; DataFlow1: 41 passed.
  • NativeAOT shared ConstructedTypesDataFlow and DeconstructFieldTarget: 2 passed.

Stack layer 2/3, based on the tests-only branch.

Note

This PR was generated with GitHub Copilot assistance.


Stack created with GitHub Stacks CLIGive Feedback 💬

@jtschuster
jtschuster added this pull request to stack #134470 September 22, 2026 22:14
@dotnet-policy-service dotnet-policy-service Bot added the linkable-framework Issues associated with delivering a linker friendly framework label Sep 22, 2026
@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 3 pipeline(s).
13 pipeline(s) were filtered out due to trigger conditions.
There may be pipelines that require an authorized user to comment /azp run to run.

@github-actions github-actions Bot added the area-Tools-ILLink .NET linker development as well as trimming analyzers label Sep 22, 2026
@dotnet-policy-service

Copy link
Copy Markdown
Contributor

Tagging subscribers to this area: @agocke, @dotnet/illink
See info in area-owners.md if you want to be subscribed.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@jtschuster
jtschuster force-pushed the tuple-localvalue-lattice branch from cae2018 to ab62d25 Compare September 22, 2026 23:21

This branch has not been deployed

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

Labels

area-Tools-ILLink .NET linker development as well as trimming analyzers linkable-framework Issues associated with delivering a linker friendly framework

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

1 participant