Skip to content
This repository has been archived by the owner on Jan 23, 2023. It is now read-only.

Commit

Permalink
[ARM/Linux] Set R2R_INDIRECT_PARAM before R2R call (#12952)
Browse files Browse the repository at this point in the history
* Set R2R_INDIRECT_PARAM before R2R call

* Revise code formatting

* Preserve R2R_INDIRECT_PARAM across R2R call

* Fix format error

* Attempt to fix x86/Windows build error

* 2nd attempt to fix x86/Windows build error

* Revise RA to reserve R2R_INDIRECT_PARAM reg

* Fix format error
  • Loading branch information
parjong authored and BruceForstall committed Jul 31, 2017
1 parent 27c3a7d commit 341eeae
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 3 deletions.
26 changes: 23 additions & 3 deletions src/jit/codegenlegacy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19440,6 +19440,7 @@ regMaskTP CodeGen::genCodeForCall(GenTreeCall* call, bool valUsed)
break;

case IAT_PVALUE:
{
//------------------------------------------------------
// Non-virtual direct calls to addresses accessed by
// a single indirection.
Expand All @@ -19448,10 +19449,28 @@ regMaskTP CodeGen::genCodeForCall(GenTreeCall* call, bool valUsed)
// Load the address into a register, load indirect and call through a register
CLANG_FORMAT_COMMENT_ANCHOR;
#if CPU_LOAD_STORE_ARCH
indCallReg = regSet.rsGrabReg(RBM_ALLINT); // Grab an available register to use for the CALL
// indirection
regMaskTP indCallMask = RBM_ALLINT;

#ifdef FEATURE_READYTORUN_COMPILER
if (call->IsR2RRelativeIndir())
{
indCallMask &= ~RBM_R2R_INDIRECT_PARAM;
}
#endif // FEATURE_READYTORUN_COMPILER

// Grab an available register to use for the CALL indirection
indCallReg = regSet.rsGrabReg(indCallMask);

instGen_Set_Reg_To_Imm(EA_HANDLE_CNS_RELOC, indCallReg, (ssize_t)addr);

#ifdef FEATURE_READYTORUN_COMPILER
if (call->IsR2RRelativeIndir())
{
noway_assert(regSet.rsRegMaskCanGrab() & RBM_R2R_INDIRECT_PARAM);
getEmitter()->emitIns_R_R(INS_mov, EA_PTRSIZE, REG_R2R_INDIRECT_PARAM, indCallReg);
}
#endif // FEATURE_READYTORUN_COMPILER

getEmitter()->emitIns_R_R_I(INS_ldr, EA_PTRSIZE, indCallReg, indCallReg, 0);
regTracker.rsTrackRegTrash(indCallReg);

Expand All @@ -19471,7 +19490,8 @@ regMaskTP CodeGen::genCodeForCall(GenTreeCall* call, bool valUsed)
REG_NA, 0, 0, // xreg, xmul, disp
false, /* isJump */
emitter::emitNoGChelper(helperNum));
break;
}
break;

case IAT_PPVALUE:
{
Expand Down
11 changes: 11 additions & 0 deletions src/jit/regalloc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4835,6 +4835,17 @@ regMaskTP Compiler::rpPredictTreeRegUse(GenTreePtr tree,
}
assert(list == NULL);

#ifdef LEGACY_BACKEND
#if CPU_LOAD_STORE_ARCH
#ifdef FEATURE_READYTORUN_COMPILER
if (tree->gtCall.IsR2RRelativeIndir())
{
tree->gtUsedRegs |= RBM_R2R_INDIRECT_PARAM;
}
#endif // FEATURE_READYTORUN_COMPILER
#endif // CPU_LOAD_STORE_ARCH
#endif // LEGACY_BACKEND

regMaskTP callAddrMask;
callAddrMask = RBM_NONE;
#if CPU_LOAD_STORE_ARCH
Expand Down

0 comments on commit 341eeae

Please sign in to comment.