Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/coreclr/jit/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -433,6 +433,7 @@ set( JIT_HEADERS
varset.h
vartype.h
vartypesdef.h
wellknownargs.h
)

# Arch specific headers
Expand Down
29 changes: 14 additions & 15 deletions src/coreclr/jit/fginline.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1399,7 +1399,6 @@ void Compiler::fgInvokeInlineeCompiler(GenTreeCall* call, InlineResult* inlineRe
pParam->inlineInfo->InlineRoot->m_inlineStrategy
->NewContext(pParam->inlineInfo->inlineCandidateInfo->inlinersContext, pParam->inlineInfo->iciStmt,
pParam->inlineInfo->iciCall);
pParam->inlineInfo->argCnt = pParam->inlineCandidateInfo->methInfo.args.totalILArgs();
Comment thread
jakobbotsch marked this conversation as resolved.
pParam->inlineInfo->tokenLookupContextHandle = pParam->inlineCandidateInfo->exactContextHandle;

JITLOG_THIS(pParam->pThis,
Expand Down Expand Up @@ -2313,27 +2312,27 @@ Statement* Compiler::fgInlinePrependStatements(InlineInfo* inlineInfo)
unsigned ilArgNum = 0;
for (CallArg& arg : call->gtArgs.Args())
{
InlArgInfo* argInfo = nullptr;
switch (arg.GetWellKnownArg())
InlArgInfo* argInfo;
if (arg.IsUserArg())
{
case WellKnownArg::RetBuffer:
case WellKnownArg::AsyncContinuation:
case WellKnownArg::AsyncExecutionContext:
case WellKnownArg::AsyncSynchronizationContext:
continue;
case WellKnownArg::InstParam:
argInfo = inlineInfo->inlInstParamArgInfo;
break;
default:
assert(ilArgNum < inlineInfo->argCnt);
argInfo = &inlineInfo->inlArgInfo[ilArgNum++];
break;
assert(ilArgNum < inlineInfo->argCnt);
argInfo = &inlArgInfo[ilArgNum++];
}
Comment thread
jakobbotsch marked this conversation as resolved.
else if (arg.GetWellKnownArg() == WellKnownArg::InstParam)
{
argInfo = inlineInfo->inlInstParamArgInfo;
}
else
{
continue;
}

assert(argInfo != nullptr);
fgInsertInlineeArgument(*argInfo, block, &afterStmt, &newStmt, callDI);
}

assert(ilArgNum == inlineInfo->argCnt);

// Add the CCTOR check if asked for.
// Note: We no longer do the optimization that is done before by staticAccessedFirstUsingHelper in the old inliner.
// Therefore we might prepend redundant call to HELPER.CORINFO_HELP_GETSHARED_NONGCSTATIC_BASE
Expand Down
72 changes: 16 additions & 56 deletions src/coreclr/jit/gentree.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1171,11 +1171,11 @@ bool CallArg::IsArgAddedLate() const
// static_cast to "enum class" for old gcc support
switch (static_cast<WellKnownArg>(m_wellKnownArg))
{
case WellKnownArg::VirtualStubCell:
case WellKnownArg::PInvokeCookie:
case WellKnownArg::PInvokeTarget:
case WellKnownArg::R2RIndirectionCell:
return true;
#define WELL_KNOWN_ARG(name, shortName, isILArg, addedByMorph) \
case WellKnownArg::name: \
return addedByMorph;
#include "wellknownargs.h"

default:
return false;
}
Expand All @@ -1185,18 +1185,18 @@ bool CallArg::IsArgAddedLate() const
// IsUserArg: Check if this is an argument that can be treated as
// user-defined (in IL).
//
// Remarks:
// "this" and ShiftLow/ShiftHigh are recognized as user-defined
//
bool CallArg::IsUserArg() const
{
switch (static_cast<WellKnownArg>(m_wellKnownArg))
{
case WellKnownArg::None:
case WellKnownArg::ShiftLow:
case WellKnownArg::ShiftHigh:
case WellKnownArg::ThisPointer:
return true;

#define WELL_KNOWN_ARG(name, shortName, isILArg, addedByMorph) \
case WellKnownArg::name: \
return isILArg;
#include "wellknownargs.h"

default:
return false;
}
Expand Down Expand Up @@ -14556,51 +14556,11 @@ const char* Compiler::gtGetWellKnownArgNameForArgMsg(WellKnownArg arg)
{
switch (arg)
{
case WellKnownArg::ThisPointer:
return "this";
case WellKnownArg::VarArgsCookie:
return "va cookie";
case WellKnownArg::InstParam:
return "gctx";
case WellKnownArg::AsyncContinuation:
return "async";
case WellKnownArg::RetBuffer:
return "retbuf";
case WellKnownArg::PInvokeFrame:
return "pinv frame";
case WellKnownArg::ShiftLow:
return "shift low";
case WellKnownArg::ShiftHigh:
return "shift high";
case WellKnownArg::VirtualStubCell:
return "vsd cell";
case WellKnownArg::PInvokeCookie:
return "pinv cookie";
case WellKnownArg::PInvokeTarget:
return "pinv tgt";
case WellKnownArg::R2RIndirectionCell:
return "r2r cell";
case WellKnownArg::ValidateIndirectCallTarget:
case WellKnownArg::DispatchIndirectCallTarget:
return "cfg tgt";
case WellKnownArg::SwiftError:
return "swift error";
case WellKnownArg::SwiftSelf:
return "swift self";
case WellKnownArg::X86TailCallSpecialArg:
return "tail call";
case WellKnownArg::StackArrayLocal:
return "&lcl arr";
case WellKnownArg::RuntimeMethodHandle:
return "meth hnd";
case WellKnownArg::AsyncExecutionContext:
return "exec ctx";
case WellKnownArg::AsyncSynchronizationContext:
return "sync ctx";
case WellKnownArg::WasmShadowStackPointer:
return "wasm sp";
case WellKnownArg::WasmPortableEntryPoint:
return "wasm pep";
#define WELL_KNOWN_ARG(name, shortName, isILArg, addedByMorph) \
case WellKnownArg::name: \
return shortName;
#include "wellknownargs.h"

default:
return nullptr;
}
Expand Down
25 changes: 2 additions & 23 deletions src/coreclr/jit/gentree.h
Original file line number Diff line number Diff line change
Expand Up @@ -4793,29 +4793,8 @@ class CallArgs;
enum class WellKnownArg : unsigned
{
None,
ThisPointer,
VarArgsCookie,
InstParam,
AsyncContinuation,
RetBuffer,
PInvokeFrame,
ShiftLow,
ShiftHigh,
VirtualStubCell,
PInvokeCookie,
PInvokeTarget,
R2RIndirectionCell,
ValidateIndirectCallTarget,
DispatchIndirectCallTarget,
SwiftError,
SwiftSelf,
X86TailCallSpecialArg,
StackArrayLocal,
RuntimeMethodHandle,
AsyncExecutionContext,
AsyncSynchronizationContext,
WasmShadowStackPointer,
WasmPortableEntryPoint
#define WELL_KNOWN_ARG(name, shortName, isILArg, addedByMorph) name,
#include "wellknownargs.h"
};

#ifdef DEBUG
Expand Down
29 changes: 15 additions & 14 deletions src/coreclr/jit/importer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13872,24 +13872,23 @@ void Compiler::impInlineInitVars(InlineInfo* pInlineInfo)
/* init the argument struct */
memset(inlArgInfo, 0, (MAX_INL_ARGS + 1) * sizeof(inlArgInfo[0]));

unsigned ilArgCnt = 0;
pInlineInfo->argCnt = pInlineInfo->inlineCandidateInfo->methInfo.args.totalILArgs();
unsigned ilArgCnt = 0;
for (CallArg& arg : call->gtArgs.Args())
{
InlArgInfo* argInfo;
switch (arg.GetWellKnownArg())
if (arg.IsUserArg())
{
case WellKnownArg::RetBuffer:
case WellKnownArg::AsyncContinuation:
case WellKnownArg::AsyncExecutionContext:
case WellKnownArg::AsyncSynchronizationContext:
// These do not appear in the table of inline arg info; do not include them
continue;
case WellKnownArg::InstParam:
pInlineInfo->inlInstParamArgInfo = argInfo = new (this, CMK_Inlining) InlArgInfo{};
break;
default:
argInfo = &inlArgInfo[ilArgCnt++];
break;
assert(ilArgCnt < pInlineInfo->argCnt);
argInfo = &inlArgInfo[ilArgCnt++];
}
else if (arg.GetWellKnownArg() == WellKnownArg::InstParam)
{
pInlineInfo->inlInstParamArgInfo = argInfo = new (this, CMK_Inlining) InlArgInfo{};
}
else
{
continue;
}

arg.SetEarlyNode(gtFoldExpr(arg.GetEarlyNode()));
Expand All @@ -13901,6 +13900,8 @@ void Compiler::impInlineInitVars(InlineInfo* pInlineInfo)
}
}

assert(ilArgCnt == pInlineInfo->argCnt);

#ifdef FEATURE_SIMD
bool foundSIMDType = pInlineInfo->hasSIMDTypeArgLocalOrReturn;
#endif // FEATURE_SIMD
Expand Down
16 changes: 4 additions & 12 deletions src/coreclr/jit/importercalls.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7928,18 +7928,10 @@ bool Compiler::isCompatibleMethodGDV(GenTreeCall* call, CORINFO_METHOD_HANDLE gd

for (CallArg& arg : call->gtArgs.Args())
{
switch (arg.GetWellKnownArg())
{
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;
if (!arg.IsUserArg() || (arg.GetWellKnownArg() == WellKnownArg::ThisPointer))
{
// Not part of the signature
continue;
}
Comment thread
jakobbotsch marked this conversation as resolved.

numArgs++;
Expand Down
6 changes: 3 additions & 3 deletions src/coreclr/jit/inline.h
Original file line number Diff line number Diff line change
Expand Up @@ -690,9 +690,9 @@ struct InlineInfo
CORINFO_CONTEXT_HANDLE tokenLookupContextHandle; // The context handle that will be passed to
// impTokenLookupContextHandle in Inlinee's Compiler.

unsigned argCnt;
InlArgInfo inlArgInfo[MAX_INL_ARGS + 1];
InlArgInfo* inlInstParamArgInfo;
unsigned argCnt; // Number of IL args
InlArgInfo inlArgInfo[MAX_INL_ARGS + 1]; // IL arg info
InlArgInfo* inlInstParamArgInfo; // Arg info for inst param
int lclTmpNum[MAX_INL_LCLS]; // map local# -> temp# (-1 if unused)
InlLclVarInfo lclVarInfo[MAX_INL_LCLS + MAX_INL_ARGS + 1]; // type information from local sig

Expand Down
58 changes: 9 additions & 49 deletions src/coreclr/jit/morph.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -589,55 +589,15 @@ const char* getWellKnownArgName(WellKnownArg arg)
{
case WellKnownArg::None:
return "None";
case WellKnownArg::ThisPointer:
return "ThisPointer";
case WellKnownArg::VarArgsCookie:
return "VarArgsCookie";
case WellKnownArg::InstParam:
return "InstParam";
case WellKnownArg::AsyncContinuation:
return "AsyncContinuation";
case WellKnownArg::RetBuffer:
return "RetBuffer";
case WellKnownArg::PInvokeFrame:
return "PInvokeFrame";
case WellKnownArg::ShiftLow:
return "ShiftLow";
case WellKnownArg::ShiftHigh:
return "ShiftHigh";
case WellKnownArg::VirtualStubCell:
return "VirtualStubCell";
case WellKnownArg::PInvokeCookie:
return "PInvokeCookie";
case WellKnownArg::PInvokeTarget:
return "PInvokeTarget";
case WellKnownArg::R2RIndirectionCell:
return "R2RIndirectionCell";
case WellKnownArg::ValidateIndirectCallTarget:
return "ValidateIndirectCallTarget";
case WellKnownArg::DispatchIndirectCallTarget:
return "DispatchIndirectCallTarget";
case WellKnownArg::SwiftError:
return "SwiftError";
case WellKnownArg::SwiftSelf:
return "SwiftSelf";
case WellKnownArg::X86TailCallSpecialArg:
return "X86TailCallSpecialArg";
case WellKnownArg::StackArrayLocal:
return "StackArrayLocal";
case WellKnownArg::RuntimeMethodHandle:
return "RuntimeMethodHandle";
case WellKnownArg::AsyncExecutionContext:
return "AsyncExecutionContext";
case WellKnownArg::AsyncSynchronizationContext:
return "AsyncSynchronizationContext";
case WellKnownArg::WasmShadowStackPointer:
return "WasmShadowStackPointer";
case WellKnownArg::WasmPortableEntryPoint:
return "WasmPortableEntryPoint";
}

return "N/A";

#define WELL_KNOWN_ARG(name, shortName, isILArg, addedByMorph) \
case WellKnownArg::name: \
return #name;
#include "wellknownargs.h"

default:
return "N/A";
}
}

//------------------------------------------------------------------------
Expand Down
46 changes: 46 additions & 0 deletions src/coreclr/jit/wellknownargs.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

// clang-format off

#ifndef WELL_KNOWN_ARG
#error Define WELL_KNOWN_ARG before including this file.
#endif

// List of well-known arguments that the JIT recognizes. The columns are:
//
// - name: The name of the WellKnownArg enum member.
// - shortName: A short human-readable descriptor used when dumping args
// - isILArg: True if this is an argument that can be treated as
// user-defined (i.e. it appears in the IL/signature).
// - addedByMorph: True if this is an argument that is added late by morph (in
// `AddFinalArgsAndDetermineABIInfo`).

// name, shortName, isILArg, addedByMorph
WELL_KNOWN_ARG(ThisPointer, "this", true, false)
WELL_KNOWN_ARG(VarArgsCookie, "va cookie", false, false)
WELL_KNOWN_ARG(InstParam, "gctx", false, false)
WELL_KNOWN_ARG(AsyncContinuation, "async", false, false)
WELL_KNOWN_ARG(RetBuffer, "retbuf", false, false)
WELL_KNOWN_ARG(PInvokeFrame, "pinv frame", false, false)
WELL_KNOWN_ARG(ShiftLow, "shift low", false, false)
WELL_KNOWN_ARG(ShiftHigh, "shift high", false, false)
WELL_KNOWN_ARG(VirtualStubCell, "vsd cell", false, true)
WELL_KNOWN_ARG(PInvokeCookie, "pinv cookie", false, true)
WELL_KNOWN_ARG(PInvokeTarget, "pinv tgt", false, true)
WELL_KNOWN_ARG(R2RIndirectionCell, "r2r cell", false, true)
WELL_KNOWN_ARG(ValidateIndirectCallTarget, "cfg tgt", false, false)
WELL_KNOWN_ARG(DispatchIndirectCallTarget, "cfg tgt", false, false)
WELL_KNOWN_ARG(SwiftError, "swift error", true, false)
WELL_KNOWN_ARG(SwiftSelf, "swift self", true, false)
Comment thread
jakobbotsch marked this conversation as resolved.
WELL_KNOWN_ARG(X86TailCallSpecialArg, "tail call", false, false)
WELL_KNOWN_ARG(StackArrayLocal, "&lcl arr", false, false)
WELL_KNOWN_ARG(RuntimeMethodHandle, "meth hnd", false, false)
WELL_KNOWN_ARG(AsyncExecutionContext, "exec ctx", false, false)
WELL_KNOWN_ARG(AsyncSynchronizationContext, "sync ctx", false, false)
WELL_KNOWN_ARG(WasmShadowStackPointer, "wasm sp", false, false)
WELL_KNOWN_ARG(WasmPortableEntryPoint, "wasm pep", false, false)

#undef WELL_KNOWN_ARG

// clang-format on
Loading