Skip to content

Commit 24864a9

Browse files
authored
Turn off reloc generation for handles (dotnet#60721)
Due to dotnet#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 dotnet#60626 Fix dotnet#60627 Fix dotnet#60629
1 parent ce4dd5f commit 24864a9

File tree

3 files changed

+13
-5
lines changed

3 files changed

+13
-5
lines changed

src/coreclr/jit/codegenarm.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,9 @@ void CodeGen::genSetRegToConst(regNumber targetReg, var_types targetType, GenTre
238238

239239
emitAttr attr = emitActualTypeSize(targetType);
240240

241-
if (con->IsIconHandle())
241+
// TODO-CQ: Currently we cannot do this for all handles because of
242+
// https://github.com/dotnet/runtime/issues/60712
243+
if (con->ImmedValNeedsReloc(compiler))
242244
{
243245
attr = EA_SET_FLG(attr, EA_CNS_RELOC_FLG);
244246
}

src/coreclr/jit/codegenarm64.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1692,13 +1692,13 @@ void CodeGen::genSetRegToConst(regNumber targetReg, var_types targetType, GenTre
16921692
{
16931693
case GT_CNS_INT:
16941694
{
1695-
// relocatable values tend to come down as a CNS_INT of native int type
1696-
// so the line between these two opcodes is kind of blurry
16971695
GenTreeIntConCommon* con = tree->AsIntConCommon();
16981696
ssize_t cnsVal = con->IconValue();
16991697

17001698
emitAttr attr = emitActualTypeSize(targetType);
1701-
if (con->IsIconHandle())
1699+
// TODO-CQ: Currently we cannot do this for all handles because of
1700+
// https://github.com/dotnet/runtime/issues/60712
1701+
if (con->ImmedValNeedsReloc(compiler))
17021702
{
17031703
attr = EA_SET_FLG(attr, EA_CNS_RELOC_FLG);
17041704
}

src/coreclr/jit/codegenxarch.cpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -466,7 +466,13 @@ void CodeGen::genSetRegToConst(regNumber targetReg, var_types targetType, GenTre
466466
ssize_t cnsVal = con->IconValue();
467467

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

0 commit comments

Comments
 (0)