Skip to content

Commit bc50ff1

Browse files
committed
[AMDGPU] Remove dead function metadata after amdgpu-lower-kernel-arguments
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 8a46437 commit bc50ff1

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-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: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
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 | FileCheck %s
22

3-
; CHECK: function declaration may only have a unique !dbg attachment
4-
; CHECK-NEXT: ptr @0
3+
; CHECK: define amdgpu_kernel void @preload_block_count_x{{.*}} !dbg ![[#]]
4+
; CHECK-NOT: declare void @0{{.*}} !dbg ![[#]]
55

66
define amdgpu_kernel void @preload_block_count_x(ptr addrspace(1) %out) !dbg !4 {
77
%imp_arg_ptr = call ptr addrspace(4) @llvm.amdgcn.implicitarg.ptr()

0 commit comments

Comments
 (0)