diff options
Diffstat (limited to 'src/jit/codegencommon.cpp')
-rw-r--r-- | src/jit/codegencommon.cpp | 24 |
1 files changed, 17 insertions, 7 deletions
diff --git a/src/jit/codegencommon.cpp b/src/jit/codegencommon.cpp index 34be5f7de7..8725619ceb 100644 --- a/src/jit/codegencommon.cpp +++ b/src/jit/codegencommon.cpp @@ -8905,20 +8905,30 @@ void CodeGen::genFnEpilog(BasicBlock* block) NO_WAY("Unsupported JMP indirection"); } - // If we have IAT_PVALUE, jump via register indirect, as sometimes the + // If we have IAT_PVALUE we might need to jump via register indirect, as sometimes the // indirection cell can't be reached by the jump. - emitter::EmitCallType callType; void* addr; regNumber indCallReg; if (addrInfo.accessType == IAT_PVALUE) { - callType = emitter::EC_INDIR_ARD; - indCallReg = REG_RAX; - addr = nullptr; - instGen_Set_Reg_To_Imm(EA_HANDLE_CNS_RELOC, indCallReg, (ssize_t)addrInfo.addr); - regSet.verifyRegUsed(indCallReg); + if (genCodeIndirAddrCanBeEncodedAsPCRelOffset((size_t)addrInfo.addr)) + { + // 32 bit displacement will work + callType = emitter::EC_FUNC_TOKEN_INDIR; + addr = addrInfo.addr; + indCallReg = REG_NA; + } + else + { + // 32 bit displacement won't work + callType = emitter::EC_INDIR_ARD; + indCallReg = REG_RAX; + addr = nullptr; + instGen_Set_Reg_To_Imm(EA_HANDLE_CNS_RELOC, indCallReg, (ssize_t)addrInfo.addr); + regSet.verifyRegUsed(indCallReg); + } } else { |