Skip to content

Commit 284f9f7

Browse files
committed
[OpenCL][NVPTX] Don't set calling convention for OpenCL kernel
1 parent def5899 commit 284f9f7

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

clang/lib/CodeGen/Targets/NVPTX.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -277,7 +277,9 @@ void NVPTXTargetCodeGenInfo::setTargetAttributes(
277277
}
278278
}
279279
// Attach kernel metadata directly if compiling for NVPTX.
280-
if (FD->hasAttr<DeviceKernelAttr>())
280+
// NOTE: Don't set kernel calling convention for handled OpenCL kernel,
281+
// otherwise the stub version of kernel would be incorrect.
282+
if (FD->hasAttr<DeviceKernelAttr>() && !M.getLangOpts().OpenCL)
281283
F->setCallingConv(getDeviceKernelCallingConv());
282284
}
283285

clang/test/CodeGenOpenCL/ptx-calls.cl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ void device_function() {
1212
// CHECK-LABEL: define dso_local ptx_kernel void @kernel_function(
1313
// CHECK-SAME: ) local_unnamed_addr #[[ATTR1:[0-9]+]] !kernel_arg_addr_space [[META7:![0-9]+]] !kernel_arg_access_qual [[META7]] !kernel_arg_type [[META7]] !kernel_arg_base_type [[META7]] !kernel_arg_type_qual [[META7]] {
1414
// CHECK-NEXT: [[ENTRY:.*:]]
15-
// CHECK-NEXT: unreachable
15+
// CHECK-NEXT: ret void
1616
//
1717
__kernel void kernel_function() {
1818
device_function();

0 commit comments

Comments
 (0)