llvm.org GIT mirror llvm / fb3de31
[NVPTX] Lower instructions that expand into libcalls. The change is an effort to split and refactor abandoned D34708 into smaller parts. Here the behaviour of unsupported instructions is changed to match the behaviour of explicit intrinsics calls. Currently LLVM crashes with: > Assertion getInstruction() && "Not a call or invoke instruction!" failed. With this patch LLVM produces a more sensible error message: > Cannot select: ... i32 = ExternalSymbol'__foobar' Author: Denys Zariaiev <denys.zariaiev@gmail.com> Differential Revision: https://reviews.llvm.org/D55145 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@349213 91177308-0d34-0410-b5e6-96231b3b80d8 Artem Belevich 1 year, 10 months ago
2 changed file(s) with 17 addition(s) and 4 deletion(s). Raw diff Collapse all Expand all
16601660 }
16611661 }
16621662
1663 if (!Func) {
1663 // Both indirect calls and libcalls have nullptr Func. In order to distinguish
1664 // between them we must rely on the call site value which is valid for
1665 // indirect calls but is always null for libcalls.
1666 bool isIndirectCall = !Func && CS;
1667
1668 if (isIndirectCall) {
16641669 // This is indirect function call case : PTX requires a prototype of the
16651670 // form
16661671 // proto_0 : .callprototype(.param .b32 _) _ (.param .b32 _);
16841689 Chain, DAG.getConstant((Ins.size() == 0) ? 0 : 1, dl, MVT::i32), InFlag
16851690 };
16861691 // We model convergent calls as separate opcodes.
1687 unsigned Opcode = Func ? NVPTXISD::PrintCallUni : NVPTXISD::PrintCall;
1692 unsigned Opcode = isIndirectCall ? NVPTXISD::PrintCall : NVPTXISD::PrintCallUni;
16881693 if (CLI.IsConvergent)
16891694 Opcode = Opcode == NVPTXISD::PrintCallUni ? NVPTXISD::PrintConvergentCallUni
16901695 : NVPTXISD::PrintConvergentCall;
17181723 }
17191724 SDVTList CallArgEndVTs = DAG.getVTList(MVT::Other, MVT::Glue);
17201725 SDValue CallArgEndOps[] = { Chain,
1721 DAG.getConstant(Func ? 1 : 0, dl, MVT::i32),
1726 DAG.getConstant(isIndirectCall ? 0 : 1, dl, MVT::i32),
17221727 InFlag };
17231728 Chain = DAG.getNode(NVPTXISD::CallArgEnd, dl, CallArgEndVTs, CallArgEndOps);
17241729 InFlag = Chain.getValue(1);
17251730
1726 if (!Func) {
1731 if (isIndirectCall) {
17271732 SDVTList PrototypeVTs = DAG.getVTList(MVT::Other, MVT::Glue);
17281733 SDValue PrototypeOps[] = { Chain,
17291734 DAG.getConstant(uniqueCallSite, dl, MVT::i32),
0 ; RUN: not llc < %s -march=nvptx 2>&1 | FileCheck %s
1 ; used to panic on failed assetion and now fails with a "Cannot select"
2
3 ; CHECK: LLVM ERROR: Cannot select: {{t28|0x[0-9a-f]+}}: i32 = ExternalSymbol'__umodti3'
4 define hidden i128 @remainder(i128, i128) {
5 %3 = urem i128 %0, %1
6 ret i128 %3
7 }