Skip to content

Commit

Permalink
Turn off reloc generation for handles (#60721)
Browse files Browse the repository at this point in the history
Due to #60712 we cannot unconditionally generate lea for handles, since
the runtime does not expect us to generate ask for reloc hints for
arbitrary constants. In addition, for many Intel CPUs it looks like
rip-relative lea has greater latency than mov with an 8-byte immediate.

Instead of reverting the change I'm just turning it off here, since the
change also unified a couple of functions to simplify the handling.

Fix #60626
Fix #60627
Fix #60629
  • Loading branch information
jakobbotsch committed Oct 22, 2021
1 parent ce4dd5f commit 24864a9
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 5 deletions.
4 changes: 3 additions & 1 deletion src/coreclr/jit/codegenarm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,9 @@ void CodeGen::genSetRegToConst(regNumber targetReg, var_types targetType, GenTre

emitAttr attr = emitActualTypeSize(targetType);

if (con->IsIconHandle())
// TODO-CQ: Currently we cannot do this for all handles because of
// https://github.com/dotnet/runtime/issues/60712
if (con->ImmedValNeedsReloc(compiler))
{
attr = EA_SET_FLG(attr, EA_CNS_RELOC_FLG);
}
Expand Down
6 changes: 3 additions & 3 deletions src/coreclr/jit/codegenarm64.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1692,13 +1692,13 @@ void CodeGen::genSetRegToConst(regNumber targetReg, var_types targetType, GenTre
{
case GT_CNS_INT:
{
// relocatable values tend to come down as a CNS_INT of native int type
// so the line between these two opcodes is kind of blurry
GenTreeIntConCommon* con = tree->AsIntConCommon();
ssize_t cnsVal = con->IconValue();

emitAttr attr = emitActualTypeSize(targetType);
if (con->IsIconHandle())
// TODO-CQ: Currently we cannot do this for all handles because of
// https://github.com/dotnet/runtime/issues/60712
if (con->ImmedValNeedsReloc(compiler))
{
attr = EA_SET_FLG(attr, EA_CNS_RELOC_FLG);
}
Expand Down
8 changes: 7 additions & 1 deletion src/coreclr/jit/codegenxarch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -466,7 +466,13 @@ void CodeGen::genSetRegToConst(regNumber targetReg, var_types targetType, GenTre
ssize_t cnsVal = con->IconValue();

emitAttr attr = emitActualTypeSize(targetType);
if (con->IsIconHandle())
// Currently this cannot be done for all handles due to
// https://github.com/dotnet/runtime/issues/60712. However, it is
// also unclear whether we unconditionally want to use rip-relative
// lea instructions when not necessary. While a mov is larger, on
// many Intel CPUs rip-relative lea instructions have higher
// latency.
if (con->ImmedValNeedsReloc(compiler))
{
attr = EA_SET_FLG(attr, EA_CNS_RELOC_FLG);
}
Expand Down

0 comments on commit 24864a9

Please sign in to comment.