Thanks to visit codestin.com
Credit goes to github.com

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
2 changes: 1 addition & 1 deletion src/coreclr/jit/compiler.h
Original file line number Diff line number Diff line change
Expand Up @@ -5210,7 +5210,7 @@ class Compiler
InlineCandidateInfo** ppInlineCandidateInfo,
InlineResult* inlineResult);

void impInlineRecordArgInfo(InlineInfo* pInlineInfo, CallArg* arg, unsigned argNum, InlineResult* inlineResult);
void impInlineRecordArgInfo(InlineInfo* pInlineInfo, CallArg* arg, InlArgInfo* argInfo, InlineResult* inlineResult);

void impInlineInitVars(InlineInfo* pInlineInfo);

Expand Down
28 changes: 20 additions & 8 deletions src/coreclr/jit/fginline.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2045,20 +2045,32 @@ Statement* Compiler::fgInlinePrependStatements(InlineInfo* inlineInfo)
}
}

// Append the InstParam
if (inlineInfo->inlInstParamArgInfo != nullptr)
#ifdef DEBUG
if (call->gtArgs.CountUserArgs() > 0)
{
fgInsertInlineeArgument(*inlineInfo->inlInstParamArgInfo, block, &afterStmt, &newStmt, callDI);
JITDUMP("\nArguments setup:\n");
}
#endif

// Treat arguments that had to be assigned to temps
if (inlineInfo->argCnt)
unsigned ilArgNum = 0;
for (CallArg& arg : call->gtArgs.Args())
{
JITDUMP("\nArguments setup:\n");
for (unsigned argNum = 0; argNum < inlineInfo->argCnt; argNum++)
InlArgInfo* argInfo = nullptr;
switch (arg.GetWellKnownArg())
{
fgInsertInlineeArgument(inlArgInfo[argNum], block, &afterStmt, &newStmt, callDI);
case WellKnownArg::RetBuffer:
continue;
case WellKnownArg::InstParam:
argInfo = inlineInfo->inlInstParamArgInfo;
break;
default:
assert(ilArgNum < inlineInfo->argCnt);
argInfo = &inlineInfo->inlArgInfo[ilArgNum++];
break;
}

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

// Add the CCTOR check if asked for.
Expand Down
31 changes: 31 additions & 0 deletions src/coreclr/jit/gentree.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1581,6 +1581,37 @@ unsigned CallArgs::GetIndex(CallArg* arg)
return (unsigned)-1;
}

//---------------------------------------------------------------
// GetIndex: Get the user arg index for the specified argument (IL index).
//
// Parameters:
// arg - The argument to obtain the index of.
//
// Returns:
// The user index.
//
unsigned CallArgs::GetUserIndex(CallArg* arg)
{
unsigned i = 0;
for (CallArg& a : Args())
{
if (!a.IsUserArg())
{
continue;
}

if (&a == arg)
{
return i;
}

i++;
}

assert(!"Could not find argument in arg list");
return (unsigned)-1;
}

//---------------------------------------------------------------
// Reverse: Reverse the specified subrange of arguments.
//
Expand Down
1 change: 1 addition & 0 deletions src/coreclr/jit/gentree.h
Original file line number Diff line number Diff line change
Expand Up @@ -4920,6 +4920,7 @@ class CallArgs
CallArg* GetArgByIndex(unsigned index);
CallArg* GetUserArgByIndex(unsigned index);
unsigned GetIndex(CallArg* arg);
unsigned GetUserIndex(CallArg* arg);

