[PATCH] D79977: [ELF][PPC64] Synthesize _savegpr[01]_{14..31} and _restgpr[01]_{14..31}

Fangrui Song via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu May 14 17:58:58 PDT 2020


MaskRay created this revision.
MaskRay added reviewers: Bdragon28, echristo, grimar, jyknight, ruiu, sfertile.
Herald added subscribers: llvm-commits, kbarton, arichardson, mgorny, nemanjai, emaste.
Herald added a reviewer: espindola.
Herald added a project: LLVM.

In the 64-bit ELF V2 API Specification: Power Architecture, 2.3.3.1. GPR
Save and Restore Functions defines some special functions which may be
referenced by GCC produced assembly (LLVM does not reference them).

With GCC -Os, when the number of call-saved registers exceeds a certain
threshold, GCC generates _savegpr0_* tgpr0_* calls and expects the
linker to define them. See
https://sourceware.org/pipermail/binutils/2002-February/017444.html and
https://sourceware.org/pipermail/binutils/2004-August/036765.html . This
is weird because libgcc.a would be the natural place. However, the linker
generation approach has the advantage that the linker can generate
multiple copies to avoid long branch thunks. We don't consider the
advantage significant enough to complicate our trunk implementation, so
we take a simple approach.

- Check whether _savegpr[01]_{14..31} and _restgpr[01]_{14..31} are used
- If yes, assemble the predefined .s and add the object file as LazyObjFile.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D79977

Files:
  lld/ELF/Arch/PPC64SaveRest.cpp
  lld/ELF/CMakeLists.txt
  lld/ELF/Driver.cpp
  lld/ELF/InputFiles.h
  lld/test/ELF/ppc64-savegpr0.s
  lld/test/ELF/ppc64-savegpr1.s

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D79977.264134.patch
Type: text/x-patch
Size: 15055 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200515/5dd52d23/attachment.bin>


More information about the llvm-commits mailing list