[llvm] [AMDGPU] Do not print `kernel-resource-usage` information on non-kernels (PR #99720)
Joseph Huber via llvm-commits
llvm-commits at lists.llvm.org
Sat Jul 20 05:34:31 PDT 2024
https://github.com/jhuber6 updated https://github.com/llvm/llvm-project/pull/99720
>From 89ad91927b8e9b9538193e6bc699b0f45abd8195 Mon Sep 17 00:00:00 2001
From: Joseph Huber <huberjn at outlook.com>
Date: Fri, 19 Jul 2024 18:49:23 -0500
Subject: [PATCH 1/3] [AMDGPU] Do not print `kernel-resource-usage` information
on non-kernels
Summary:
This pass is used to get helpful information about the kernel resources
without needing to insepct the binary. However, it currently prints on
every function. These values will always be zero, so it's just spam on
the terminal, at best an indication that a function wasn't internalized
/ optimized out. This patch makes it only print for kernels to make it
more useful in practice.
---
llvm/lib/Target/AMDGPU/AMDGPUAsmPrinter.cpp | 4 ++++
.../AMDGPU/resource-optimization-remarks.ll | 21 ++-----------------
2 files changed, 6 insertions(+), 19 deletions(-)
diff --git a/llvm/lib/Target/AMDGPU/AMDGPUAsmPrinter.cpp b/llvm/lib/Target/AMDGPU/AMDGPUAsmPrinter.cpp
index 3154dc6fe433d..be338962e858b 100644
--- a/llvm/lib/Target/AMDGPU/AMDGPUAsmPrinter.cpp
+++ b/llvm/lib/Target/AMDGPU/AMDGPUAsmPrinter.cpp
@@ -1487,6 +1487,10 @@ void AMDGPUAsmPrinter::emitResourceUsageRemarks(
if (!Ctx.getDiagHandlerPtr()->isAnalysisRemarkEnabled(Name))
return;
+ // Currently non-kernel functions have no resources to emit.
+ if (MF.getFunction().getCallingConv() != CallingConv::AMDGPU_KERNEL)
+ return;
+
auto EmitResourceUsageRemark = [&](StringRef RemarkName,
StringRef RemarkLabel, auto Argument) {
// Add an indent for every line besides the line with the kernel name. This
diff --git a/llvm/test/CodeGen/AMDGPU/resource-optimization-remarks.ll b/llvm/test/CodeGen/AMDGPU/resource-optimization-remarks.ll
index a640ac985ade4..7da89c335157a 100644
--- a/llvm/test/CodeGen/AMDGPU/resource-optimization-remarks.ll
+++ b/llvm/test/CodeGen/AMDGPU/resource-optimization-remarks.ll
@@ -113,16 +113,7 @@ define amdgpu_kernel void @test_kernel() !dbg !3 {
ret void
}
-; STDERR: remark: foo.cl:42:0: Function Name: test_func
-; STDERR-NEXT: remark: foo.cl:42:0: SGPRs: 0
-; STDERR-NEXT: remark: foo.cl:42:0: VGPRs: 0
-; STDERR-NEXT: remark: foo.cl:42:0: AGPRs: 0
-; STDERR-NEXT: remark: foo.cl:42:0: ScratchSize [bytes/lane]: 0
-; STDERR-NEXT: remark: foo.cl:42:0: Dynamic Stack: False
-; STDERR-NEXT: remark: foo.cl:42:0: Occupancy [waves/SIMD]: 0
-; STDERR-NEXT: remark: foo.cl:42:0: SGPRs Spill: 0
-; STDERR-NEXT: remark: foo.cl:42:0: VGPRs Spill: 0
-; STDERR-NOT: LDS Size
+; STDERR-NOT: remark: foo.cl:42:0: Function Name: test_func
define void @test_func() !dbg !6 {
call void asm sideeffect "; clobber v17", "~{v17}"()
call void asm sideeffect "; clobber s11", "~{s11}"()
@@ -144,15 +135,7 @@ define amdgpu_kernel void @empty_kernel() !dbg !7 {
ret void
}
-; STDERR: remark: foo.cl:52:0: Function Name: empty_func
-; STDERR-NEXT: remark: foo.cl:52:0: SGPRs: 0
-; STDERR-NEXT: remark: foo.cl:52:0: VGPRs: 0
-; STDERR-NEXT: remark: foo.cl:52:0: AGPRs: 0
-; STDERR-NEXT: remark: foo.cl:52:0: ScratchSize [bytes/lane]: 0
-; STDERR-NEXT: remark: foo.cl:52:0: Dynamic Stack: False
-; STDERR-NEXT: remark: foo.cl:52:0: Occupancy [waves/SIMD]: 0
-; STDERR-NEXT: remark: foo.cl:52:0: SGPRs Spill: 0
-; STDERR-NEXT: remark: foo.cl:52:0: VGPRs Spill: 0
+; STDERR-NOT: remark: foo.cl:52:0: Function Name: empty_func
define void @empty_func() !dbg !8 {
ret void
}
>From 79e481e5e8c15968a6f8c57ca5f68129e1cf08f2 Mon Sep 17 00:00:00 2001
From: Joseph Huber <huberjn at outlook.com>
Date: Sat, 20 Jul 2024 07:22:20 -0500
Subject: [PATCH 2/3] Update llvm/lib/Target/AMDGPU/AMDGPUAsmPrinter.cpp
---
llvm/lib/Target/AMDGPU/AMDGPUAsmPrinter.cpp | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/llvm/lib/Target/AMDGPU/AMDGPUAsmPrinter.cpp b/llvm/lib/Target/AMDGPU/AMDGPUAsmPrinter.cpp
index be338962e858b..e64e28e01d3d1 100644
--- a/llvm/lib/Target/AMDGPU/AMDGPUAsmPrinter.cpp
+++ b/llvm/lib/Target/AMDGPU/AMDGPUAsmPrinter.cpp
@@ -1488,7 +1488,7 @@ void AMDGPUAsmPrinter::emitResourceUsageRemarks(
return;
// Currently non-kernel functions have no resources to emit.
- if (MF.getFunction().getCallingConv() != CallingConv::AMDGPU_KERNEL)
+ if (!isEntryFunctionCC(MF.getFunction().getCallingConv()))
return;
auto EmitResourceUsageRemark = [&](StringRef RemarkName,
>From b131c93ee8d4154acd87e8c6cbfcce66f5883562 Mon Sep 17 00:00:00 2001
From: Joseph Huber <huberjn at outlook.com>
Date: Sat, 20 Jul 2024 07:34:21 -0500
Subject: [PATCH 3/3] Update
llvm/test/CodeGen/AMDGPU/resource-optimization-remarks.ll
---
llvm/test/CodeGen/AMDGPU/resource-optimization-remarks.ll | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/llvm/test/CodeGen/AMDGPU/resource-optimization-remarks.ll b/llvm/test/CodeGen/AMDGPU/resource-optimization-remarks.ll
index 7da89c335157a..17023f95b457a 100644
--- a/llvm/test/CodeGen/AMDGPU/resource-optimization-remarks.ll
+++ b/llvm/test/CodeGen/AMDGPU/resource-optimization-remarks.ll
@@ -135,7 +135,7 @@ define amdgpu_kernel void @empty_kernel() !dbg !7 {
ret void
}
-; STDERR-NOT: remark: foo.cl:52:0: Function Name: empty_func
+; STDERR-NOT: empty_func
define void @empty_func() !dbg !8 {
ret void
}
More information about the llvm-commits
mailing list