On Mac OS X, GV requires an extra load only when relocation-model is non-static.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@36718 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Evan Cheng 2007-05-04 00:26:58 +00:00
parent 874ebada58
commit 97c9bb5cc6

View File

@ -812,10 +812,11 @@ SDOperand ARMTargetLowering::LowerGlobalAddressELF(SDOperand Op,
}
/// GVIsIndirectSymbol - true if the GV will be accessed via an indirect symbol
/// even in dynamic-no-pic mode.
static bool GVIsIndirectSymbol(GlobalValue *GV) {
return (GV->hasWeakLinkage() || GV->hasLinkOnceLinkage() ||
(GV->isDeclaration() && !GV->hasNotBeenReadFromBytecode()));
/// even in non-static mode.
static bool GVIsIndirectSymbol(GlobalValue *GV, Reloc::Model RelocM) {
return RelocM != Reloc::Static &&
(GV->hasWeakLinkage() || GV->hasLinkOnceLinkage() ||
(GV->isDeclaration() && !GV->hasNotBeenReadFromBytecode()));
}
SDOperand ARMTargetLowering::LowerGlobalAddressDarwin(SDOperand Op,
@ -823,7 +824,7 @@ SDOperand ARMTargetLowering::LowerGlobalAddressDarwin(SDOperand Op,
MVT::ValueType PtrVT = getPointerTy();
GlobalValue *GV = cast<GlobalAddressSDNode>(Op)->getGlobal();
Reloc::Model RelocM = getTargetMachine().getRelocationModel();
bool IsIndirect = GVIsIndirectSymbol(GV);
bool IsIndirect = GVIsIndirectSymbol(GV, RelocM);
SDOperand CPAddr;
if (RelocM == Reloc::Static)
CPAddr = DAG.getTargetConstantPool(GV, PtrVT, 2);