Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions src/coreclr/jit/codegenarmarch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3353,6 +3353,14 @@ void CodeGen::genCallInstruction(GenTreeCall* call)
// mrs
emitter->emitIns_R(INS_mrs_tpid0, attr, REG_R1);

// We remove x0 here since the linker relaxation
// sequence will rewrite the instructions we are emitting here with
// instructions that may clobber these registers.
// (This is more important for the emitter, but we match it here
// for symmetry and to avoid confusion about the state of the
// registers.)
Comment thread
jakobbotsch marked this conversation as resolved.
gcInfo.gcMarkRegSetNpt(RBM_R0);

// adrp
// ldr
// add
Expand Down
9 changes: 9 additions & 0 deletions src/coreclr/jit/codegenxarch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -484,6 +484,15 @@ void CodeGen::genSetRegToConst(regNumber targetReg, var_types targetType, GenTre
else if (con->IsIconHandle(GTF_ICON_TLSGD_OFFSET))
{
attr = EA_SET_FLG(attr, EA_CNS_TLSGD_RELOC);

// This marks the start of a TLS access linker relaxation
// sequence for linux-x64. The linker may rewrite to
// instructions that trash rax at this point, so we update
// GC state eagerly here.
// (This is more important for the emitter, but we match it here
// for symmetry and to avoid confusion about the state of the
// registers.)
Comment thread
jakobbotsch marked this conversation as resolved.
gcInfo.gcMarkRegSetNpt(RBM_RAX);
Comment thread
jakobbotsch marked this conversation as resolved.
}
}

Expand Down
11 changes: 11 additions & 0 deletions src/coreclr/jit/emitarm64.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11725,6 +11725,17 @@ size_t emitter::emitOutputInstr(insGroup* ig, instrDesc* id, BYTE** dp)
emitRecordRelocation(odst, id->idAddr()->iiaAddr,
id->idIsTlsGD() ? CorInfoReloc::ARM64_LIN_TLSDESC_ADR_PAGE21
: CorInfoReloc::ARM64_PAGEBASE_REL21);

if (id->idIsTlsGD())
{
// This is the beginning of the TLS access linker
// relaxation sequence for linux arm64. The linker may
// replace these with other instructions that may trash x0.
// We thus need to eagerly update GC for x0, in case the
// linker's instructions trashes it earlier than we would
// emit a mutating instruction that trashes it.
Comment thread
jakobbotsch marked this conversation as resolved.
emitGCregDeadUpd(REG_R0, dst);
}
}
else
{
Expand Down
7 changes: 7 additions & 0 deletions src/coreclr/jit/emitxarch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18451,6 +18451,13 @@ size_t emitter::emitOutputInstr(insGroup* ig, instrDesc* id, BYTE** dp)
{
dst = emitOutputData16(dst);
sz = emitSizeOfInsDsc_NONE(id);

// This may mark the beginning of a TLS access linker
// relaxation sequence. The linker can replace these general
// sequences by other instructions that trash rax. We need to
Comment thread
jakobbotsch marked this conversation as resolved.
// eagerly invalidate GC info in rax before the linker's
// instructions would trash it.
emitGCregDeadUpd(REG_RAX, dst);
break;
}

Expand Down
Loading