https://github.com/arsenm created https://github.com/llvm/llvm-project/pull/170585
Eventually the set of available functions will be a program dependent property, which could diverge from the static table of functions for the subtarget. In that case, fall back to the usual expansion. >From 415468f033df9e813c8c74a6cef51a61603978ea Mon Sep 17 00:00:00 2001 From: Matt Arsenault <[email protected]> Date: Wed, 3 Dec 2025 23:50:44 +0100 Subject: [PATCH] DAG: Avoid asserting on libcall action if function is unavailable Eventually the set of available functions will be a program dependent property, which could diverge from the static table of functions for the subtarget. In that case, fall back to the usual expansion. --- .../SelectionDAG/LegalizeIntegerTypes.cpp | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/llvm/lib/CodeGen/SelectionDAG/LegalizeIntegerTypes.cpp b/llvm/lib/CodeGen/SelectionDAG/LegalizeIntegerTypes.cpp index 94a3386e75394..ac8532d34d0d6 100644 --- a/llvm/lib/CodeGen/SelectionDAG/LegalizeIntegerTypes.cpp +++ b/llvm/lib/CodeGen/SelectionDAG/LegalizeIntegerTypes.cpp @@ -4102,14 +4102,19 @@ void DAGTypeLegalizer::ExpandIntRes_CTPOP(SDNode *N, SDValue &Lo, SDValue &Hi) { if (TLI.getOperationAction(ISD::CTPOP, VT) == TargetLoweringBase::LibCall) { RTLIB::Libcall LC = RTLIB::getCTPOP(VT); - assert(LC != RTLIB::UNKNOWN_LIBCALL && TLI.getLibcallName(LC) && + assert(LC != RTLIB::UNKNOWN_LIBCALL && "LibCall explicitly requested, but not available"); - TargetLowering::MakeLibCallOptions CallOptions; - EVT IntVT = - EVT::getIntegerVT(*DAG.getContext(), DAG.getLibInfo().getIntSize()); - SDValue Res = TLI.makeLibCall(DAG, LC, IntVT, Op, CallOptions, DL).first; - SplitInteger(DAG.getSExtOrTrunc(Res, DL, VT), Lo, Hi); - return; + + if (RTLIB::LibcallImpl LCImpl = TLI.getLibcallImpl(LC)) { + TargetLowering::MakeLibCallOptions CallOptions; + EVT IntVT = + EVT::getIntegerVT(*DAG.getContext(), DAG.getLibInfo().getIntSize()); + SDValue Res = TLI.makeLibCall(DAG, LCImpl, IntVT, Op, CallOptions, DL).first; + SplitInteger(DAG.getSExtOrTrunc(Res, DL, VT), Lo, Hi); + return; + } + + // If the function is not available, fall back on the expansion. } // ctpop(HiLo) -> ctpop(Hi)+ctpop(Lo) _______________________________________________ llvm-branch-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
