[NVPTX] Report fatal error on empty argument type.
authorPavel Kopyl <pavelkopyl@gmail.com>
Thu, 16 Mar 2023 02:01:50 +0000 (03:01 +0100)
committerPavel Kopyl <pavelkopyl@gmail.com>
Sat, 18 Mar 2023 00:27:43 +0000 (01:27 +0100)
Differential Revision: https://reviews.llvm.org/D146331

llvm/lib/Target/NVPTX/NVPTXISelLowering.cpp
llvm/test/CodeGen/NVPTX/empty-type.ll [new file with mode: 0644]

index 7d6ff72..93f2533 100644 (file)
@@ -2666,7 +2666,9 @@ SDValue NVPTXTargetLowering::LowerFormalArguments(
         SmallVector<EVT, 16> vtparts;
 
         ComputePTXValueVTs(*this, DAG.getDataLayout(), Ty, vtparts);
-        assert(vtparts.size() > 0 && "empty aggregate type not expected");
+        if (vtparts.empty())
+          report_fatal_error("Empty parameter types are not supported");
+
         for (unsigned parti = 0, parte = vtparts.size(); parti != parte;
              ++parti) {
           InVals.push_back(DAG.getNode(ISD::UNDEF, dl, Ins[InsIdx].VT));
@@ -2703,7 +2705,9 @@ SDValue NVPTXTargetLowering::LowerFormalArguments(
       SmallVector<EVT, 16> VTs;
       SmallVector<uint64_t, 16> Offsets;
       ComputePTXValueVTs(*this, DL, Ty, VTs, &Offsets, 0);
-      assert(VTs.size() > 0 && "Unexpected empty type.");
+      if (VTs.empty())
+        report_fatal_error("Empty parameter types are not supported");
+
       auto VectorInfo =
           VectorizePTXValueVTs(VTs, Offsets, DL.getABITypeAlign(Ty));
 
diff --git a/llvm/test/CodeGen/NVPTX/empty-type.ll b/llvm/test/CodeGen/NVPTX/empty-type.ll
new file mode 100644 (file)
index 0000000..e5c02f9
--- /dev/null
@@ -0,0 +1,10 @@
+; RUN: not --crash llc < %s -march=nvptx -mcpu=sm_20 2>&1 | FileCheck %s
+
+%struct.A = type { [0 x float] }
+%struct.B = type { i32, i32 }
+
+; CHECK: ERROR: Empty parameter types are not supported
+define void @kernel(%struct.A %a, %struct.B %b) {
+entry:
+  ret void
+}