[PATCH] D79864: [PowerPC] Add new linker optimization for PowerPC

Stefan Pintilie via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed May 13 08:05:30 PDT 2020


stefanp created this revision.
stefanp added reviewers: nemanjai, lei, PowerPC, hfinkel.
Herald added subscribers: steven.zhang, shchenz, kbarton, hiraditya.
Herald added a project: LLVM.

A linker optimization is available on PowerPC for GOT indirect PCRelative loads.

The idea is that we can mark a usual GOT indirect load:

  pld 3, vec at got@pcrel(0), 1
  lwa 3, 4(3)

With a relocation to say that if we don't need to go through the GOT we can let the linker further optimize this and replace a load with a nop.

    pld 3, vec at got@pcrel(0), 1
  .Lpcrel1:
  .reloc .Lpcrel1-8,R_PPC64_PCREL_OPT,.-(.Lpcrel1-8)
    lwa 3, 4(3)

Which will eventually turn it into this by the linker (if we don't actually need to go through the GOT):

  plwa 3, vec at got@pcrel+4(0), 1
  nop

To create those relocations on the compiler side this patch adds an MCSymbol operand on the pld and the subsequent load or store that depends on it. 
This symbol is then read in the MC layer and is used to match the two instructions together.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D79864

Files:
  llvm/lib/Target/PowerPC/MCTargetDesc/PPCInstPrinter.cpp
  llvm/lib/Target/PowerPC/PPC.h
  llvm/lib/Target/PowerPC/PPCInstrInfo.cpp
  llvm/lib/Target/PowerPC/PPCInstrPrefix.td
  llvm/lib/Target/PowerPC/PPCMCInstLower.cpp
  llvm/lib/Target/PowerPC/PPCMIPeephole.cpp
  llvm/test/CodeGen/PowerPC/pcrel-call-linkage-with-calls.ll
  llvm/test/CodeGen/PowerPC/pcrel-got-indirect.ll
  llvm/test/CodeGen/PowerPC/pcrel-linkeropt.ll
  llvm/test/CodeGen/PowerPC/pcrel-relocation-plus-offset.ll
  llvm/test/CodeGen/PowerPC/pcrel-tail-calls.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D79864.263713.patch
Type: text/x-patch
Size: 33137 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200513/dc3b60c0/attachment-0001.bin>


More information about the llvm-commits mailing list