From: Akira Hatanaka Date: Thu, 8 Dec 2011 21:05:38 +0000 (+0000) Subject: Pass a GlobalAddress instead of an ExternalSymbol to LowerCallTo in X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=7a7194b5294661809ab37270c8ee5e94f8cdee18;p=oota-llvm.git Pass a GlobalAddress instead of an ExternalSymbol to LowerCallTo in MipsTargetLowering::LowerGlobalTLSAddress. This is necessary to have call16(__tls_get_addr) emitted instead of got_disp(__tls_get_addr) when the target is Mips64. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@146183 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Target/Mips/MipsISelLowering.cpp b/lib/Target/Mips/MipsISelLowering.cpp index 20feb71316f..c888cfc4cab 100644 --- a/lib/Target/Mips/MipsISelLowering.cpp +++ b/lib/Target/Mips/MipsISelLowering.cpp @@ -1550,19 +1550,26 @@ LowerGlobalTLSAddress(SDValue Op, SelectionDAG &DAG) const SDValue TGA = DAG.getTargetGlobalAddress(GV, dl, PtrVT, 0, MipsII::MO_TLSGD); SDValue Argument = DAG.getNode(MipsISD::WrapperPIC, dl, PtrVT, TGA); + unsigned PtrSize = PtrVT.getSizeInBits(); + IntegerType *PtrTy = Type::getIntNTy(*DAG.getContext(), PtrSize); + + SmallVector Params; + Params.push_back(PtrTy); + FunctionType *FuncTy = FunctionType::get(PtrTy, Params, false); + Function *Func = Function::Create(FuncTy, GlobalValue::ExternalLinkage, + "__tls_get_addr"); + SDValue TlsGetAddr = DAG.getGlobalAddress(Func, dl, PtrVT); ArgListTy Args; ArgListEntry Entry; Entry.Node = Argument; - unsigned PtrSize = PtrVT.getSizeInBits(); - IntegerType *PtrTy = Type::getIntNTy(*DAG.getContext(), PtrSize); Entry.Ty = PtrTy; Args.push_back(Entry); + std::pair CallResult = LowerCallTo(DAG.getEntryNode(), PtrTy, false, false, false, false, 0, CallingConv::C, false, true, - DAG.getExternalSymbol("__tls_get_addr", PtrVT), Args, DAG, - dl); + TlsGetAddr, Args, DAG, dl); return CallResult.first; }