Skip to content

Commit 1fadeec

Browse files
committed
Move checks int IR Verifier
Move the CUDA address-space checks out of ASMPrinter and into the IR Verifier.
1 parent 02fcf51 commit 1fadeec

File tree

3 files changed

+16
-9
lines changed

3 files changed

+16
-9
lines changed

llvm/lib/IR/Verifier.cpp

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,7 @@
119119
#include "llvm/Support/ErrorHandling.h"
120120
#include "llvm/Support/MathExtras.h"
121121
#include "llvm/Support/ModRef.h"
122+
#include "llvm/Support/NVPTXAddrSpace.h"
122123
#include "llvm/Support/raw_ostream.h"
123124
#include <algorithm>
124125
#include <cassert>
@@ -2927,6 +2928,20 @@ void Verifier::visitFunction(const Function &F) {
29272928
"Calling convention does not support varargs or "
29282929
"perfect forwarding!",
29292930
&F);
2931+
if (F.getCallingConv() == CallingConv::PTX_Kernel &&
2932+
TT.getOS() == Triple::CUDA) {
2933+
for (const Argument &Arg : F.args()) {
2934+
if (Arg.getType()->isPointerTy()) {
2935+
auto AS = Arg.getType()->getPointerAddressSpace();
2936+
Check(AS != NVPTXAS::AddressSpace::ADDRESS_SPACE_SHARED,
2937+
".shared ptr kernel args unsupported in CUDA.", &Arg, &F);
2938+
Check(AS != NVPTXAS::AddressSpace::ADDRESS_SPACE_CONST,
2939+
".const ptr kernel args unsupported in CUDA.", &Arg, &F);
2940+
Check(AS != NVPTXAS::AddressSpace::ADDRESS_SPACE_LOCAL,
2941+
".local ptr kernel args unsupported in CUDA.", &Arg, &F);
2942+
}
2943+
}
2944+
}
29302945
break;
29312946
}
29322947

llvm/lib/Target/NVPTX/NVPTXAsmPrinter.cpp

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1399,27 +1399,19 @@ void NVPTXAsmPrinter::emitFunctionParamList(const Function *F, raw_ostream &O) {
13991399
if (PTy) {
14001400
O << "\t.param .u" << PTySizeInBits << " .ptr";
14011401

1402-
bool IsCUDA = static_cast<NVPTXTargetMachine &>(TM).getDrvInterface() ==
1403-
NVPTX::CUDA;
14041402
switch (PTy->getAddressSpace()) {
14051403
default:
14061404
break;
14071405
case ADDRESS_SPACE_GLOBAL:
14081406
O << " .global";
14091407
break;
14101408
case ADDRESS_SPACE_SHARED:
1411-
if (IsCUDA)
1412-
report_fatal_error(".shared ptr kernel args unsupported in CUDA.");
14131409
O << " .shared";
14141410
break;
14151411
case ADDRESS_SPACE_CONST:
1416-
if (IsCUDA)
1417-
report_fatal_error(".const ptr kernel args unsupported in CUDA.");
14181412
O << " .const";
14191413
break;
14201414
case ADDRESS_SPACE_LOCAL:
1421-
if (IsCUDA)
1422-
report_fatal_error(".local ptr kernel args unsupported in CUDA.");
14231415
O << " .local";
14241416
break;
14251417
}

llvm/test/CodeGen/NVPTX/lower-args-cuda.ll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
; RUN: not --crash llc < %s -mcpu=sm_75 -o /dev/null 2>&1 | FileCheck %s
1+
; RUN: not llc < %s -mcpu=sm_75 -o /dev/null 2>&1 | FileCheck %s
22

33
target datalayout = "e-i64:64-i128:128-v16:16-v32:32-n16:32:64"
44
target triple = "nvptx64-nvidia-cuda"

0 commit comments

Comments
 (0)