-
Notifications
You must be signed in to change notification settings - Fork 13.5k
[AMDGPU] Remove dead function metadata after amdgpu-lower-kernel-arguments #126147
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[AMDGPU] Remove dead function metadata after amdgpu-lower-kernel-arguments #126147
Conversation
This stack of pull requests is managed by Graphite. Learn more about stacking. |
@llvm/pr-subscribers-backend-amdgpu Author: Scott Linder (slinder1) ChangesThe verifier ensures function !dbg metadata is unique across the module, Removing the function via e.g. eraseFromParent seems like a better Full diff: https://github.com/llvm/llvm-project/pull/126147.diff 2 Files Affected:
diff --git a/llvm/lib/Target/AMDGPU/AMDGPULowerKernelArguments.cpp b/llvm/lib/Target/AMDGPU/AMDGPULowerKernelArguments.cpp
index e9d009baa20af2..09412d1b0f1cc9 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 fe110cbcafc465..4b47a218f1be45 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,7 @@
-; 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 | FileCheck %s
-; CHECK: function declaration may only have a unique !dbg attachment
-; CHECK-NEXT: ptr @0
+; CHECK: define amdgpu_kernel void @preload_block_count_x{{.*}} !dbg ![[#]]
+; CHECK-NOT: declare void @0{{.*}} !dbg ![[#]]
define amdgpu_kernel void @preload_block_count_x(ptr addrspace(1) %out) !dbg !4 {
%imp_arg_ptr = call ptr addrspace(4) @llvm.amdgcn.implicitarg.ptr()
|
llvm/test/CodeGen/AMDGPU/preload-implicit-kernargs-debug-info.ll
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This shouldn't be needed after #123547, there are other bugs besides this caused by the leftover declarations.
bc50ff1
to
2fe5d5c
Compare
@@ -1,7 +1,10 @@ | |||
; 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 -implicit-check-not='declare {{.*}} !dbg' %s |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is still a big aggressive for check-not, and I'm not sure it supports regex. Can you simplify to just check-not=declare and explicitly check the few declares that are expected?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I had already double-checked that --implicit-check-not
supports regex (just --implicit-check-not='{{.*}}'
will fail on the first line)
I went that route to avoid the awkward CHECKs for the irrelevant declares of llvm.amdgcn.implicitarg.ptr
and llvm.amdgcn.kernarg.segment.ptr
, but I posted a version with --implicit-check-not=declare
and the extra CHECKs; let me know what you think
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For some reason pushing didn't clear your approval, but I wanted to double check your thoughts on the test change so I re-requested
I am not certain I understand the github interface, but it seems to be saying you approved the latest patch, so I will land and anything else can be resolved post-commit |
…ments 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.
07f4086
to
4c24199
Compare
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.