[PATCH] D129425: [ELF][RISCV] Relax local-exec TLS model
Fangrui Song via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Sat Jul 9 10:39:31 PDT 2022
MaskRay created this revision.
MaskRay added reviewers: gkm, jrtc27, kito-cheng.
Herald added subscribers: sunshaoce, VincentWu, luke957, StephenFan, vkmr, frasercrmck, evandro, luismarques, apazos, sameer.abuasal, s.egerton, Jim, benna, psnobl, jocewei, the_o, brucehoult, MartinMosbeck, rogfer01, edward-jones, zzheng, shiva0217, niosHD, sabuasal, simoncook, johnrusso, rbar, asb, arichardson, emaste.
Herald added a project: All.
MaskRay published this revision for review.
Herald added subscribers: llvm-commits, pcwang-thead, eopXD.
Herald added a project: LLVM.
In -mrelax mode, GCC/Clang may generate a local-exec TLS code sequence like:
# R_RISCV_TPREL_HI20, R_RISCV_RELAX
lui rd, %tprel_hi(x)
# R_RISCV_TPREL_ADD, R_RISCV_RELAX
add rd, rd, tp, %tprel_add(x)
# (R_RISCV_TPREL_LO12_I || R_RISCV_TPREL_LO12_S), R_RISCV_RELAX
addi rd, rd, %tprel_lo(x) || sw rs, %tprel(x)(rd)
Note: st_value(x) for TLS should in the range [0,p_memsz(PT_TLS)).
When st_value(x) < 2048 (i.e. hi20(x) == 0), the linker can relax
the code sequence to:
addi rd, tp, st_value(x) || sw rs, st_value(x)(rd)
R_RISCV_TPREL_I/R_RISCV_TPREL_S are relocation types for linkers' internal use.
Their is no %tprel modifier to generate them.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D129425
Files:
lld/ELF/Arch/RISCV.cpp
lld/test/ELF/riscv-tls-le.s
llvm/include/llvm/BinaryFormat/ELFRelocs/RISCV.def
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D129425.443448.patch
Type: text/x-patch
Size: 7621 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220709/6ef137bc/attachment.bin>
More information about the llvm-commits
mailing list