Skip to content

JIT: Use logical local definitions in more places - #137727

Merged
jakobbotsch merged 4 commits into
dotnet:mainfrom
jakobbotsch:jit-logical-local-defs
Nov 24, 2026
Merged

jakobbotsch merged 4 commits into
dotnet:mainfrom
jakobbotsch:jit-logical-local-defs

Conversation

@jakobbotsch

Copy link
Copy Markdown
Member

Generalize code that looks for local definitions to use VisitLogicalLocalDefs instead of only recognizing local store nodes:

  • gtHasRef, gtMayHaveStoreInterference, gtHasLocalsWithAddrOp and gtHasAddressExposedLocals consider all logical local definitions.
  • Local morph's LoopDefinitions records all logical local definitions.
  • optRemoveRedundantZeroInits counts definitions made by other nodes.
  • Mask conversion candidates defined by other nodes are invalidated.
  • Object allocation connects locals defined by unmodelled nodes to the unknown source and marks them as escaping.

VisitLogicalLocalDefs now skips nodes without GTF_ASG, and fgDebugCheckFlagsAndTypes verifies that nodes defining locals have GTF_ASG, using the new VisitLogicalLocalDefsInternal.

Generalize code that looks for local definitions to use
`VisitLogicalLocalDefs` instead of only recognizing local store nodes:

- `gtHasRef`, `gtMayHaveStoreInterference`, `gtHasLocalsWithAddrOp` and
  `gtHasAddressExposedLocals` consider all logical local definitions.
- Local morph's `LoopDefinitions` records all logical local definitions.
- `optRemoveRedundantZeroInits` counts definitions made by other nodes.
- Mask conversion candidates defined by other nodes are invalidated.
- Object allocation connects locals defined by unmodelled nodes to the
  unknown source and marks them as escaping.

`VisitLogicalLocalDefs` now skips nodes without `GTF_ASG`, and
`fgDebugCheckFlagsAndTypes` verifies that nodes defining locals have
`GTF_ASG`, using the new `VisitLogicalLocalDefsInternal`.

Co-authored-by: Copilot <[email protected]>
Copilot-Session: 36da9052-8682-4d23-95c8-e0be241095bc
@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 Nov 17, 2026
@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 5 pipeline(s).
10 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.

@jakobbotsch

jakobbotsch commented Nov 17, 2026 •

Copy link
Copy Markdown
Member Author

cc @dotnet/jit-contrib PTAL @AndyAyersMS

Diffs. These are all related to async indicator defs/uses -- this PR is no-diff on top of #137548 which ensures the use/def of the async indicator happens after all arguments.
No diffs.

Comment thread src/coreclr/jit/optimizer.cpp Resolved
jakobbotsch and others added 2 commits November 17, 2026 16:40
…oInits`

Definitions made through `GT_LCL_ADDR` nodes with `GTF_VAR_DEF` are counted
via `VisitLogicalLocalDefs` for the defining node, so skip them when counting
local references and definitions.

Co-authored-by: Copilot <[email protected]>
Copilot-Session: 36da9052-8682-4d23-95c8-e0be241095bc
@jakobbotsch

Copy link
Copy Markdown
Member Author

Ping @AndyAyersMS, this modifies a few more places to automatically handle GT_STORE_LCL_VARS at its introduction without requiring any code changes.

@AndyAyersMS AndyAyersMS left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM

Should we deprecate the DoLclVarsOnly feature, seems like it is now increasingly easy to misuse this...?

@jakobbotsch

Copy link
Copy Markdown
Member Author

Should we deprecate the DoLclVarsOnly feature, seems like it is now increasingly easy to misuse this...?

We could also make DoLclVarsOnly visit GT_STORE_LCL_VARS as well, but perhaps full removal is the best. I opened a follow-up issue #138135.

@jakobbotsch

Copy link
Copy Markdown
Member Author

/ba-g Deadletter

@jakobbotsch
jakobbotsch merged commit becd277 into dotnet:main Nov 24, 2026
125 of 128 checks passed
@jakobbotsch
jakobbotsch deleted the jit-logical-local-defs branch November 24, 2026 07:44
@dotnet-milestone-bot dotnet-milestone-bot Bot added this to the 12.0-preview1 milestone Nov 25, 2026
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.

2 participants