瀏覽代碼

[HIP] change kernel stub name

Add .stub to kernel stub function name so that it is different from kernel
name in device code. This is necessary to let debugger find correct symbol
for kernel

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


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@354615 91177308-0d34-0410-b5e6-96231b3b80d8
Yaxun Liu 6 年之前
父節點
當前提交
1acb1c592b
共有 2 個文件被更改,包括 8 次插入1 次删除
  1. 6 0
      lib/CodeGen/CGCUDANV.cpp
  2. 2 1
      test/CodeGenCUDA/device-stub.cu

+ 6 - 0
lib/CodeGen/CGCUDANV.cpp

@@ -227,6 +227,12 @@ void CGNVCUDARuntime::emitDeviceStub(CodeGenFunction &CGF,
     emitDeviceStubBodyNew(CGF, Args);
     emitDeviceStubBodyNew(CGF, Args);
   else
   else
     emitDeviceStubBodyLegacy(CGF, Args);
     emitDeviceStubBodyLegacy(CGF, Args);
+
+  // Postfix kernel stub names with .stub to differentiate them from kernel
+  // names in device binaries. This is to facilitate the debugger to find
+  // the correct symbols for kernels in the device binary.
+  if (CGF.getLangOpts().HIP)
+    CGF.CurFn->setName(CGF.CurFn->getName() + ".stub");
 }
 }
 
 
 // CUDA 9.0+ uses new way to launch kernels. Parameters are packed in a local
 // CUDA 9.0+ uses new way to launch kernels. Parameters are packed in a local

+ 2 - 1
test/CodeGenCUDA/device-stub.cu

@@ -145,7 +145,8 @@ void use_pointers() {
 // Test that we build the correct number of calls to cudaSetupArgument followed
 // Test that we build the correct number of calls to cudaSetupArgument followed
 // by a call to cudaLaunch.
 // by a call to cudaLaunch.
 
 
-// LNX: define{{.*}}kernelfunc
+// CUDA-LABEL: define{{.*}}kernelfunc
+// HIP-LABEL: define{{.*}}@_Z10kernelfunciii.stub
 
 
 // New launch sequence stores arguments into local buffer and passes array of
 // New launch sequence stores arguments into local buffer and passes array of
 // pointers to them directly to cudaLaunchKernel
 // pointers to them directly to cudaLaunchKernel