Skip to content

Commit 15a9706

Browse files
arsenmkcloudy0717
authored andcommitted
DAG: Avoid using getLibcallName when looking for a divrem call (llvm#170413)
Also introduce an error if it's not available, which is not yet testable.
1 parent f022347 commit 15a9706

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2381,8 +2381,19 @@ SelectionDAGLegalize::ExpandDivRemLibCall(SDNode *Node,
23812381
Entry.IsZExt = !isSigned;
23822382
Args.push_back(Entry);
23832383

2384-
SDValue Callee = DAG.getExternalSymbol(TLI.getLibcallName(LC),
2385-
TLI.getPointerTy(DAG.getDataLayout()));
2384+
RTLIB::LibcallImpl LibcallImpl = TLI.getLibcallImpl(LC);
2385+
if (LibcallImpl == RTLIB::Unsupported) {
2386+
DAG.getContext()->emitError(Twine("no libcall available for ") +
2387+
Node->getOperationName(&DAG));
2388+
SDValue Poison = DAG.getPOISON(RetVT);
2389+
Results.push_back(Poison);
2390+
Results.push_back(Poison);
2391+
return;
2392+
}
2393+
2394+
SDValue Callee =
2395+
DAG.getExternalSymbol(TLI.getLibcallImplName(LibcallImpl).data(),
2396+
TLI.getPointerTy(DAG.getDataLayout()));
23862397

23872398
SDLoc dl(Node);
23882399
TargetLowering::CallLoweringInfo CLI(DAG);

0 commit comments

Comments
 (0)