[PATCH] D127611: [ELF] Relax R_RISCV_CALL and R_RISCV_CALL_PLT

Fangrui Song via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sun Jun 12 23:05:09 PDT 2022


MaskRay created this revision.
MaskRay added reviewers: gkm, jrtc27, luismarques, kito-cheng.
Herald added subscribers: sunshaoce, VincentWu, luke957, StephenFan, vkmr, frasercrmck, evandro, apazos, sameer.abuasal, s.egerton, Jim, benna, psnobl, jocewei, PkmX, the_o, brucehoult, MartinMosbeck, rogfer01, edward-jones, zzheng, shiva0217, niosHD, sabuasal, simoncook, johnrusso, rbar, asb, arichardson, emaste.
Herald added a project: All.
MaskRay requested review of this revision.
Herald added subscribers: llvm-commits, pcwang-thead, eopXD.
Herald added a project: LLVM.

A pair of auipc+jalr relocated by R_RISCV_CALL or R_RISCV_CALL_PLT can be
converted to c.j, c.jal, or jal.

- c.j: RVC and displacement is representable as an int12
- c.jal: RV32C and displacement is representable as an int12
- jal: displacement is representable as an int21

Use the D127581 <https://reviews.llvm.org/D127581> relaxation framework to implement the relaxation. If a shorter
sequence is satisfied, we record the new relocation type in `relocTypes` and
saves the new form into `writes`. Finally let `riscvFinalizeRelax` rewrite the
instruction by setting `skip`.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D127611

Files:
  lld/ELF/Arch/RISCV.cpp
  lld/ELF/InputSection.h
  lld/test/ELF/riscv-relax-call.s

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D127611.436278.patch
Type: text/x-patch
Size: 10133 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220613/719a877b/attachment.bin>


More information about the llvm-commits mailing list