Skip to content

Commit 296586b

Browse files
github-actions[bot]kunalspathakjeffschwMSFT
authored
[release/9.0-staging] NativeAOT/Arm64: Do not overwrite gcinfo tracking registers for TLS (#112549)
* Do not overwrite gcrefs masks present in reg1/reg2 fields * Temporary use debian 10 * Revert "Temporary use debian 10" This reverts commit 269225f. --------- Co-authored-by: Kunal Pathak <[email protected]> Co-authored-by: Jeff Schwartz <[email protected]>
1 parent a5d80ca commit 296586b

File tree

1 file changed

+18
-7
lines changed

1 file changed

+18
-7
lines changed

src/coreclr/jit/emitarm64.cpp

+18-7
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,6 @@ void emitter::emitInsSanityCheck(instrDesc* id)
217217
case IF_BR_1B: // BR_1B ................ ......nnnnn..... Rn
218218
if (emitComp->IsTargetAbi(CORINFO_NATIVEAOT_ABI) && id->idIsTlsGD())
219219
{
220-
assert(isGeneralRegister(id->idReg1()));
221220
assert(id->idAddr()->iiaAddr != nullptr);
222221
}
223222
else
@@ -9184,11 +9183,14 @@ void emitter::emitIns_Call(EmitCallType callType,
91849183
if (emitComp->IsTargetAbi(CORINFO_NATIVEAOT_ABI) && EA_IS_CNS_TLSGD_RELOC(retSize))
91859184
{
91869185
// For NativeAOT linux/arm64, we need to also record the relocation of methHnd.
9187-
// Since we do not have space to embed it in instrDesc, we store the register in
9188-
// reg1 and instead use the `iiaAdd` to store the method handle. Likewise, during
9189-
// emitOutputInstr, we retrieve the register from reg1 for this specific case.
9186+
// Since we do not have space to embed it in instrDesc, we use the `iiaAddr` to
9187+
// store the method handle.
9188+
// The target handle need to be always in R2 and hence the assert check.
9189+
// We cannot use reg1 and reg2 fields of instrDesc because they contain the gc
9190+
// registers (emitEncodeCallGCregs()) that are live across the call.
9191+
9192+
assert(ireg == REG_R2);
91909193
id->idSetTlsGD();
9191-
id->idReg1(ireg);
91929194
id->idAddr()->iiaAddr = (BYTE*)methHnd;
91939195
}
91949196
else
@@ -10990,12 +10992,13 @@ size_t emitter::emitOutputInstr(insGroup* ig, instrDesc* id, BYTE** dp)
1099010992
{
1099110993
emitRecordRelocation(odst, (CORINFO_METHOD_HANDLE)id->idAddr()->iiaAddr,
1099210994
IMAGE_REL_AARCH64_TLSDESC_CALL);
10993-
code |= insEncodeReg_Rn(id->idReg1()); // nnnnn
10995+
code |= insEncodeReg_Rn(REG_R2); // nnnnn
1099410996
}
1099510997
else
1099610998
{
1099710999
code |= insEncodeReg_Rn(id->idReg3()); // nnnnn
1099811000
}
11001+
1099911002
dst += emitOutputCall(ig, dst, id, code);
1100011003
sz = id->idIsLargeCall() ? sizeof(instrDescCGCA) : sizeof(instrDesc);
1100111004
break;
@@ -13315,7 +13318,15 @@ void emitter::emitDispInsHelp(
1331513318
case IF_BR_1B: // BR_1B ................ ......nnnnn..... Rn
1331613319
// The size of a branch target is always EA_PTRSIZE
1331713320
assert(insOptsNone(id->idInsOpt()));
13318-
emitDispReg(id->idReg3(), EA_PTRSIZE, false);
13321+
13322+
if (emitComp->IsTargetAbi(CORINFO_NATIVEAOT_ABI) && id->idIsTlsGD())
13323+
{
13324+
emitDispReg(REG_R2, EA_PTRSIZE, false);
13325+
}
13326+
else
13327+
{
13328+
emitDispReg(id->idReg3(), EA_PTRSIZE, false);
13329+
}
1331913330
break;
1332013331

1332113332
case IF_LS_1A: // LS_1A XX...V..iiiiiiii iiiiiiiiiiittttt Rt PC imm(1MB)

0 commit comments

Comments
 (0)