Skip to content

Commit

Permalink
Use REG_INDIRECT_CALL_TARGET_REG for indirect calls on arm64 (#101927)
Browse files Browse the repository at this point in the history
* Use REG_INDIRECT_CALL_TARGET_REG for indirect calls on arm64

* Added a comment about NativeAOT dependency at the place wehre we exclude LR from availableIntRegs
  • Loading branch information
VSadov authored May 7, 2024
1 parent 7dc3669 commit e1c6717
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 6 deletions.
6 changes: 3 additions & 3 deletions src/coreclr/jit/codegenarmarch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3682,11 +3682,11 @@ void CodeGen::genCallInstruction(GenTreeCall* call)
{
#ifdef TARGET_ARM
// For arm32 we've allocated an internal register to load the target into.
// Loading into lr takes 4 bytes (instead of potentially 2 with another register).
// Loading into IP takes 4 bytes (instead of potentially 2 with another register).
targetAddrReg = internalRegisters.GetSingle(call);
#else
// For arm64 we just use lr and skip the internal register.
targetAddrReg = REG_LR;
// For arm64 we just use IP0 and skip the internal register.
targetAddrReg = REG_INDIRECT_CALL_TARGET_REG;
#endif

GetEmitter()->emitIns_R_R(ins_Load(TYP_I_IMPL), emitActualTypeSize(TYP_I_IMPL), targetAddrReg,
Expand Down
3 changes: 3 additions & 0 deletions src/coreclr/jit/lsra.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -788,6 +788,9 @@ LinearScan::LinearScan(Compiler* theCompiler)
regSelector = new (theCompiler, CMK_LSRA) RegisterSelection(this);

#ifdef TARGET_ARM64
// Note: one known reason why we exclude LR is because NativeAOT has dependency on not
// using LR as a GPR. See: https://github.com/dotnet/runtime/issues/101932
// Once that is addressed, we may consider allowing LR in availableIntRegs.
availableIntRegs = (RBM_ALLINT & ~(RBM_PR | RBM_FP | RBM_LR) & ~compiler->codeGen->regSet.rsMaskResvd);
#elif defined(TARGET_LOONGARCH64) || defined(TARGET_RISCV64)
availableIntRegs = (RBM_ALLINT & ~(RBM_FP | RBM_RA) & ~compiler->codeGen->regSet.rsMaskResvd);
Expand Down
6 changes: 3 additions & 3 deletions src/coreclr/jit/lsraarmarch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -191,9 +191,9 @@ int LinearScan::BuildCall(GenTreeCall* call)
}
else
{
// For arm64 we can use lr for non-tailcalls so we skip the
// internal register as a TP optimization. We could do the same for
// arm32, but loading into lr cannot be encoded in 2 bytes, so
// For arm64 we can use REG_INDIRECT_CALL_TARGET_REG (IP0) for non-tailcalls
// so we skip the internal register as a TP optimization. We could do the same for
// arm32, but loading into IP cannot be encoded in 2 bytes, so
// another register is usually better.
#ifdef TARGET_ARM
buildInternalIntRegisterDefForNode(call);
Expand Down

0 comments on commit e1c6717

Please sign in to comment.