[lld] [lld][LoongArch] Support TLSDESC GD/LD to IE/LE (PR #123715)
Zhaoxin Yang via llvm-commits
llvm-commits at lists.llvm.org
Sun Jun 22 18:30:53 PDT 2025
================
@@ -1453,7 +1459,17 @@ unsigned RelocationScanner::handleTlsRelocation(RelExpr expr, RelType type,
// label, so TLSDESC=>IE will be categorized as R_RELAX_TLS_GD_TO_LE. We fix
// the categorization in RISCV::relocateAllosec->
if (sym.isPreemptible) {
- sym.setFlags(NEEDS_TLSGD_TO_IE);
+ // In LoongArch, TLSDESC code sequences share relocations
+ // R_LARCH_TLS_DESC_PC_HI20 and R_LARCH_TLS_DESC_PC_LO12 in
+ // normal/medium/extreme code model. Since the extreme code model cannot
+ // be optimized to IE/LE, the flag NEEDS_TLSGD_TO_IE added previously
+ // needs to be cleared.
+ // In extreme code model, R_LARCH_TLS_DESC64_LO20 and
+ // R_LARCH_TLS_DESC64_HI12 will set NEEDS_TLSDESC flag.
+ if (ctx.arg.emachine == EM_LOONGARCH && sym.hasFlag(NEEDS_TLSDESC))
+ sym.clearFlags(NEEDS_TLSGD_TO_IE);
----------------
ylzsx wrote:
Thank you, I have already fixed this issue(https://github.com/llvm/llvm-project/pull/123715/commits/85165b332fca62aa7de47b14f9ef7715128f0389). From your perspective, is there anything else that needs to be fixed?
https://github.com/llvm/llvm-project/pull/123715
More information about the llvm-commits
mailing list