Skip to content
Closed
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/codegenarmarch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3459,7 +3459,7 @@ void CodeGen::genCallInstruction(GenTreeCall* call)
else
{
// Direct call to a non-virtual user function.
params.addr = call->gtDirectCallAddress;
params.addr = call->GetDirectCallAddress();
}

assert(params.addr != nullptr);
Expand Down
2 changes: 1 addition & 1 deletion src/coreclr/jit/codegenloongarch64.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5800,7 +5800,7 @@ void CodeGen::genCallInstruction(GenTreeCall* call)
else
{
// Direct call to a non-virtual user function.
params.addr = call->gtDirectCallAddress;
params.addr = call->GetDirectCallAddress();
}

assert(params.addr != nullptr);
Expand Down
2 changes: 1 addition & 1 deletion src/coreclr/jit/codegenriscv64.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5879,7 +5879,7 @@ void CodeGen::genCallInstruction(GenTreeCall* call)
else
{
// Direct call to a non-virtual user function.
params.addr = call->gtDirectCallAddress;
params.addr = call->GetDirectCallAddress();
}

assert(params.addr != nullptr);
Expand Down
2 changes: 1 addition & 1 deletion src/coreclr/jit/codegenxarch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6511,7 +6511,7 @@ void CodeGen::genCallInstruction(GenTreeCall* call X86_ARG(target_ssize_t stackA
else
{
// Direct call to a non-virtual user function.
addr = call->gtDirectCallAddress;
addr = call->GetDirectCallAddress();
}

assert(addr != nullptr);
Expand Down
14 changes: 7 additions & 7 deletions src/coreclr/jit/compiler.h
Original file line number Diff line number Diff line change
Expand Up @@ -11887,17 +11887,17 @@ class GenTreeVisitor
}
}

if (call->gtCallType == CT_INDIRECT)
if (call->HasCallCookie())
{
if (call->gtCallCookie != nullptr)
result = WalkTree(call->GetCallCookiePtr(), call);
if (result == fgWalkResult::WALK_ABORT)
{
result = WalkTree(&call->gtCallCookie, call);
if (result == fgWalkResult::WALK_ABORT)
{
return result;
}
return result;
}
}

