x86-64 PIC JIT fixes: do not generate the extra load for external GV's.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@53661 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Evan Cheng 2008-07-16 01:34:02 +00:00
parent 81fb5feede
commit 817a6a9eaa
2 changed files with 5 additions and 8 deletions

View File

@ -1677,15 +1677,11 @@ SDOperand X86TargetLowering::LowerCALL(SDOperand Op, SelectionDAG &DAG) {
if (GlobalAddressSDNode *G = dyn_cast<GlobalAddressSDNode>(Callee)) { if (GlobalAddressSDNode *G = dyn_cast<GlobalAddressSDNode>(Callee)) {
// We should use extra load for direct calls to dllimported functions in // We should use extra load for direct calls to dllimported functions in
// non-JIT mode. // non-JIT mode.
if ((IsTailCall || !Is64Bit || if (!Subtarget->GVRequiresExtraLoad(G->getGlobal(),
getTargetMachine().getCodeModel() != CodeModel::Large) getTargetMachine(), true))
&& !Subtarget->GVRequiresExtraLoad(G->getGlobal(),
getTargetMachine(), true))
Callee = DAG.getTargetGlobalAddress(G->getGlobal(), getPointerTy()); Callee = DAG.getTargetGlobalAddress(G->getGlobal(), getPointerTy());
} else if (ExternalSymbolSDNode *S = dyn_cast<ExternalSymbolSDNode>(Callee)) { } else if (ExternalSymbolSDNode *S = dyn_cast<ExternalSymbolSDNode>(Callee)) {
if (IsTailCall || !Is64Bit || Callee = DAG.getTargetExternalSymbol(S->getSymbol(), getPointerTy());
getTargetMachine().getCodeModel() != CodeModel::Large)
Callee = DAG.getTargetExternalSymbol(S->getSymbol(), getPointerTy());
} else if (IsTailCall) { } else if (IsTailCall) {
unsigned Opc = Is64Bit ? X86::R9 : X86::ECX; unsigned Opc = Is64Bit ? X86::R9 : X86::ECX;

View File

@ -37,7 +37,8 @@ bool X86Subtarget::GVRequiresExtraLoad(const GlobalValue* GV,
bool isDirectCall) const bool isDirectCall) const
{ {
// FIXME: PIC // FIXME: PIC
if (TM.getRelocationModel() != Reloc::Static) { if (TM.getRelocationModel() != Reloc::Static &&
TM.getCodeModel() != CodeModel::Large) {
if (isTargetDarwin()) { if (isTargetDarwin()) {
return (!isDirectCall && return (!isDirectCall &&
(GV->hasWeakLinkage() || GV->hasLinkOnceLinkage() || (GV->hasWeakLinkage() || GV->hasLinkOnceLinkage() ||