[all-commits] [llvm/llvm-project] 4b91af: [lld][LoongArch] Implement TLSDESC GD/LD to IE/LE.
Zhaoxin Yang via All-commits
all-commits at lists.llvm.org
Fri Apr 11 02:51:14 PDT 2025
Branch: refs/heads/users/ylzsx/r-tlsdesc-to-iele-norelax
Home: https://github.com/llvm/llvm-project
Commit: 4b91af1232fe7a18b4fca4329d0c916cbfa59dc9
https://github.com/llvm/llvm-project/commit/4b91af1232fe7a18b4fca4329d0c916cbfa59dc9
Author: yangzhaoxin <yangzhaoxin at loongson.cn>
Date: 2025-04-11 (Fri, 11 Apr 2025)
Changed paths:
M lld/ELF/Arch/LoongArch.cpp
M lld/ELF/InputSection.cpp
M lld/ELF/Relocations.cpp
M lld/ELF/Relocations.h
Log Message:
-----------
[lld][LoongArch] Implement TLSDESC GD/LD to IE/LE.
Support TLSDESC to initial-exec or local-exec optimizations. Introduce a new hook
RE_LOONGARCH_RELAX_TLS_GD_TO_IE_PAGE_PC and use existing R_RELAX_TLS_GD_TO_IE_ABS
to support TLSDESC => IE, while use existing R_RELAX_TLS_GD_TO_LE to support
TLSDESC => LE.
In normal or medium code model, there are two forms of code sequences:
* pcalau12i $a0, %desc_pc_hi20(sym_desc)
* addi.d $a0, $a0, %desc_pc_lo12(sym_desc)
* ld.d $ra, $a0, %desc_ld(sym_desc)
* jirl $ra, $ra, %desc_call(sym_desc)
------
* pcaddi $a0, %desc_pcrel_20(sym_desc)
* ld.d $ra, $a0, %desc_ld(sym_desc)
* jirl $ra, $ra, %desc_call(sym_desc)
The code sequence obtained is as follows:
* pcalau12i $a0, %ie_pc_hi20(sym_ie)
* ld.[wd] $a0, $a0, %ie_pc_lo12(sym_ie)
Simplicity, whether tlsdescToIe or tlsdescToLe, we always tend to convert the preceding
instructions to NOPs, due to both forms of code sequence (corresponding to relocation
combinations: R_LARCH_TLS_DESC_PC_HI20+R_LARCH_TLS_DESC_PC_LO12 and R_LARCH_TLS_DESC_PCREL20_S2)
have same process.
FIXME: When relaxation enables, redundant NOPs can be removed. It will
be implemented in a future patch.
Note: All forms of TLSDESC code sequences should not appear interleaved in the normal,
medium or extreme code model, which compilers do not generate and lld is unsupported.
This is thanks to the guard in PostRASchedulerList.cpp in llvm.
```
Calls are not scheduling boundaries before register allocation, but
post-ra we don't gain anything by scheduling across calls since we
don't need to worry about register pressure.
```
Commit: 99c1a4eaaad1e71aab45861aa48da768e8868d0b
https://github.com/llvm/llvm-project/commit/99c1a4eaaad1e71aab45861aa48da768e8868d0b
Author: yangzhaoxin <yangzhaoxin at loongson.cn>
Date: 2025-04-11 (Fri, 11 Apr 2025)
Changed paths:
M lld/test/ELF/loongarch-relax-tlsdesc.s
M lld/test/ELF/loongarch-tlsdesc-pcrel20-s2.s
M lld/test/ELF/loongarch-tlsdesc.s
Log Message:
-----------
Modify loongarch-tlsdesc.s and loongarch-tlsdesc-pcrel20-s2.s
Add loongarch-relax-tlsdesc.s
Commit: baee006a50c14536f2e60ad4300458458ee67d6c
https://github.com/llvm/llvm-project/commit/baee006a50c14536f2e60ad4300458458ee67d6c
Author: yangzhaoxin <yangzhaoxin at loongson.cn>
Date: 2025-04-11 (Fri, 11 Apr 2025)
Changed paths:
M lld/ELF/Relocations.cpp
M lld/ELF/Symbols.h
Log Message:
-----------
Delete the wrong flag NEEDS_TLSGD_TO_IE in the extreme code model.
Compare: https://github.com/llvm/llvm-project/compare/0c6ba1de86e3...baee006a50c1
To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications
More information about the All-commits
mailing list