[llvm] eaa460c - [AMDGPU] Remove dead function metadata after amdgpu-lower-kernel-arguments (#126147)

via llvm-commits llvm-commits at lists.llvm.org
Mon Feb 17 10:27:26 PST 2025


Author: Scott Linder
Date: 2025-02-17T13:27:23-05:00
New Revision: eaa460ca499bec0547393bae7c18b128c2926839

URL: https://github.com/llvm/llvm-project/commit/eaa460ca499bec0547393bae7c18b128c2926839
DIFF: https://github.com/llvm/llvm-project/commit/eaa460ca499bec0547393bae7c18b128c2926839.diff

LOG: [AMDGPU] Remove dead function metadata after amdgpu-lower-kernel-arguments (#126147)

The verifier ensures function !dbg metadata is unique across the module,
so ensure the old nameless function we leave behind doesn't violate
this invariant.

Removing the function via e.g. eraseFromParent seems like a better
option, but doesn't seem to be legal from a FunctionPass.

Added: 
    

Modified: 
    llvm/lib/Target/AMDGPU/AMDGPULowerKernelArguments.cpp
    llvm/test/CodeGen/AMDGPU/preload-implicit-kernargs-debug-info.ll

Removed: 
    


################################################################################
diff  --git a/llvm/lib/Target/AMDGPU/AMDGPULowerKernelArguments.cpp b/llvm/lib/Target/AMDGPU/AMDGPULowerKernelArguments.cpp
index e9d009baa20af..09412d1b0f1cc 100644
--- a/llvm/lib/Target/AMDGPU/AMDGPULowerKernelArguments.cpp
+++ b/llvm/lib/Target/AMDGPU/AMDGPULowerKernelArguments.cpp
@@ -132,6 +132,7 @@ class PreloadKernelArgInfo {
     NF->setAttributes(AL);
     F.replaceAllUsesWith(NF);
     F.setCallingConv(CallingConv::C);
+    F.clearMetadata();
 
     return NF;
   }

diff  --git a/llvm/test/CodeGen/AMDGPU/preload-implicit-kernargs-debug-info.ll b/llvm/test/CodeGen/AMDGPU/preload-implicit-kernargs-debug-info.ll
index a6a0b88dce125..b008f397318e8 100644
--- a/llvm/test/CodeGen/AMDGPU/preload-implicit-kernargs-debug-info.ll
+++ b/llvm/test/CodeGen/AMDGPU/preload-implicit-kernargs-debug-info.ll
@@ -1,7 +1,13 @@
-; RUN: not --crash opt -mtriple=amdgcn-amd-amdhsa -mcpu=gfx940 -passes='amdgpu-attributor,function(amdgpu-lower-kernel-arguments)' -amdgpu-kernarg-preload-count=16 -S < %s 2>&1 | FileCheck %s
+; RUN: opt -mtriple=amdgcn-amd-amdhsa -mcpu=gfx940 -passes='amdgpu-attributor,function(amdgpu-lower-kernel-arguments)' -amdgpu-kernarg-preload-count=16 -S < %s 2>&1 \
+; RUN: | FileCheck --match-full-lines --implicit-check-not='declare' %s
 
-; CHECK: function declaration may only have a unique !dbg attachment
-; CHECK-NEXT: ptr @0
+; Confirms we do not leave behind a declaration which references the same
+; DISubprogram metadata.
+
+; CHECK: define amdgpu_kernel void @preload_block_count_x{{.*}} !dbg ![[#]] !max_work_group_size ![[#]] {
+; CHECK: declare void @0{{.*}} #[[#]]
+; CHECK: declare noundef align 4 ptr addrspace(4) @llvm.amdgcn.implicitarg.ptr() #[[#]]
+; CHECK: declare noundef align 4 ptr addrspace(4) @llvm.amdgcn.kernarg.segment.ptr() #[[#]]
 
 define amdgpu_kernel void @preload_block_count_x(ptr addrspace(1) %out) !dbg !4 !max_work_group_size !7 {
   %imp_arg_ptr = call ptr addrspace(4) @llvm.amdgcn.implicitarg.ptr()


        


More information about the llvm-commits mailing list