bool IsEmpty() const
{
Expand Down
95 changes: 35 additions & 60 deletions src/coreclr/jit/importer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12928,7 +12928,7 @@ void Compiler::impCanInlineIL(CORINFO_METHOD_HANDLE fncHandle,
// Arguments:
// pInlineInfo - inline info for the inline candidate
// arg - the caller argument
// argNum - logical index of this argument
// argInfo - Structure to record information into
// inlineResult - result of ongoing inline evaluation
//
// Notes:
Expand All @@ -12940,12 +12940,10 @@ void Compiler::impCanInlineIL(CORINFO_METHOD_HANDLE fncHandle,

void Compiler::impInlineRecordArgInfo(InlineInfo* pInlineInfo,
CallArg* arg,
unsigned argNum,
InlArgInfo* argInfo,
InlineResult* inlineResult)
{
InlArgInfo* inlCurArgInfo = &pInlineInfo->inlArgInfo[argNum];

inlCurArgInfo->arg = arg;
argInfo->arg = arg;
GenTree* curArgVal = arg->GetNode();

assert(!curArgVal->OperIs(GT_RET_EXPR));
Expand All @@ -12958,7 +12956,7 @@ void Compiler::impInlineRecordArgInfo(InlineInfo* pInlineInfo,

if (varTypeIsStruct(varDsc))
{
inlCurArgInfo->argIsByRefToStructLocal = true;
argInfo->argIsByRefToStructLocal = true;
#ifdef FEATURE_SIMD
if (varTypeIsSIMD(varDsc))
{
Expand All @@ -12973,22 +12971,21 @@ void Compiler::impInlineRecordArgInfo(InlineInfo* pInlineInfo,

if (curArgVal->gtFlags & GTF_ALL_EFFECT)
{
inlCurArgInfo->argHasGlobRef = (curArgVal->gtFlags & GTF_GLOB_REF) != 0;
inlCurArgInfo->argHasSideEff = (curArgVal->gtFlags & (GTF_ALL_EFFECT & ~GTF_GLOB_REF)) != 0;
argInfo->argHasGlobRef = (curArgVal->gtFlags & GTF_GLOB_REF) != 0;
argInfo->argHasSideEff = (curArgVal->gtFlags & (GTF_ALL_EFFECT & ~GTF_GLOB_REF)) != 0;
}

if (curArgVal->gtOper == GT_LCL_VAR)
{
inlCurArgInfo->argIsLclVar = true;

/* Remember the "original" argument number */
INDEBUG(curArgVal->AsLclVar()->gtLclILoffs = argNum;)
argInfo->argIsLclVar = true;
}

argInfo->argIsThis = arg->GetWellKnownArg() == WellKnownArg::ThisPointer;

if (impIsInvariant(curArgVal))
{
inlCurArgInfo->argIsInvariant = true;
if (inlCurArgInfo->argIsThis && (curArgVal->gtOper == GT_CNS_INT) && (curArgVal->AsIntCon()->gtIconVal == 0))
argInfo->argIsInvariant = true;
if (argInfo->argIsThis && (curArgVal->gtOper == GT_CNS_INT) && (curArgVal->AsIntCon()->gtIconVal == 0))
{
// Abort inlining at this call site
inlineResult->NoteFatal(InlineObservation::CALLSITE_ARG_HAS_NULL_THIS);
Expand All @@ -12997,13 +12994,13 @@ void Compiler::impInlineRecordArgInfo(InlineInfo* pInlineInfo,
}
else if (gtIsTypeof(curArgVal))
{
inlCurArgInfo->argIsInvariant = true;
inlCurArgInfo->argHasSideEff = false;
argInfo->argIsInvariant = true;
argInfo->argHasSideEff = false;
}

bool isExact = false;
bool isNonNull = false;
inlCurArgInfo->argIsExact = (gtGetClassHandle(curArgVal, &isExact, &isNonNull) != NO_CLASS_HANDLE) && isExact;
bool isExact = false;
bool isNonNull = false;
argInfo->argIsExact = (gtGetClassHandle(curArgVal, &isExact, &isNonNull) != NO_CLASS_HANDLE) && isExact;

// If the arg is a local that is address-taken, we can't safely
// directly substitute it into the inlinee.
Expand All @@ -13014,51 +13011,51 @@ void Compiler::impInlineRecordArgInfo(InlineInfo* pInlineInfo,
// which is safe in this case.
//
// Instead mark the arg as having a caller local ref.
if (!inlCurArgInfo->argIsInvariant && gtHasLocalsWithAddrOp(curArgVal))
if (!argInfo->argIsInvariant && gtHasLocalsWithAddrOp(curArgVal))
{
inlCurArgInfo->argHasCallerLocalRef = true;
argInfo->argHasCallerLocalRef = true;
}

#ifdef DEBUG
if (verbose)
{
if (inlCurArgInfo->argIsThis)
if (arg->GetWellKnownArg() != WellKnownArg::None)
{
printf("thisArg:");
printf("%s:", getWellKnownArgName(arg->GetWellKnownArg()));
}
else
{
printf("\nArgument #%u:", argNum);
printf("IL argument #%u:", pInlineInfo->iciCall->gtArgs.GetUserIndex(arg));
}
if (inlCurArgInfo->argIsLclVar)
if (argInfo->argIsLclVar)
{
printf(" is a local var");
}
if (inlCurArgInfo->argIsInvariant)
if (argInfo->argIsInvariant)
{
printf(" is a constant or invariant");
}
if (inlCurArgInfo->argHasGlobRef)
if (argInfo->argHasGlobRef)
{
printf(" has global refs");
}
if (inlCurArgInfo->argHasCallerLocalRef)
if (argInfo->argHasCallerLocalRef)
{
printf(" has caller local ref");
}
if (inlCurArgInfo->argHasSideEff)
if (argInfo->argHasSideEff)
{
printf(" has side effects");
}
if (inlCurArgInfo->argHasLdargaOp)
if (argInfo->argHasLdargaOp)
{
printf(" has ldarga effect");
}
if (inlCurArgInfo->argHasStargOp)
if (argInfo->argHasStargOp)
{
printf(" has starg effect");
}
if (inlCurArgInfo->argIsByRefToStructLocal)
if (argInfo->argIsByRefToStructLocal)
{
printf(" is byref to a struct local");
}
Expand Down Expand Up @@ -13114,51 +13111,29 @@ void Compiler::impInlineInitVars(InlineInfo* pInlineInfo)
unsigned ilArgCnt = 0;
for (CallArg& arg : call->gtArgs.Args())
{
InlArgInfo* argInfo;
switch (arg.GetWellKnownArg())
{
case WellKnownArg::ThisPointer:
inlArgInfo[ilArgCnt].argIsThis = true;
break;
case WellKnownArg::RetBuffer:
// This does not appear in the table of inline arg info; do not include them
continue;
case WellKnownArg::InstParam:
{
InlArgInfo* ctxInfo = new (this, CMK_Inlining) InlArgInfo{};
ctxInfo->arg = &arg;
ctxInfo->argTmpNum = BAD_VAR_NUM;
ctxInfo->argIsLclVar = arg.GetNode()->OperIs(GT_LCL_VAR);
if (arg.GetNode()->IsCnsIntOrI())
{
ctxInfo->argIsInvariant = true;
}
else
{
// Conservative approach
ctxInfo->argHasSideEff = true;
ctxInfo->argHasGlobRef = true;
}
pInlineInfo->inlInstParamArgInfo = ctxInfo;
continue;
}
pInlineInfo->inlInstParamArgInfo = argInfo = new (this, CMK_Inlining) InlArgInfo{};
break;
default:
argInfo = &inlArgInfo[ilArgCnt++];
break;
}

arg.SetEarlyNode(gtFoldExpr(arg.GetEarlyNode()));
impInlineRecordArgInfo(pInlineInfo, &arg, ilArgCnt, inlineResult);
impInlineRecordArgInfo(pInlineInfo, &arg, argInfo, inlineResult);

if (inlineResult->IsFailure())
{
return;
}

ilArgCnt++;
}

/* Make sure we got the arg number right */
assert(ilArgCnt == methInfo->args.totalILArgs());

#ifdef FEATURE_SIMD
bool foundSIMDType = pInlineInfo->hasSIMDTypeArgLocalOrReturn;
#endif // FEATURE_SIMD
Expand Down Expand Up @@ -13538,7 +13513,7 @@ unsigned Compiler::impInlineFetchLocal(unsigned lclNum DEBUGARG(const char* reas
//
// This method will side effect inlArgInfo. It should only be called
// for actual uses of the argument in the inlinee.

//
GenTree* Compiler::impInlineFetchArg(InlArgInfo& argInfo, const InlLclVarInfo& lclInfo)
{
// Cache the relevant arg and lcl info for this argument.
Expand Down
Loading