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
This commit is contained in:
Chris Lattner 2009-07-11 20:29:19 +00:00
parent 97c8c51f07
commit 4f06649497
2 changed files with 561 additions and 24 deletions

View File

@ -4453,7 +4453,7 @@ X86TargetLowering::LowerConstantPool(SDValue Op, SelectionDAG &DAG) {
unsigned char OpFlag = 0; unsigned char OpFlag = 0;
unsigned WrapperKind = X86ISD::Wrapper; unsigned WrapperKind = X86ISD::Wrapper;
if (Subtarget->is64Bit() && if (Subtarget->isPICStyleRIPRel() &&
getTargetMachine().getCodeModel() == CodeModel::Small) getTargetMachine().getCodeModel() == CodeModel::Small)
WrapperKind = X86ISD::WrapperRIP; WrapperKind = X86ISD::WrapperRIP;
else if (Subtarget->isPICStyleGOT()) else if (Subtarget->isPICStyleGOT())
@ -4485,7 +4485,7 @@ SDValue X86TargetLowering::LowerJumpTable(SDValue Op, SelectionDAG &DAG) {
unsigned char OpFlag = 0; unsigned char OpFlag = 0;
unsigned WrapperKind = X86ISD::Wrapper; unsigned WrapperKind = X86ISD::Wrapper;
if (Subtarget->is64Bit() && if (Subtarget->isPICStyleRIPRel() &&
getTargetMachine().getCodeModel() == CodeModel::Small) getTargetMachine().getCodeModel() == CodeModel::Small)
WrapperKind = X86ISD::WrapperRIP; WrapperKind = X86ISD::WrapperRIP;
else if (Subtarget->isPICStyleGOT()) else if (Subtarget->isPICStyleGOT())
@ -4517,7 +4517,7 @@ X86TargetLowering::LowerExternalSymbol(SDValue Op, SelectionDAG &DAG) {
// global base reg. // global base reg.
unsigned char OpFlag = 0; unsigned char OpFlag = 0;
unsigned WrapperKind = X86ISD::Wrapper; unsigned WrapperKind = X86ISD::Wrapper;
if (Subtarget->is64Bit() && if (Subtarget->isPICStyleRIPRel() &&
getTargetMachine().getCodeModel() == CodeModel::Small) getTargetMachine().getCodeModel() == CodeModel::Small)
WrapperKind = X86ISD::WrapperRIP; WrapperKind = X86ISD::WrapperRIP;
else if (Subtarget->isPICStyleGOT()) else if (Subtarget->isPICStyleGOT())
@ -4561,7 +4561,7 @@ X86TargetLowering::LowerGlobalAddress(const GlobalValue *GV, DebugLoc dl,
Result = DAG.getTargetGlobalAddress(GV, getPointerTy(), 0, OpFlags); Result = DAG.getTargetGlobalAddress(GV, getPointerTy(), 0, OpFlags);
} }
if (Subtarget->is64Bit() && if (Subtarget->isPICStyleRIPRel() &&
getTargetMachine().getCodeModel() == CodeModel::Small) getTargetMachine().getCodeModel() == CodeModel::Small)
Result = DAG.getNode(X86ISD::WrapperRIP, dl, getPointerTy(), Result); Result = DAG.getNode(X86ISD::WrapperRIP, dl, getPointerTy(), Result);
else else

File diff suppressed because it is too large Load Diff