Skip to content

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

Draft
Copilot wants to merge 1 commit intomainfrom
copilot/replace-fgmorph-tree-with-fgmorph-args
Draft

JIT: Replace fgMorphTree with fgMorphArgs for calls introduced after rationalization#127507
Copilot wants to merge 1 commit intomainfrom
copilot/replace-fgmorph-tree-with-fgmorph-args

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Apr 28, 2026

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

…nalization

Agent-Logs-Url: https://github.com/dotnet/runtime/sessions/676423b6-a547-47ac-96ec-4cc74af33ac3

Co-authored-by: jakobbotsch <7887810+jakobbotsch@users.noreply.github.com>
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.

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