[all-commits] [llvm/llvm-project] 5e854a: [lld][LoongArch] GOT indirection to PC relative op...

Zhaoxin Yang via All-commits all-commits at lists.llvm.org
Wed Jul 23 20:56:43 PDT 2025


  Branch: refs/heads/users/ylzsx/r-got-to-pcrel
  Home:   https://github.com/llvm/llvm-project
  Commit: 5e854ab7e239c318c42cda50e9580ee53ba827b7
      https://github.com/llvm/llvm-project/commit/5e854ab7e239c318c42cda50e9580ee53ba827b7
  Author: yangzhaoxin <yangzhaoxin at loongson.cn>
  Date:   2025-07-24 (Thu, 24 Jul 2025)

  Changed paths:
    M lld/ELF/Arch/LoongArch.cpp
    M lld/test/ELF/loongarch-relax-pc-hi20-lo12.s

  Log Message:
  -----------
  [lld][LoongArch] GOT indirection to PC relative optimization.

In LoongArch, this optimization is only supported when relaxation is enabled.
From:
 * pcalau12i $a0, %got_pc_hi20(sym_got)
 * ld.w/d $a0, $a0, %got_pc_lo12(sym_got)
To:
 * pcalau12i $a0, %pc_hi20(sym)
 * addi.w/d $a0, $a0, %pc_lo12(sym)

If the original code sequence can be relaxed into a single instruction
`pcaddi`, this patch will not be taken (see https://).
The implementation related to `got` is split into two locations because
the `relax()` function is part of an iteration fixed-point algorithm. We
should minimize it to achieve better linker performance.

FIXME: Althouth the optimization has been performed, the GOT entries still
exists, similarly to AArch64. Eliminating the entries may be require
additional marking in the common code.


  Commit: c18b57d47b33c1dd91dee4595cd42cfe51c9ee0c
      https://github.com/llvm/llvm-project/commit/c18b57d47b33c1dd91dee4595cd42cfe51c9ee0c
  Author: yangzhaoxin <yangzhaoxin at loongson.cn>
  Date:   2025-07-24 (Thu, 24 Jul 2025)

  Changed paths:
    M lld/ELF/Arch/LoongArch.cpp

  Log Message:
  -----------
  Add check for register.


  Commit: 9b06f463928cc2450bd38cfa99b47659be1e4417
      https://github.com/llvm/llvm-project/commit/9b06f463928cc2450bd38cfa99b47659be1e4417
  Author: yangzhaoxin <yangzhaoxin at loongson.cn>
  Date:   2025-07-24 (Thu, 24 Jul 2025)

  Changed paths:
    M lld/ELF/Arch/LoongArch.cpp

  Log Message:
  -----------
  Delete FIXME according to review.


Compare: https://github.com/llvm/llvm-project/compare/2d92dc3684b5...9b06f463928c

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