From 7adacaa098d9ec563d0d80a1e94a7b5b71832349 Mon Sep 17 00:00:00 2001 From: Pavel Kopyl Date: Thu, 16 Mar 2023 03:01:50 +0100 Subject: [PATCH] [NVPTX] Report fatal error on empty argument type. Differential Revision: https://reviews.llvm.org/D146331 --- llvm/lib/Target/NVPTX/NVPTXISelLowering.cpp | 8 ++++++-- llvm/test/CodeGen/NVPTX/empty-type.ll | 10 ++++++++++ 2 files changed, 16 insertions(+), 2 deletions(-) create mode 100644 llvm/test/CodeGen/NVPTX/empty-type.ll diff --git a/llvm/lib/Target/NVPTX/NVPTXISelLowering.cpp b/llvm/lib/Target/NVPTX/NVPTXISelLowering.cpp index 7d6ff72997bb..93f2533bf1d8 100644 --- a/llvm/lib/Target/NVPTX/NVPTXISelLowering.cpp +++ b/llvm/lib/Target/NVPTX/NVPTXISelLowering.cpp @@ -2666,7 +2666,9 @@ SDValue NVPTXTargetLowering::LowerFormalArguments( 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 @@ SDValue NVPTXTargetLowering::LowerFormalArguments( 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 index 000000000000..e5c02f99681c --- /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 +}