Skip to content

Commit

Permalink
[NVPTX] Report fatal error on empty argument type.
Browse files Browse the repository at this point in the history
Differential Revision: https://reviews.llvm.org/D146331
  • Loading branch information
PavelKopyl committed Mar 18, 2023
1 parent 93c1a5f commit 7adacaa
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
8 changes: 6 additions & 2 deletions llvm/lib/Target/NVPTX/NVPTXISelLowering.cpp
Expand Up @@ -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));
Expand Down Expand Up @@ -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));

Expand Down
10 changes: 10 additions & 0 deletions 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
}

0 comments on commit 7adacaa

Please sign in to comment.