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:
parent
d2ace26a79
commit
6f4b31d957
@ -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);
|
||||
|
16
test/CodeGen/X86/fast-isel-noplt-pic.ll
Normal file
16
test/CodeGen/X86/fast-isel-noplt-pic.ll
Normal 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
|
||||
|
Loading…
Reference in New Issue
Block a user