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
diff --git a/llvm/lib/Target/X86/X86FastISel.cpp b/llvm/lib/Target/X86/X86FastISel.cpp
index cea4dec..5dae485 100644
--- a/llvm/lib/Target/X86/X86FastISel.cpp
+++ b/llvm/lib/Target/X86/X86FastISel.cpp
@@ -3458,13 +3458,11 @@
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);