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
8 changes: 4 additions & 4 deletions src/coreclr/src/jit/codegenarmarch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2520,13 +2520,14 @@ void CodeGen::genCallInstruction(GenTreeCall* call)
INDEBUG_LDISASM_COMMA(sigInfo) nullptr, // addr
retSize MULTIREG_HAS_SECOND_GC_RET_ONLY_ARG(secondRetSize), ilOffset, target->GetRegNum());
}
#if defined(FEATURE_READYTORUN_COMPILER) && defined(TARGET_ARMARCH)
else if (call->IsR2RRelativeIndir())
else if (call->IsR2ROrVirtualStubRelativeIndir())
{
// Generate a direct call to a non-virtual user defined or helper method
assert(callType == CT_HELPER || callType == CT_USER_FUNC);
assert(call->gtEntryPoint.accessType == IAT_PVALUE);
assert(((call->IsR2RRelativeIndir()) && (call->gtEntryPoint.accessType == IAT_PVALUE)) ||
((call->IsVirtualStubRelativeIndir()) && (call->gtEntryPoint.accessType == IAT_VALUE)));
assert(call->gtControlExpr == nullptr);
assert(!call->IsTailCall());

regNumber tmpReg = call->GetSingleTempReg();
GetEmitter()->emitIns_R_R(ins_Load(TYP_I_IMPL), emitActualTypeSize(TYP_I_IMPL), tmpReg, REG_R2R_INDIRECT_PARAM);
Expand All @@ -2540,7 +2541,6 @@ void CodeGen::genCallInstruction(GenTreeCall* call)
INDEBUG_LDISASM_COMMA(sigInfo) nullptr, // addr
retSize MULTIREG_HAS_SECOND_GC_RET_ONLY_ARG(secondRetSize), ilOffset, tmpReg);
}
#endif // FEATURE_READYTORUN_COMPILER && TARGET_ARMARCH
else
{
// Generate a direct call to a non-virtual user defined or helper method
Expand Down
10 changes: 10 additions & 0 deletions src/coreclr/src/jit/gentree.h
Original file line number Diff line number Diff line change
Expand Up @@ -4202,6 +4202,16 @@ struct GenTreeCall final : public GenTree
return (gtFlags & GTF_CALL_INLINE_CANDIDATE) != 0;
}

bool IsR2ROrVirtualStubRelativeIndir()
{
#if defined(FEATURE_READYTORUN_COMPILER) && defined(TARGET_ARMARCH)
bool isVirtualStub = (gtFlags & GTF_CALL_VIRT_KIND_MASK) == GTF_CALL_VIRT_STUB;
return ((IsR2RRelativeIndir()) || (isVirtualStub && (IsVirtualStubRelativeIndir())));
#else
return false;
#endif // FEATURE_READYTORUN_COMPILER && TARGET_ARMARCH
}

bool HasNonStandardAddedArgs(Compiler* compiler) const;
int GetNonStandardAddedArgCount(Compiler* compiler) const;

Expand Down
19 changes: 18 additions & 1 deletion src/coreclr/src/jit/lower.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3489,6 +3489,9 @@ GenTree* Lowering::LowerDirectCall(GenTreeCall* call)
{
bool isR2RRelativeIndir = false;
#if defined(FEATURE_READYTORUN_COMPILER) && defined(TARGET_ARMARCH)
// Skip inserting the indirection node to load the address that is already
// computed in REG_R2R_INDIRECT_PARAM as a hidden parameter. Instead during the
// codegen, just load the call target from REG_R2R_INDIRECT_PARAM.
isR2RRelativeIndir = call->IsR2RRelativeIndir();
#endif // FEATURE_READYTORUN_COMPILER && TARGET_ARMARCH

Expand Down Expand Up @@ -4529,7 +4532,21 @@ GenTree* Lowering::LowerVirtualStubCall(GenTreeCall* call)
}
else
{
result = Ind(addr);

bool shouldOptimizeVirtualStubCall = false;
#if defined(FEATURE_READYTORUN_COMPILER) && defined(TARGET_ARMARCH)
// Skip inserting the indirection node to load the address that is already
// computed in REG_R2R_INDIRECT_PARAM as a hidden parameter. Instead during the
// codegen, just load the call target from REG_R2R_INDIRECT_PARAM.
// However, for tail calls, the call target is always computed in RBM_FASTTAILCALL_TARGET
// and so do not optimize virtual stub calls for such cases.
shouldOptimizeVirtualStubCall = !call->IsTailCall();
#endif // FEATURE_READYTORUN_COMPILER && TARGET_ARMARCH

if (!shouldOptimizeVirtualStubCall)
{
result = Ind(addr);
}
}
}

Expand Down
4 changes: 1 addition & 3 deletions src/coreclr/src/jit/lsraarmarch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -182,12 +182,10 @@ int LinearScan::BuildCall(GenTreeCall* call)
ctrlExprCandidates = RBM_FASTTAILCALL_TARGET;
}
}
#if defined(FEATURE_READYTORUN_COMPILER) && defined(TARGET_ARMARCH)
else if (call->IsR2RRelativeIndir())
else if (call->IsR2ROrVirtualStubRelativeIndir())
{
buildInternalIntRegisterDefForNode(call);
}
#endif // FEATURE_READYTORUN_COMPILER && TARGET_ARMARCH
#ifdef TARGET_ARM
else
{
Expand Down