[lld] [LLD][RISCV] Add relaxation for absolute symbol whose hi20 can use c.lui (PR #86294)
Philip Reames via llvm-commits
llvm-commits at lists.llvm.org
Fri Mar 22 08:19:13 PDT 2024
================
@@ -789,25 +791,39 @@ static void relaxTlsLe(const InputSection &sec, size_t i, uint64_t loc,
static void relaxHi20Lo12(const InputSection &sec, size_t i, uint64_t loc,
Relocation &r, uint32_t &remove) {
- const Defined *gp = ElfSym::riscvGlobalPointer;
- if (!gp)
- return;
-
- if (!isInt<12>(r.sym->getVA(r.addend) - gp->getVA()))
+ if (const Defined *gp = ElfSym::riscvGlobalPointer;
+ gp && isInt<12>(r.sym->getVA(r.addend) - gp->getVA())) {
+ switch (r.type) {
+ case R_RISCV_RVC_LUI:
----------------
preames wrote:
Note that the addition of the handling for R_RISCV_RVC_LUI is technically a separate change. Previously, if a user manually wrote a c.lui relocation in the assembler (clang doesn't seem to ever emit this), and we applied gp relaxation we'd end up with a stray c.lui whose result was never read. I noticed it while thinking through the interactions with the new code, but it could be separated if that was reviewer preference.
https://github.com/llvm/llvm-project/pull/86294
More information about the llvm-commits
mailing list