- Added option -relocation-model to set relocation model. Valid values include static, pic,
dynamic-no-pic, and default.
PPC and x86 default is dynamic-no-pic for Darwin, pic for others.
- Removed options -enable-pic and -ppc-static.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@26315 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Target/X86/X86ISelLowering.cpp b/lib/Target/X86/X86ISelLowering.cpp
index 77fc52b..105e6ce 100644
--- a/lib/Target/X86/X86ISelLowering.cpp
+++ b/lib/Target/X86/X86ISelLowering.cpp
@@ -1836,7 +1836,7 @@
if (getTargetMachine().
getSubtarget<X86Subtarget>().isTargetDarwin()) {
// With PIC, the address is actually $g + Offset.
- if (PICEnabled)
+ if (getTargetMachine().getRelocationModel() == Reloc::PIC)
Result = DAG.getNode(ISD::ADD, getPointerTy(),
DAG.getNode(X86ISD::GlobalBaseReg, getPointerTy()), Result);
}
@@ -1851,7 +1851,7 @@
GlobalValue *GV = cast<GlobalAddressSDNode>(Op)->getGlobal();
SDOperand Addr = DAG.getTargetGlobalAddress(GV, getPointerTy());
// With PIC, the address is actually $g + Offset.
- if (PICEnabled)
+ if (getTargetMachine().getRelocationModel() == Reloc::PIC)
Addr = DAG.getNode(ISD::ADD, getPointerTy(),
DAG.getNode(X86ISD::GlobalBaseReg, getPointerTy()), Addr);
@@ -1859,8 +1859,9 @@
// the value at address GV, not the value of GV itself. This means that
// the GlobalAddress must be in the base or index register of the address,
// not the GV offset field.
- if (GV->hasWeakLinkage() || GV->hasLinkOnceLinkage() ||
- (GV->isExternal() && !GV->hasNotBeenReadFromBytecode()))
+ if (getTargetMachine().getRelocationModel() != Reloc::Static &&
+ (GV->hasWeakLinkage() || GV->hasLinkOnceLinkage() ||
+ (GV->isExternal() && !GV->hasNotBeenReadFromBytecode())))
Result = DAG.getLoad(MVT::i32, DAG.getEntryNode(),
Addr, DAG.getSrcValue(NULL));
}