summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorLouis Gerbarg <lgg@apple.com>2014-06-16 17:35:40 +0000
committerLouis Gerbarg <lgg@apple.com>2014-06-16 17:35:40 +0000
commita564159d85ead67f5bea1d6fda1b7e261db23825 (patch)
tree679486391fecc078686a687bce2e67f14a473e30 /lib
parentdc2dc390f65ecc3b769c806cfc40b14fd42eed91 (diff)
downloadllvm-a564159d85ead67f5bea1d6fda1b7e261db23825.tar.gz
llvm-a564159d85ead67f5bea1d6fda1b7e261db23825.tar.bz2
llvm-a564159d85ead67f5bea1d6fda1b7e261db23825.tar.xz
Fix illegal relocations in X86FastISel
On x86_86 the lea instruction can only use a 32 bit immediate value. When the code is compiled statically the RIP register is not used, meaning the immediate is all that can be used for the relocation, which is not sufficient in the case of targets more than +/- 2GB away. This patch bails out of fast isel in those cases and reverts to DAG which does the right thing. Test case included. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@211040 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib')
-rw-r--r--lib/Target/X86/X86FastISel.cpp4
1 files changed, 4 insertions, 0 deletions
diff --git a/lib/Target/X86/X86FastISel.cpp b/lib/Target/X86/X86FastISel.cpp
index 0308b1e029..4b8a8362c5 100644
--- a/lib/Target/X86/X86FastISel.cpp
+++ b/lib/Target/X86/X86FastISel.cpp
@@ -2709,6 +2709,10 @@ unsigned X86FastISel::TargetMaterializeConstant(const Constant *C) {
// Materialize addresses with LEA instructions.
if (isa<GlobalValue>(C)) {
+ //LEA can only handle 32 bit immediates
+ if (TM.getRelocationModel() == Reloc::Static && Subtarget->is64Bit())
+ return false;
+
X86AddressMode AM;
if (X86SelectAddress(C, AM)) {
// If the expression is just a basereg, then we're done, otherwise we need