[all-commits] [llvm/llvm-project] cddb0d: [LLD][PowerPC] Implement GOT to PC-Rel relaxation

Nemanja Ivanovic via All-commits all-commits at lists.llvm.org
Mon Aug 17 07:37:01 PDT 2020


  Branch: refs/heads/master
  Home:   https://github.com/llvm/llvm-project
  Commit: cddb0dbcefd83109eee99a3bb1d8aa72629cf21d
      https://github.com/llvm/llvm-project/commit/cddb0dbcefd83109eee99a3bb1d8aa72629cf21d
  Author: Nemanja Ivanovic <nemanja.i.ibm at gmail.com>
  Date:   2020-08-17 (Mon, 17 Aug 2020)

  Changed paths:
    M lld/ELF/Arch/PPC64.cpp
    A lld/ELF/Arch/PPCInsns.def
    M lld/ELF/Config.h
    M lld/ELF/Driver.cpp
    M lld/ELF/InputSection.cpp
    M lld/ELF/Options.td
    M lld/ELF/Relocations.cpp
    M lld/ELF/Relocations.h
    A lld/test/ELF/Inputs/ppc64-got-to-pcrel-relaxation-def.s
    A lld/test/ELF/ppc64-got-to-pcrel-relaxation.s

  Log Message:
  -----------
  [LLD][PowerPC] Implement GOT to PC-Rel relaxation

This patch implements the handling for the R_PPC64_PCREL_OPT relocation as well
as the GOT relocation for the associated R_PPC64_GOT_PCREL34 relocation.

On Power10 targets with PC-Relative addressing, the linker can relax
GOT-relative accesses to PC-Relative under some conditions. Since the sequence
consists of a prefixed load, followed by a non-prefixed access (load or store),
the linker needs to replace the first instruction (as the replacement
instruction will be prefixed). The compiler communicates to the linker that
this optimization is safe by placing the two aforementioned relocations on the
GOT load (of the address).
The linker then does two things:

- Convert the load from the got into a PC-Relative add to compute the address
  relative to the PC
- Find the instruction referred to by the second relocation (R_PPC64_PCREL_OPT)
  and replace the first with the PC-Relative version of it

It is important to synchronize the mapping from legacy memory instructions to
their PC-Relative form. Hence, this patch adds a file to be included by both
the compiler and the linker so they're always in agreement.

Differential revision: https://reviews.llvm.org/D84360




More information about the All-commits mailing list