Skip to content

JIT: Centralize WellKnownArg definitions#130252

Draft
jakobbotsch wants to merge 4 commits into
dotnet:mainfrom
jakobbotsch:fix-130227
Draft

JIT: Centralize WellKnownArg definitions#130252
jakobbotsch wants to merge 4 commits into
dotnet:mainfrom
jakobbotsch:fix-130227

Conversation

@jakobbotsch

Copy link
Copy Markdown
Member

Use a single wellknownargs.h that is included multiple times to build various pieces of information we query about arguments. Rewrite users in terms of columns defined in that file.

Fix #130227

Use a single wellknownargs.h that is included multiple times to build
various pieces of information we query about arguments. Rewrite users in
terms of columns defined in that file.
Copilot AI review requested due to automatic review settings July 6, 2026 14:41
@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 Jul 6, 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.

Comment thread src/coreclr/jit/compiler.hpp Outdated
Comment on lines 7929 to 7935
for (CallArg& arg : call->gtArgs.Args())
{
switch (arg.GetWellKnownArg())
if (!arg.IsUserArg() || (arg.GetWellKnownArg() == WellKnownArg::ThisPointer))
{
case WellKnownArg::RetBuffer:
case WellKnownArg::ThisPointer:
case WellKnownArg::AsyncContinuation:
// Not part of signature but we still expect to see it here
continue;
case WellKnownArg::None:
break;
default:
assert(!"Unexpected well known arg to method GDV candidate");
continue;
// Not part of the signature
continue;
}

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Actual bug fix is here.

Comment on lines +34 to +35
WELL_KNOWN_ARG(SwiftError, "swift error", true, false)
WELL_KNOWN_ARG(SwiftSelf, "swift self", true, false)

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

These are defined in IL and also marked well-known, so I made them true for isILArg.

Copilot AI 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.

Pull request overview

This PR centralizes WellKnownArg metadata into a single wellknownargs.h “X-macro” list that is included multiple times to generate the enum and related query helpers, and it adjusts GDV candidate argument handling to avoid asserting on unexpected well-known args.

Changes:

  • Introduces src/coreclr/jit/wellknownargs.h as the single source of truth for WellKnownArg entries and their metadata.
  • Rewrites WellKnownArg-related helpers (getWellKnownArgName, CallArg::IsUserArg, CallArg::IsArgAddedLate, arg dump short names) to be table-driven from wellknownargs.h.
  • Updates GDV compatibility checking to skip non-signature arguments via CallArg::IsUserArg() instead of asserting on “unexpected” well-known args.

Reviewed changes

Copilot reviewed 9 out of 9 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
src/coreclr/jit/wellknownargs.h New centralized table defining well-known args and their metadata.
src/coreclr/jit/morph.cpp Converts getWellKnownArgName to use the centralized table.
src/coreclr/jit/importercalls.cpp Updates GDV arg filtering logic; also includes a small indentation-only change.
src/coreclr/jit/importer.cpp Refactors inline arg init to use IsUserArg/InstParam instead of a well-known switch.
src/coreclr/jit/gentree.h Generates WellKnownArg enum members from the centralized table.
src/coreclr/jit/gentree.cpp Table-driven IsArgAddedLate, IsUserArg, and short-name lookup for arg messages.
src/coreclr/jit/fginline.cpp Refactors inline argument setup logic to use IsUserArg/InstParam.
src/coreclr/jit/compiler.hpp Stops tagging the helper “method handle” arg as a well-known arg.
src/coreclr/jit/CMakeLists.txt Adds wellknownargs.h to the JIT header list.
Comments suppressed due to low confidence (1)

src/coreclr/jit/importercalls.cpp:7648

  • Extra leading spaces were introduced on this loop and its body, making indentation inconsistent with the surrounding block and adding whitespace-only noise.
        for (UINT32 i = 0; i < numberOfMethods; i++)
        {
            CORINFO_CONST_LOOKUP lookup = {};
            info.compCompHnd->getFunctionFixedEntryPoint((CORINFO_METHOD_HANDLE)likelyMethods[i].handle, false,
                                                         &lookup);

Comment thread src/coreclr/jit/wellknownargs.h
Copilot AI review requested due to automatic review settings July 6, 2026 14:50

Copilot AI 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.

Pull request overview

Copilot reviewed 9 out of 9 changed files in this pull request and generated 2 comments.

Comment thread src/coreclr/jit/wellknownargs.h
Comment thread src/coreclr/jit/fginline.cpp
Copilot AI review requested due to automatic review settings July 6, 2026 22:58
pParam->inlineInfo->InlineRoot->m_inlineStrategy
->NewContext(pParam->inlineInfo->inlineCandidateInfo->inlinersContext, pParam->inlineInfo->iciStmt,
pParam->inlineInfo->iciCall);
pParam->inlineInfo->argCnt = pParam->inlineCandidateInfo->methInfo.args.totalILArgs();

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Moved this into impInlineInitVars since I added some asserts that needed it, and this would otherwise be initialized after.

Copilot AI 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.

Pull request overview

Copilot reviewed 9 out of 9 changed files in this pull request and generated no new comments.

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.

Assertion failed '!"Unexpected well known arg to method GDV candidate"'

3 participants