@@ -9061,8 +9061,8 @@ static bool isInTailCallPositionWrapper(const CallInst *CI,
90619061std::pair<SDValue, SDValue>
90629062SelectionDAG::getMemcmp(SDValue Chain, const SDLoc &dl, SDValue Mem0,
90639063 SDValue Mem1, SDValue Size, const CallInst *CI) {
9064- const char *LibCallName = TLI->getLibcallName (RTLIB::MEMCMP);
9065- if (!LibCallName )
9064+ RTLIB::LibcallImpl MemcmpImpl = TLI->getLibcallImpl (RTLIB::MEMCMP);
9065+ if (MemcmpImpl == RTLIB::Unsupported )
90669066 return {};
90679067
90689068 PointerType *PT = PointerType::getUnqual(*getContext());
@@ -9075,13 +9075,14 @@ SelectionDAG::getMemcmp(SDValue Chain, const SDLoc &dl, SDValue Mem0,
90759075 bool IsTailCall =
90769076 isInTailCallPositionWrapper(CI, this, /*AllowReturnsFirstArg*/ true);
90779077
9078+ StringRef LibCallName = TLI->getLibcallImplName(MemcmpImpl);
90789079 CLI.setDebugLoc(dl)
90799080 .setChain(Chain)
9080- .setLibCallee(
9081- TLI->getLibcallCallingConv(RTLIB::MEMCMP ),
9082- Type::getInt32Ty(*getContext() ),
9083- getExternalSymbol(LibCallName, TLI->getPointerTy(getDataLayout())),
9084- std::move(Args))
9081+ .setLibCallee(TLI->getLibcallImplCallingConv(MemcmpImpl),
9082+ Type::getInt32Ty(*getContext() ),
9083+ getExternalSymbol(LibCallName.data( ),
9084+ TLI->getPointerTy(getDataLayout())),
9085+ std::move(Args))
90859086 .setTailCall(IsTailCall);
90869087
90879088 return TLI->LowerCallTo(CLI);
@@ -9091,8 +9092,8 @@ std::pair<SDValue, SDValue> SelectionDAG::getStrlen(SDValue Chain,
90919092 const SDLoc &dl,
90929093 SDValue Src,
90939094 const CallInst *CI) {
9094- const char *LibCallName = TLI->getLibcallName (RTLIB::STRLEN);
9095- if (!LibCallName )
9095+ RTLIB::LibcallImpl StrlenImpl = TLI->getLibcallImpl (RTLIB::STRLEN);
9096+ if (StrlenImpl == RTLIB::Unsupported )
90969097 return {};
90979098
90989099 // Emit a library call.
@@ -9102,13 +9103,15 @@ std::pair<SDValue, SDValue> SelectionDAG::getStrlen(SDValue Chain,
91029103 TargetLowering::CallLoweringInfo CLI(*this);
91039104 bool IsTailCall =
91049105 isInTailCallPositionWrapper(CI, this, /*AllowReturnsFirstArg*/ true);
9106+ StringRef LibcallName = TLI->getLibcallImplName(StrlenImpl);
91059107
91069108 CLI.setDebugLoc(dl)
91079109 .setChain(Chain)
9108- .setLibCallee(TLI->getLibcallCallingConv(RTLIB::STRLEN), CI->getType(),
9109- getExternalSymbol(
9110- LibCallName, TLI->getProgramPointerTy(getDataLayout())),
9111- std::move(Args))
9110+ .setLibCallee(
9111+ TLI->getLibcallImplCallingConv(StrlenImpl), CI->getType(),
9112+ getExternalSymbol(LibcallName.data(),
9113+ TLI->getProgramPointerTy(getDataLayout())),
9114+ std::move(Args))
91129115 .setTailCall(IsTailCall);
91139116
91149117 return TLI->LowerCallTo(CLI);
@@ -9211,17 +9214,19 @@ SDValue SelectionDAG::getAtomicMemcpy(SDValue Chain, const SDLoc &dl,
92119214
92129215 RTLIB::Libcall LibraryCall =
92139216 RTLIB::getMEMCPY_ELEMENT_UNORDERED_ATOMIC(ElemSz);
9214- if (LibraryCall == RTLIB::UNKNOWN_LIBCALL)
9217+ RTLIB::LibcallImpl LibcallImpl = TLI->getLibcallImpl(LibraryCall);
9218+ if (LibcallImpl == RTLIB::Unsupported)
92159219 report_fatal_error("Unsupported element size");
92169220
92179221 TargetLowering::CallLoweringInfo CLI(*this);
92189222 CLI.setDebugLoc(dl)
92199223 .setChain(Chain)
9220- .setLibCallee(TLI->getLibcallCallingConv(LibraryCall),
9221- Type::getVoidTy(*getContext()),
9222- getExternalSymbol(TLI->getLibcallName(LibraryCall),
9223- TLI->getPointerTy(getDataLayout())),
9224- std::move(Args))
9224+ .setLibCallee(
9225+ TLI->getLibcallImplCallingConv(LibcallImpl),
9226+ Type::getVoidTy(*getContext()),
9227+ getExternalSymbol(TLI->getLibcallImplName(LibcallImpl).data(),
9228+ TLI->getPointerTy(getDataLayout())),
9229+ std::move(Args))
92259230 .setDiscardResult()
92269231 .setTailCall(isTailCall);
92279232
@@ -9317,17 +9322,19 @@ SDValue SelectionDAG::getAtomicMemmove(SDValue Chain, const SDLoc &dl,
93179322
93189323 RTLIB::Libcall LibraryCall =
93199324 RTLIB::getMEMMOVE_ELEMENT_UNORDERED_ATOMIC(ElemSz);
9320- if (LibraryCall == RTLIB::UNKNOWN_LIBCALL)
9325+ RTLIB::LibcallImpl LibcallImpl = TLI->getLibcallImpl(LibraryCall);
9326+ if (LibcallImpl == RTLIB::Unsupported)
93219327 report_fatal_error("Unsupported element size");
93229328
93239329 TargetLowering::CallLoweringInfo CLI(*this);
93249330 CLI.setDebugLoc(dl)
93259331 .setChain(Chain)
9326- .setLibCallee(TLI->getLibcallCallingConv(LibraryCall),
9327- Type::getVoidTy(*getContext()),
9328- getExternalSymbol(TLI->getLibcallName(LibraryCall),
9329- TLI->getPointerTy(getDataLayout())),
9330- std::move(Args))
9332+ .setLibCallee(
9333+ TLI->getLibcallImplCallingConv(LibcallImpl),
9334+ Type::getVoidTy(*getContext()),
9335+ getExternalSymbol(TLI->getLibcallImplName(LibcallImpl).data(),
9336+ TLI->getPointerTy(getDataLayout())),
9337+ std::move(Args))
93319338 .setDiscardResult()
93329339 .setTailCall(isTailCall);
93339340
@@ -9388,27 +9395,32 @@ SDValue SelectionDAG::getMemset(SDValue Chain, const SDLoc &dl, SDValue Dst,
93889395 // FIXME: pass in SDLoc
93899396 CLI.setDebugLoc(dl).setChain(Chain);
93909397
9391- const char *BzeroName = getTargetLoweringInfo().getLibcallName(RTLIB::BZERO);
9398+ RTLIB::LibcallImpl BzeroImpl = TLI->getLibcallImpl(RTLIB::BZERO);
9399+ bool UseBZero = BzeroImpl != RTLIB::Unsupported && isNullConstant(Src);
93929400
9393- bool UseBZero = isNullConstant(Src) && BzeroName;
93949401 // If zeroing out and bzero is present, use it.
93959402 if (UseBZero) {
93969403 TargetLowering::ArgListTy Args;
93979404 Args.emplace_back(Dst, PointerType::getUnqual(Ctx));
93989405 Args.emplace_back(Size, DL.getIntPtrType(Ctx));
93999406 CLI.setLibCallee(
9400- TLI->getLibcallCallingConv(RTLIB::BZERO), Type::getVoidTy(Ctx),
9401- getExternalSymbol(BzeroName, TLI->getPointerTy(DL)), std::move(Args));
9407+ TLI->getLibcallImplCallingConv(BzeroImpl), Type::getVoidTy(Ctx),
9408+ getExternalSymbol(TLI->getLibcallImplName(BzeroImpl).data(),
9409+ TLI->getPointerTy(DL)),
9410+ std::move(Args));
94029411 } else {
9412+ RTLIB::LibcallImpl MemsetImpl = TLI->getLibcallImpl(RTLIB::MEMSET);
9413+
94039414 TargetLowering::ArgListTy Args;
94049415 Args.emplace_back(Dst, PointerType::getUnqual(Ctx));
94059416 Args.emplace_back(Src, Src.getValueType().getTypeForEVT(Ctx));
94069417 Args.emplace_back(Size, DL.getIntPtrType(Ctx));
9407- CLI.setLibCallee(TLI->getLibcallCallingConv(RTLIB::MEMSET),
9408- Dst.getValueType().getTypeForEVT(Ctx),
9409- getExternalSymbol(TLI->getLibcallName(RTLIB::MEMSET),
9410- TLI->getPointerTy(DL)),
9411- std::move(Args));
9418+ CLI.setLibCallee(
9419+ TLI->getLibcallImplCallingConv(MemsetImpl),
9420+ Dst.getValueType().getTypeForEVT(Ctx),
9421+ getExternalSymbol(TLI->getLibcallImplName(MemsetImpl).data(),
9422+ TLI->getPointerTy(DL)),
9423+ std::move(Args));
94129424 }
94139425
94149426 RTLIB::LibcallImpl MemsetImpl = TLI->getLibcallImpl(RTLIB::MEMSET);
@@ -9440,17 +9452,19 @@ SDValue SelectionDAG::getAtomicMemset(SDValue Chain, const SDLoc &dl,
94409452
94419453 RTLIB::Libcall LibraryCall =
94429454 RTLIB::getMEMSET_ELEMENT_UNORDERED_ATOMIC(ElemSz);
9443- if (LibraryCall == RTLIB::UNKNOWN_LIBCALL)
9455+ RTLIB::LibcallImpl LibcallImpl = TLI->getLibcallImpl(LibraryCall);
9456+ if (LibcallImpl == RTLIB::Unsupported)
94449457 report_fatal_error("Unsupported element size");
94459458
94469459 TargetLowering::CallLoweringInfo CLI(*this);
94479460 CLI.setDebugLoc(dl)
94489461 .setChain(Chain)
9449- .setLibCallee(TLI->getLibcallCallingConv(LibraryCall),
9450- Type::getVoidTy(*getContext()),
9451- getExternalSymbol(TLI->getLibcallName(LibraryCall),
9452- TLI->getPointerTy(getDataLayout())),
9453- std::move(Args))
9462+ .setLibCallee(
9463+ TLI->getLibcallImplCallingConv(LibcallImpl),
9464+ Type::getVoidTy(*getContext()),
9465+ getExternalSymbol(TLI->getLibcallImplName(LibcallImpl).data(),
9466+ TLI->getPointerTy(getDataLayout())),
9467+ std::move(Args))
94549468 .setDiscardResult()
94559469 .setTailCall(isTailCall);
94569470
@@ -14177,13 +14191,18 @@ SDValue SelectionDAG::makeStateFunctionCall(unsigned LibFunc, SDValue Ptr,
1417714191 assert(InChain.getValueType() == MVT::Other && "Expected token chain");
1417814192 TargetLowering::ArgListTy Args;
1417914193 Args.emplace_back(Ptr, Ptr.getValueType().getTypeForEVT(*getContext()));
14180- RTLIB::Libcall LC = static_cast<RTLIB::Libcall>(LibFunc);
14181- SDValue Callee = getExternalSymbol(TLI->getLibcallName(LC),
14182- TLI->getPointerTy(getDataLayout()));
14194+ RTLIB::LibcallImpl LibcallImpl =
14195+ TLI->getLibcallImpl(static_cast<RTLIB::Libcall>(LibFunc));
14196+ if (LibcallImpl == RTLIB::Unsupported)
14197+ reportFatalUsageError("emitting call to unsupported libcall");
14198+
14199+ SDValue Callee =
14200+ getExternalSymbol(TLI->getLibcallImplName(LibcallImpl).data(),
14201+ TLI->getPointerTy(getDataLayout()));
1418314202 TargetLowering::CallLoweringInfo CLI(*this);
1418414203 CLI.setDebugLoc(DLoc).setChain(InChain).setLibCallee(
14185- TLI->getLibcallCallingConv(LC), Type::getVoidTy(*getContext()), Callee ,
14186- std::move(Args));
14204+ TLI->getLibcallImplCallingConv(LibcallImpl) ,
14205+ Type::getVoidTy(*getContext()), Callee, std::move(Args));
1418714206 return TLI->LowerCallTo(CLI).second;
1418814207}
1418914208
0 commit comments