]> granicus.if.org Git - clang/commitdiff
[AMDGPU] Enable the implicit arguments for HIP (CLANG)
authorYaxun Liu <Yaxun.Liu@amd.com>
Fri, 14 Jun 2019 15:54:47 +0000 (15:54 +0000)
committerYaxun Liu <Yaxun.Liu@amd.com>
Fri, 14 Jun 2019 15:54:47 +0000 (15:54 +0000)
Enable 48-bytes of implicit arguments for HIP as well. Earlier it was enabled for OpenCL. This code is specific to AMDGPU target.

Differential Revision: https://reviews.llvm.org/D62244

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@363414 91177308-0d34-0410-b5e6-96231b3b80d8

lib/CodeGen/TargetInfo.cpp
test/CodeGenCUDA/amdgpu-hip-implicit-kernarg.cu [new file with mode: 0644]

index f39764d1a46d6a2559651272b4b4e60f9d9be847..4ef57786f44e88e1c3eb158d2496f48a47e734d6 100644 (file)
@@ -7868,7 +7868,8 @@ void AMDGPUTargetCodeGenInfo::setTargetAttributes(
   const auto *ReqdWGS = M.getLangOpts().OpenCL ?
     FD->getAttr<ReqdWorkGroupSizeAttr>() : nullptr;
 
-  if (M.getLangOpts().OpenCL && FD->hasAttr<OpenCLKernelAttr>() &&
+  if (((M.getLangOpts().OpenCL && FD->hasAttr<OpenCLKernelAttr>()) ||
+      (M.getLangOpts().HIP && FD->hasAttr<CUDAGlobalAttr>())) &&
       (M.getTriple().getOS() == llvm::Triple::AMDHSA))
     F->addFnAttr("amdgpu-implicitarg-num-bytes", "48");
 
diff --git a/test/CodeGenCUDA/amdgpu-hip-implicit-kernarg.cu b/test/CodeGenCUDA/amdgpu-hip-implicit-kernarg.cu
new file mode 100644 (file)
index 0000000..8f730ac
--- /dev/null
@@ -0,0 +1,8 @@
+// REQUIRES: amdgpu-registered-target
+// RUN: %clang_cc1 -triple amdgcn-amd-amdhsa -fcuda-is-device -emit-llvm -x hip -o - %s | FileCheck %s
+#include "Inputs/cuda.h"
+
+__global__ void hip_kernel_temp() {
+}
+
+// CHECK: attributes {{.*}} = {{.*}} "amdgpu-implicitarg-num-bytes"="48"