[all-commits] [llvm/llvm-project] 75e551: [ELF] Relax R_RISCV_CALL and R_RISCV_CALL_PLT

Fangrui Song via All-commits all-commits at lists.llvm.org
Thu Jul 7 10:18:59 PDT 2022


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

  Changed paths:
    M lld/ELF/Arch/RISCV.cpp
    A lld/test/ELF/riscv-relax-call.s
    A lld/test/ELF/riscv-relax-call2.s

  Log Message:
  -----------
  [ELF] Relax R_RISCV_CALL and R_RISCV_CALL_PLT

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 relaxation framework to implement the relaxation. If a shorter
sequence is satisfied, we record the new relocation type in `relocTypes` and
saves the new instruction into `writes`. Finally let `riscvFinalizeRelax` rewrite the
instruction by setting `skip`.

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




More information about the All-commits mailing list