The global entry point prologue currently assumes that the TOC associated
with a function is less than 2GB away from the function entry point. This
is always true when using the medium or small code model, but may not be
the case when using the large code model.
This patch adds a new variant of the ELFv2 global entry point prologue that
lifts the 2GB restriction when building with -mcmodel=large. This works by
emitting a quadword containing the distance from the function entry point
to its associated TOC immediately before the entry point, and then using a
prologue like:
ld r2,-8(r12)
add r2,r2,r12
Since creation of the entry point prologue is now split across two separate
routines (PPCLinuxAsmPrinter::EmitFunctionEntryLabel emits the data word,
PPCLinuxAsmPrinter::EmitFunctionBodyStart the prolog code), I've switched
to using named labels instead of just temporaries to indicate the locations
of the global and local entry points and the new TOC offset data word.
These names are provided by new routines in PPCFunctionInfo modeled
after the existing PPCFunctionInfo::getPICOffsetSymbol.
Note that a corresponding change was committed to GCC here:
https://gcc.gnu.org/ml/gcc-patches/2015-12/msg00355.html
[ The GCC patch implements a further optimization, R_PPC64_ENTRY,
which isn't in the LLVM patch yet, since it requires working .reloc
support in the assembler. This can always be added later on. ]