[PATCH] D55145: [NVPTX] Lower instructions that expands into libcalls
Artem Belevich via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Dec 14 15:56:39 PST 2018
This revision was automatically updated to reflect the committed changes.
Closed by commit rL349213: [NVPTX] Lower instructions that expand into libcalls. (authored by tra, committed by ).
Herald added a subscriber: llvm-commits.
Changed prior to commit:
https://reviews.llvm.org/D55145?vs=178299&id=178312#toc
Repository:
rL LLVM
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D55145/new/
https://reviews.llvm.org/D55145
Files:
llvm/trunk/lib/Target/NVPTX/NVPTXISelLowering.cpp
llvm/trunk/test/CodeGen/NVPTX/libcall-instruction.ll
Index: llvm/trunk/test/CodeGen/NVPTX/libcall-instruction.ll
===================================================================
--- llvm/trunk/test/CodeGen/NVPTX/libcall-instruction.ll
+++ llvm/trunk/test/CodeGen/NVPTX/libcall-instruction.ll
@@ -0,0 +1,8 @@
+; RUN: not llc < %s -march=nvptx 2>&1 | FileCheck %s
+; used to panic on failed assetion and now fails with a "Cannot select"
+
+; CHECK: LLVM ERROR: Cannot select: {{t28|0x[0-9a-f]+}}: i32 = ExternalSymbol'__umodti3'
+define hidden i128 @remainder(i128, i128) {
+ %3 = urem i128 %0, %1
+ ret i128 %3
+}
Index: llvm/trunk/lib/Target/NVPTX/NVPTXISelLowering.cpp
===================================================================
--- llvm/trunk/lib/Target/NVPTX/NVPTXISelLowering.cpp
+++ llvm/trunk/lib/Target/NVPTX/NVPTXISelLowering.cpp
@@ -1661,7 +1661,12 @@
}
}
- if (!Func) {
+ // Both indirect calls and libcalls have nullptr Func. In order to distinguish
+ // between them we must rely on the call site value which is valid for
+ // indirect calls but is always null for libcalls.
+ bool isIndirectCall = !Func && CS;
+
+ if (isIndirectCall) {
// This is indirect function call case : PTX requires a prototype of the
// form
// proto_0 : .callprototype(.param .b32 _) _ (.param .b32 _);
@@ -1685,7 +1690,7 @@
Chain, DAG.getConstant((Ins.size() == 0) ? 0 : 1, dl, MVT::i32), InFlag
};
// We model convergent calls as separate opcodes.
- unsigned Opcode = Func ? NVPTXISD::PrintCallUni : NVPTXISD::PrintCall;
+ unsigned Opcode = isIndirectCall ? NVPTXISD::PrintCall : NVPTXISD::PrintCallUni;
if (CLI.IsConvergent)
Opcode = Opcode == NVPTXISD::PrintCallUni ? NVPTXISD::PrintConvergentCallUni
: NVPTXISD::PrintConvergentCall;
@@ -1719,12 +1724,12 @@
}
SDVTList CallArgEndVTs = DAG.getVTList(MVT::Other, MVT::Glue);
SDValue CallArgEndOps[] = { Chain,
- DAG.getConstant(Func ? 1 : 0, dl, MVT::i32),
+ DAG.getConstant(isIndirectCall ? 0 : 1, dl, MVT::i32),
InFlag };
Chain = DAG.getNode(NVPTXISD::CallArgEnd, dl, CallArgEndVTs, CallArgEndOps);
InFlag = Chain.getValue(1);
- if (!Func) {
+ if (isIndirectCall) {
SDVTList PrototypeVTs = DAG.getVTList(MVT::Other, MVT::Glue);
SDValue PrototypeOps[] = { Chain,
DAG.getConstant(uniqueCallSite, dl, MVT::i32),
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D55145.178312.patch
Type: text/x-patch
Size: 2462 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20181214/b26338d7/attachment.bin>
More information about the llvm-commits
mailing list