Skip to content

Commit eaa460c

Browse files
authored
[AMDGPU] Remove dead function metadata after amdgpu-lower-kernel-arguments (llvm#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.
1 parent 941f7cb commit eaa460c

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

llvm/lib/Target/AMDGPU/AMDGPULowerKernelArguments.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,7 @@ class PreloadKernelArgInfo {
132132
NF->setAttributes(AL);
133133
F.replaceAllUsesWith(NF);
134134
F.setCallingConv(CallingConv::C);
135+
F.clearMetadata();
135136

136137
return NF;
137138
}

llvm/test/CodeGen/AMDGPU/preload-implicit-kernargs-debug-info.ll

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,13 @@
1-
; 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
1+
; 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 \
2+
; RUN: | FileCheck --match-full-lines --implicit-check-not='declare' %s
23

3-
; CHECK: function declaration may only have a unique !dbg attachment
4-
; CHECK-NEXT: ptr @0
4+
; Confirms we do not leave behind a declaration which references the same
5+
; DISubprogram metadata.
6+
7+
; CHECK: define amdgpu_kernel void @preload_block_count_x{{.*}} !dbg ![[#]] !max_work_group_size ![[#]] {
8+
; CHECK: declare void @0{{.*}} #[[#]]
9+
; CHECK: declare noundef align 4 ptr addrspace(4) @llvm.amdgcn.implicitarg.ptr() #[[#]]
10+
; CHECK: declare noundef align 4 ptr addrspace(4) @llvm.amdgcn.kernarg.segment.ptr() #[[#]]
511

612
define amdgpu_kernel void @preload_block_count_x(ptr addrspace(1) %out) !dbg !4 !max_work_group_size !7 {
713
%imp_arg_ptr = call ptr addrspace(4) @llvm.amdgcn.implicitarg.ptr()

0 commit comments

Comments
 (0)