@@ -217,7 +217,6 @@ void emitter::emitInsSanityCheck(instrDesc* id)
217
217
case IF_BR_1B: // BR_1B ................ ......nnnnn..... Rn
218
218
if (emitComp->IsTargetAbi(CORINFO_NATIVEAOT_ABI) && id->idIsTlsGD())
219
219
{
220
- assert(isGeneralRegister(id->idReg1()));
221
220
assert(id->idAddr()->iiaAddr != nullptr);
222
221
}
223
222
else
@@ -9184,11 +9183,14 @@ void emitter::emitIns_Call(EmitCallType callType,
9184
9183
if (emitComp->IsTargetAbi(CORINFO_NATIVEAOT_ABI) && EA_IS_CNS_TLSGD_RELOC(retSize))
9185
9184
{
9186
9185
// 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);
9190
9193
id->idSetTlsGD();
9191
- id->idReg1(ireg);
9192
9194
id->idAddr()->iiaAddr = (BYTE*)methHnd;
9193
9195
}
9194
9196
else
@@ -10990,12 +10992,13 @@ size_t emitter::emitOutputInstr(insGroup* ig, instrDesc* id, BYTE** dp)
10990
10992
{
10991
10993
emitRecordRelocation(odst, (CORINFO_METHOD_HANDLE)id->idAddr()->iiaAddr,
10992
10994
IMAGE_REL_AARCH64_TLSDESC_CALL);
10993
- code |= insEncodeReg_Rn(id->idReg1() ); // nnnnn
10995
+ code |= insEncodeReg_Rn(REG_R2 ); // nnnnn
10994
10996
}
10995
10997
else
10996
10998
{
10997
10999
code |= insEncodeReg_Rn(id->idReg3()); // nnnnn
10998
11000
}
11001
+
10999
11002
dst += emitOutputCall(ig, dst, id, code);
11000
11003
sz = id->idIsLargeCall() ? sizeof(instrDescCGCA) : sizeof(instrDesc);
11001
11004
break;
@@ -13315,7 +13318,15 @@ void emitter::emitDispInsHelp(
13315
13318
case IF_BR_1B: // BR_1B ................ ......nnnnn..... Rn
13316
13319
// The size of a branch target is always EA_PTRSIZE
13317
13320
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
+ }
13319
13330
break;
13320
13331
13321
13332
case IF_LS_1A: // LS_1A XX...V..iiiiiiii iiiiiiiiiiittttt Rt PC imm(1MB)
0 commit comments