Skip to content
Closed
1 change: 0 additions & 1 deletion llvm/lib/Target/NVPTX/NVPTXAsmPrinter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1597,7 +1597,6 @@ void NVPTXAsmPrinter::emitFunctionParamList(const Function *F, raw_ostream &O) {
// CUDA kernels assume that pointers are in global address space
// See:
// https://docs.nvidia.com/cuda/parallel-thread-execution/index.html#parameter-state-space
assert(addrSpace == 0 && "Invalid address space");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this assertion is still (partially?) valid. The only case when we want to emit .global is if the pointer is generic or explicitly in the global AS.

O << ".ptr .global ";
if (I->getParamAlign().valueOrOne() != 1) {
Align ParamAlign = I->getParamAlign().value();
Expand Down
2 changes: 1 addition & 1 deletion llvm/test/CodeGen/NVPTX/i1-param.ll
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ target triple = "nvptx-nvidia-cuda"

; CHECK: .entry foo
; CHECK: .param .u8 foo_param_0
; CHECK: .param .u64 foo_param_1
; CHECK: .param .u64 .ptr .global foo_param_1
define void @foo(i1 %p, ptr %out) {
%val = zext i1 %p to i32
store i32 %val, ptr %out
Expand Down
2 changes: 1 addition & 1 deletion llvm/test/CodeGen/NVPTX/kernel-param-align.ll
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
; CHECK-LABEL: func_align
; CHECK: .param .u64 .ptr .global .align 16 func_align_param_0,
; CHECK: .param .u64 .ptr .global func_align_param_1,
; CHECK: .param .u64 .ptr .global func_align_param_2
; CHECK: .param .u32 .ptr .global func_align_param_2
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is still wrong. addrspace(3) is not a global pointer. It's a shared AS pointer.

Speaking of which, please also add a test for explicitly annotated const and global AS pointers.

define void @func_align(ptr nocapture readonly align 16 %input, ptr nocapture %out, ptr addrspace(3) %n) {
entry:
%0 = addrspacecast ptr %out to ptr addrspace(1)
Expand Down