Skip to content

JIT: Replace fgMorphTree with fgMorphArgs for calls introduced after rationalization - #127507

Closed
jakobbotsch with Copilot wants to merge 1 commit into
mainfrom
copilot/replace-fgmorph-tree-with-fgmorph-args
Closed

jakobbotsch with Copilot wants to merge 1 commit into
mainfrom
copilot/replace-fgmorph-tree-with-fgmorph-args

Conversation

Copilot AI commented Apr 28, 2026

Copy link
Copy Markdown
Contributor

Post-rationalization phases (lowering, async transformation, GS cookie checks) were calling fgMorphTree on freshly created GenTreeCall* nodes. fgMorphTree routes through fgMorphCall, which performs tail-call analysis, inlining marking, and GC safe-point flagging — all irrelevant or already completed before rationalization. The correct operation for these sites is fgMorphArgs, which handles only ABI info and argument processing.

Description

Changed files: lower.cpp, async.cpp, gschecks.cpp, compiler.h

  • lower.cpp — Replace fgMorphTree with fgMorphArgs at four call sites:

    • LowerVirtualVtableCall (interface lookup resolution call)
    • LowerCFGCall (CFG validate-indirect call)
    • InsertPInvokeCallProlog / InsertPInvokeCallEpilog (pinvoke helper calls)
    • For InsertPInvokeMethodProlog, the original fgMorphTree(store) (where store wraps the call) is replaced with fgMorphArgs(call) directly — the store wrapper needs no morphing in LIR mode, and the original was discarding the return value of fgMorphTree anyway
    • Update stale "A hacky way to safely call fgMorphTree in Lower" comments on existing fgMorphArgs sites to reflect the actual intent
  • async.cpp — Replace fgMorphTree with fgMorphArgs for all seven call nodes created during async state-machine transformation (continuation allocation, context capture/restore, finish, rethrow)

  • gschecks.cpp — Replace fgMorphTree with fgMorphArgs for the special-copy-helper call inserted for unsafe buffer GS checks

  • compiler.h — Move fgMorphArgs declaration from private to public alongside fgMorphTree; AsyncTransformation is not a friend of Compiler so it requires public access

Copilot AI requested review from Copilot and removed request for Copilot April 28, 2026 13:21
@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 Apr 28, 2026
@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.

@dotnet-policy-service

Copy link
Copy Markdown
Contributor

Draft Pull Request was automatically closed for 30 days of inactivity. Please let us know if you'd like to reopen it.

@github-actions github-actions Bot locked and limited conversation to collaborators Nov 14, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

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