Fix PR4533, which is about buggy codegen in x86-64 -static mode.
Basically, using:
lea symbol(%rip), %rax
is not valid in -static mode, because the current RIP may not be
within 32-bits of "symbol" when an app is built partially pic and
partially static. The fix for this is to compile it to:
lea symbol, %rax
It would be better to codegen this as:
movq $symbol, %rax
but that will come next.
The hard part of fixing this bug was fixing abi-isel, which was actively
testing for the wrong behavior. Also, the RUN lines are completely impossible
to understand what they are testing. To help with this, convert the -static
x86-64 codegen tests to use filecheck. This is much more stable and makes it
more clear what the codegen is expected to be.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@75382 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Target/X86/X86ISelLowering.cpp b/lib/Target/X86/X86ISelLowering.cpp
index d14b1aa..1e79c4d 100644
--- a/lib/Target/X86/X86ISelLowering.cpp
+++ b/lib/Target/X86/X86ISelLowering.cpp
@@ -4453,7 +4453,7 @@
unsigned char OpFlag = 0;
unsigned WrapperKind = X86ISD::Wrapper;
- if (Subtarget->is64Bit() &&
+ if (Subtarget->isPICStyleRIPRel() &&
getTargetMachine().getCodeModel() == CodeModel::Small)
WrapperKind = X86ISD::WrapperRIP;
else if (Subtarget->isPICStyleGOT())
@@ -4485,7 +4485,7 @@
unsigned char OpFlag = 0;
unsigned WrapperKind = X86ISD::Wrapper;
- if (Subtarget->is64Bit() &&
+ if (Subtarget->isPICStyleRIPRel() &&
getTargetMachine().getCodeModel() == CodeModel::Small)
WrapperKind = X86ISD::WrapperRIP;
else if (Subtarget->isPICStyleGOT())
@@ -4517,7 +4517,7 @@
// global base reg.
unsigned char OpFlag = 0;
unsigned WrapperKind = X86ISD::Wrapper;
- if (Subtarget->is64Bit() &&
+ if (Subtarget->isPICStyleRIPRel() &&
getTargetMachine().getCodeModel() == CodeModel::Small)
WrapperKind = X86ISD::WrapperRIP;
else if (Subtarget->isPICStyleGOT())
@@ -4561,7 +4561,7 @@
Result = DAG.getTargetGlobalAddress(GV, getPointerTy(), 0, OpFlags);
}
- if (Subtarget->is64Bit() &&
+ if (Subtarget->isPICStyleRIPRel() &&
getTargetMachine().getCodeModel() == CodeModel::Small)
Result = DAG.getNode(X86ISD::WrapperRIP, dl, getPointerTy(), Result);
else