1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-10-19 02:52:53 +02:00

FastISel: support no-PLT PIC calls on ELF x86_64

Add support for properly handling PIC code with no-PLT.  This equates to
`-fpic -fno-plt -O0` with the clang frontend.  External functions are
marked with nonlazybind, which must then be indirected through the GOT.
This allows code to be built without optimizations in PIC mode without
going through the PLT.  Addresses PR35653!

llvm-svn: 320776
This commit is contained in:
Saleem Abdulrasool 2017-12-15 00:32:09 +00:00
parent d2ace26a79
commit 6f4b31d957
2 changed files with 18 additions and 4 deletions

View File

@ -3458,13 +3458,11 @@ bool X86FastISel::fastLowerCall(CallLoweringInfo &CLI) {
assert(GV && "Not a direct call");
// See if we need any target-specific flags on the GV operand.
unsigned char OpFlags = Subtarget->classifyGlobalFunctionReference(GV);
// Ignore NonLazyBind attribute in FastISel
if (OpFlags == X86II::MO_GOTPCREL)
OpFlags = 0;
// This will be a direct call, or an indirect call through memory for
// NonLazyBind calls or dllimport calls.
bool NeedLoad = OpFlags == X86II::MO_DLLIMPORT;
bool NeedLoad =
OpFlags == X86II::MO_DLLIMPORT || OpFlags == X86II::MO_GOTPCREL;
unsigned CallOpc = NeedLoad
? (Is64Bit ? X86::CALL64m : X86::CALL32m)
: (Is64Bit ? X86::CALL64pcrel32 : X86::CALLpcrel32);

View File

@ -0,0 +1,16 @@
; RUN: llc -mtriple x86_64-unknown-linux-gnu -O0 -fast-isel=true -relocation-model=pic -filetype asm -o - %s | FileCheck %s
declare void @f() local_unnamed_addr #0
define void @g() local_unnamed_addr {
entry:
call void @f()
ret void
}
attributes #0 = { nonlazybind }
; CHECK-LABEL: g:
; CHECK-LABEL: callq *f@GOTPCREL(%rip)
; CHECK-LABEL: retq