diff --git a/llvm/lib/Target/NVPTX/NVPTXISelLowering.cpp b/llvm/lib/Target/NVPTX/NVPTXISelLowering.cpp --- a/llvm/lib/Target/NVPTX/NVPTXISelLowering.cpp +++ b/llvm/lib/Target/NVPTX/NVPTXISelLowering.cpp @@ -2666,7 +2666,9 @@ SmallVector 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 @@ SmallVector VTs; SmallVector 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 --- /dev/null +++ b/llvm/test/CodeGen/NVPTX/empty-type.ll @@ -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 +}