@@ -9114,18 +9114,22 @@ std::pair<SDValue, SDValue> SelectionDAG::getStrlen(SDValue Chain,
91149114 TargetLowering::ArgListTy Args = {GetEntry(PT, Src)};
91159115
91169116 TargetLowering::CallLoweringInfo CLI(*this);
9117- bool IsTailCall = false;
9118- bool ReturnsFirstArg = CI && funcReturnsFirstArgOfCall(*CI);
9119- IsTailCall = CI && CI->isTailCall() &&
9120- isInTailCallPosition(*CI, getTarget(), ReturnsFirstArg);
91219117
9122- CLI.setDebugLoc(dl)
9123- .setChain(Chain)
9124- .setLibCallee(
9125- TLI->getLibcallCallingConv(RTLIB::STRLEN), CI->getType(),
9126- getExternalSymbol(LibCallName, TLI->getPointerTy(getDataLayout())),
9127- std::move(Args))
9128- .setTailCall(IsTailCall);
9118+ // TODO: Intentionally not marking this libcall as a tail call.
9119+ //
9120+ // Why:
9121+ // - The only current in-tree user of SelectionDAG::getStrlen is the AIX path,
9122+ // where generic tail-calling to libcalls is not safe due to ABI
9123+ // constraints around r2 (TOC). We don¡¯t have a reliable way to validate a
9124+ // tail call here.
9125+ //
9126+ // If another target starts using this and does support tail calls to
9127+ // libcalls, re-enable `.setTailCall(...)` under a target guard and add a
9128+ // test.
9129+ CLI.setDebugLoc(dl).setChain(Chain).setLibCallee(
9130+ TLI->getLibcallCallingConv(RTLIB::STRLEN), CI->getType(),
9131+ getExternalSymbol(LibCallName, TLI->getProgramPointerTy(getDataLayout())),
9132+ std::move(Args));
91299133
91309134 return TLI->LowerCallTo(CLI);
91319135}
0 commit comments