[all-commits] [llvm/llvm-project] f77b77: [ELF][RISCV] Relax local-exec TLS model

Fangrui Song via All-commits all-commits at lists.llvm.org
Fri Jul 15 10:08:20 PDT 2022


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: f77b77e8dbeb26764349a71b35f21b701adeee88
      https://github.com/llvm/llvm-project/commit/f77b77e8dbeb26764349a71b35f21b701adeee88
  Author: Fangrui Song <i at maskray.me>
  Date:   2022-07-15 (Fri, 15 Jul 2022)

  Changed paths:
    M lld/ELF/Arch/RISCV.cpp
    M lld/test/ELF/riscv-tls-le.s

  Log Message:
  -----------
  [ELF][RISCV] Relax local-exec TLS model

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 be 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)
```

Differential Revision: https://reviews.llvm.org/D129425




More information about the All-commits mailing list