if (call->gtCallType == CT_INDIRECT)
{
result = WalkTree(&call->gtCallAddr, call);
if (result == fgWalkResult::WALK_ABORT)
{
Expand Down
2 changes: 1 addition & 1 deletion src/coreclr/jit/compiler.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -4683,7 +4683,7 @@ void GenTree::VisitOperands(TVisitor visitor)

if (call->gtCallType == CT_INDIRECT)
{
if ((call->gtCallCookie != nullptr) && (visitor(call->gtCallCookie) == VisitResult::Abort))
if (call->HasCallCookie() && (visitor(call->GetCallCookie()) == VisitResult::Abort))
{
return;
}
Expand Down
20 changes: 10 additions & 10 deletions src/coreclr/jit/fgprofile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1902,7 +1902,7 @@ class HandleHistogramProbeVisitor final : public GenTreeVisitor<HandleHistogramP
GenTree* const node = *use;
if (node->IsCall() && (m_compiler->compClassifyGDVProbeType(node->AsCall()) != Compiler::GDVProbeType::None))
{
assert(node->AsCall()->gtHandleHistogramProfileCandidateInfo != nullptr);
assert(node->AsCall()->GetHandleHistogramProfileCandidateInfo() != nullptr);
m_functor(m_compiler, node->AsCall());
}

Expand Down Expand Up @@ -1997,7 +1997,7 @@ class BuildHandleHistogramProbeSchemaGen
schemaElem.InstrumentationKind = compiler->opts.compCollect64BitCounts
? ICorJitInfo::PgoInstrumentationKind::HandleHistogramLongCount
: ICorJitInfo::PgoInstrumentationKind::HandleHistogramIntCount;
schemaElem.ILOffset = (int32_t)call->gtHandleHistogramProfileCandidateInfo->ilOffset;
schemaElem.ILOffset = (int32_t)call->GetHandleHistogramProfileCandidateInfo()->ilOffset;
schemaElem.Offset = 0;

m_schema.push_back(schemaElem);
Expand Down Expand Up @@ -2033,7 +2033,7 @@ class BuildValueHistogramProbeSchemaGen
schemaElem.InstrumentationKind = compiler->opts.compCollect64BitCounts
? ICorJitInfo::PgoInstrumentationKind::ValueHistogramLongCount
: ICorJitInfo::PgoInstrumentationKind::ValueHistogramIntCount;
schemaElem.ILOffset = (int32_t)call->AsCall()->gtHandleHistogramProfileCandidateInfo->ilOffset;
schemaElem.ILOffset = (int32_t)call->AsCall()->GetHandleHistogramProfileCandidateInfo()->ilOffset;
m_schema.push_back(schemaElem);
m_schemaCount++;

Expand Down Expand Up @@ -2066,8 +2066,8 @@ class HandleHistogramProbeInserter
void operator()(Compiler* compiler, GenTreeCall* call)
{
JITDUMP("Found call [%06u] with probe index %d and ilOffset 0x%X\n", compiler->dspTreeID(call),
call->gtHandleHistogramProfileCandidateInfo->probeIndex,
call->gtHandleHistogramProfileCandidateInfo->ilOffset);
call->GetHandleHistogramProfileCandidateInfo()->probeIndex,
call->GetHandleHistogramProfileCandidateInfo()->ilOffset);

// We transform the call from (CALLVIRT obj, ... args ...) to
//
Expand All @@ -2085,11 +2085,11 @@ class HandleHistogramProbeInserter
void* methodHistogram = nullptr;

bool is32;
ReadHistogramAndAdvance(call->gtHandleHistogramProfileCandidateInfo->ilOffset, &typeHistogram, &methodHistogram,
&is32);
ReadHistogramAndAdvance(call->GetHandleHistogramProfileCandidateInfo()->ilOffset, &typeHistogram,
&methodHistogram, &is32);
bool secondIs32;
ReadHistogramAndAdvance(call->gtHandleHistogramProfileCandidateInfo->ilOffset, &typeHistogram, &methodHistogram,
&secondIs32);
ReadHistogramAndAdvance(call->GetHandleHistogramProfileCandidateInfo()->ilOffset, &typeHistogram,
&methodHistogram, &secondIs32);

assert(((typeHistogram != nullptr) || (methodHistogram != nullptr)) &&
"Expected at least one handle histogram when inserting probes");
Expand Down Expand Up @@ -2272,7 +2272,7 @@ class ValueHistogramProbeInserter

const ICorJitInfo::PgoInstrumentationSchema& countEntry = m_schema[*m_currentSchemaIndex];
if (countEntry.ILOffset !=
static_cast<int32_t>(node->AsCall()->gtHandleHistogramProfileCandidateInfo->ilOffset))
static_cast<int32_t>(node->AsCall()->GetHandleHistogramProfileCandidateInfo()->ilOffset))
{
return;
}
Expand Down
64 changes: 41 additions & 23 deletions src/coreclr/jit/gentree.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2036,15 +2036,19 @@ GenTree* Compiler::getArrayLengthFromAllocation(GenTree* tree DEBUGARG(BasicBloc
//
void GenTreeCall::SetSingleInlineCandidateInfo(InlineCandidateInfo* candidateInfo)
{
// assert((ud == UD::UD_INLINE_INFO) || (ud == UD::UD_INLINE_INFOS) || (ud == UD::UD_INVALID));

if (candidateInfo != nullptr)
{
gtFlags |= GTF_CALL_INLINE_CANDIDATE;
gtInlineInfoCount = 1;
ud = UD::UD_INLINE_INFO;
}
else
{
gtInlineInfoCount = 0;
gtFlags &= ~GTF_CALL_INLINE_CANDIDATE;
ud = UD::UD_INVALID;
}
gtInlineCandidateInfo = candidateInfo;
ClearGuardedDevirtualizationCandidate();
Expand All @@ -2061,9 +2065,11 @@ InlineCandidateInfo* GenTreeCall::GetGDVCandidateInfo(uint8_t index)
assert(index < gtInlineInfoCount);
if (gtInlineInfoCount > 1)
{
assert(ud == UD::UD_INLINE_INFOS);
// In this case we should access it through gtInlineCandidateInfoList
return gtInlineCandidateInfoList->at(index);
}
assert(ud == UD::UD_INLINE_INFO);
return gtInlineCandidateInfo;
}

Expand All @@ -2085,18 +2091,22 @@ void GenTreeCall::AddGDVCandidateInfo(Compiler* comp, InlineCandidateInfo* candi
{
// Most calls are monomorphic, so we don't need to allocate a vector
gtInlineCandidateInfo = candidateInfo;
ud = UD::UD_INLINE_INFO;
}
else if (gtInlineInfoCount == 1)
{
assert(ud == UD::UD_INLINE_INFO);
// Upgrade gtInlineCandidateInfo to gtInlineCandidateInfoList (vector)
CompAllocator allocator = comp->getAllocator(CMK_Inlining);
InlineCandidateInfo* firstCandidate = gtInlineCandidateInfo;
gtInlineCandidateInfoList = new (allocator) jitstd::vector<InlineCandidateInfo*>(allocator);
gtInlineCandidateInfoList->push_back(firstCandidate);
gtInlineCandidateInfoList->push_back(candidateInfo);
ud = UD::UD_INLINE_INFOS;
}
else
{
assert(ud == UD::UD_INLINE_INFOS);
gtInlineCandidateInfoList->push_back(candidateInfo);
}
gtCallMoreFlags |= GTF_CALL_M_GUARDED_DEVIRT;
Expand Down Expand Up @@ -2133,6 +2143,7 @@ void GenTreeCall::RemoveGDVCandidateInfo(Compiler* comp, uint8_t index)
if (gtInlineInfoCount == 1)
{
gtInlineCandidateInfo = gtInlineCandidateInfoList->at(0);
ud = UD::UD_INLINE_INFO;
}
}

Expand Down Expand Up @@ -2284,7 +2295,7 @@ int GenTreeCall::GetNonStandardAddedArgCount(Compiler* compiler) const
// R11 = Virtual stub param
return 1;
}
else if ((gtCallType == CT_INDIRECT) && (gtCallCookie != nullptr))
else if ((gtCallType == CT_INDIRECT) && HasCallCookie() && (GetCallCookie() != nullptr))
{
// R10 = PInvoke target param
// R11 = PInvoke cookie param
Expand Down Expand Up @@ -2469,6 +2480,20 @@ bool GenTreeCall::Equals(GenTreeCall* c1, GenTreeCall* c2)
return true;
}

void GenTreeCall::CopyUD(GenTreeCall* call, Compiler* comp)
{
call->ud = ud;

if (ud == UD::UD_COOKIE)
{
call->gtCallCookie = comp->gtClone(gtCallCookie);
}
else
{
call->gtCallCookie = gtCallCookie;
}
}

//--------------------------------------------------------------------------
// ResetFinalArgsAndABIInfo: Reset ABI information classified for arguments,
// removing late-added arguments.
Expand Down Expand Up @@ -5977,7 +6002,7 @@ unsigned Compiler::gtSetEvalOrder(GenTree* tree)
if (call->gtCallType == CT_INDIRECT)
{
// pinvoke-calli cookie is a constant, or constant indirection
assert(call->gtCallCookie == nullptr || call->gtCallCookie->OperIs(GT_CNS_INT, GT_IND));
assert(!call->HasCallCookie() || call->GetCallCookie()->OperIs(GT_CNS_INT, GT_IND));

GenTree* indirect = call->gtCallAddr;

Expand Down Expand Up @@ -6725,9 +6750,9 @@ bool GenTree::TryGetUse(GenTree* operand, GenTree*** pUse)
}
if (call->gtCallType == CT_INDIRECT)
{
if (operand == call->gtCallCookie)
if (call->HasCallCookie() && (operand == call->GetCallCookie()))
{
*pUse = &call->gtCallCookie;
*pUse = call->GetCallCookiePtr();
return true;
}
if (operand == call->gtCallAddr)
Expand Down Expand Up @@ -8298,15 +8323,7 @@ GenTreeCall* Compiler::gtNewCallNode(gtCallTypes callType,
node->gtCallMoreFlags = GTF_CALL_M_EMPTY;
INDEBUG(node->gtCallDebugFlags = GTF_CALL_MD_EMPTY);
node->gtInlineInfoCount = 0;

if (callType == CT_INDIRECT)
{
node->gtCallCookie = nullptr;
}
else
{
node->ClearInlineInfo();
}
node->ClearUD();
node->gtReturnType = type;

#ifdef FEATURE_READYTORUN
Expand Down Expand Up @@ -9896,17 +9913,17 @@ GenTreeCall* Compiler::gtCloneExprCallHelper(GenTreeCall* tree)
copy->gtControlExpr = gtCloneExpr(tree->gtControlExpr);
copy->gtStubCallStubAddr = tree->gtStubCallStubAddr;

/* Copy the union */
// Copy the union
tree->CopyUD(copy, this);

if (tree->gtCallType == CT_INDIRECT)
{
copy->gtCallCookie = tree->gtCallCookie ? gtCloneExpr(tree->gtCallCookie) : nullptr;
copy->gtCallAddr = tree->gtCallAddr ? gtCloneExpr(tree->gtCallAddr) : nullptr;
copy->gtCallAddr = tree->gtCallAddr ? gtCloneExpr(tree->gtCallAddr) : nullptr;
}
else
{
copy->gtCallMethHnd = tree->gtCallMethHnd;
copy->gtInlineCandidateInfo = tree->gtInlineCandidateInfo;
copy->gtInlineInfoCount = tree->gtInlineInfoCount;
copy->gtCallMethHnd = tree->gtCallMethHnd;
copy->gtInlineInfoCount = tree->gtInlineInfoCount;
}

copy->gtLateDevirtualizationInfo = tree->gtLateDevirtualizationInfo;
Expand Down Expand Up @@ -10641,9 +10658,9 @@ void GenTreeUseEdgeIterator::AdvanceCall()
assert(call->gtCallType == CT_INDIRECT);

m_advance = &GenTreeUseEdgeIterator::AdvanceCall<CALL_ADDRESS>;
if (call->gtCallCookie != nullptr)
if (call->HasCallCookie() && (call->GetCallCookie() != nullptr))
{
m_edge = &call->gtCallCookie;
m_edge = call->GetCallCookiePtr();
return;
}
FALLTHROUGH;
Expand Down Expand Up @@ -13506,7 +13523,7 @@ void Compiler::gtDispLIRNode(GenTree* node, const char* prefixMsg /* = nullptr *
{
displayOperand(operand, "control expr", operandArc, indentStack, prefixIndent);
}
else if (operand == call->gtCallCookie)
else if (call->HasCallCookie() && (operand == call->GetCallCookie()))
{
displayOperand(operand, "cookie", operandArc, indentStack, prefixIndent);
}
Expand Down Expand Up @@ -19426,7 +19443,8 @@ CORINFO_CLASS_HANDLE Compiler::gtGetHelperCallClassHandle(GenTreeCall* call, boo
case CORINFO_HELP_NEWARR_1_ALIGN8:
case CORINFO_HELP_READYTORUN_NEWARR_1:
{
CORINFO_CLASS_HANDLE arrayHnd = (CORINFO_CLASS_HANDLE)call->compileTimeHelperArgumentHandle;
assert(call->HasCompileTimeHelperArgumentHandle());
CORINFO_CLASS_HANDLE arrayHnd = (CORINFO_CLASS_HANDLE)call->GetCompileTimeHelperArgumentHandle();

if (arrayHnd != NO_CLASS_HANDLE)
{
Expand Down
Loading
Loading