[PowerPC] Fix large code model with the ELFv2 ABI
authorUlrich Weigand <ulrich.weigand@de.ibm.com>
Wed, 13 Jan 2016 13:12:23 +0000 (13:12 +0000)
committerUlrich Weigand <ulrich.weigand@de.ibm.com>
Wed, 13 Jan 2016 13:12:23 +0000 (13:12 +0000)
commitdc8dfe1b86ab88d4db816714fa38951cd1b843d5
tree9146907fdd2fc5dd91c6937c784d816c57a0e5dc
parent74012f5a19492f002994872f6ed1cd96383b620e
[PowerPC] Fix large code model with the ELFv2 ABI

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

Reviewers: hfinkel

Differential Revision: http://reviews.llvm.org/D15500

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@257597 91177308-0d34-0410-b5e6-96231b3b80d8
lib/Target/PowerPC/PPCAsmPrinter.cpp
lib/Target/PowerPC/PPCMachineFunctionInfo.cpp
lib/Target/PowerPC/PPCMachineFunctionInfo.h
test/CodeGen/PowerPC/ppc64le-localentry-large.ll [new file with mode: 0644]
test/CodeGen/PowerPC/ppc64le-localentry.ll