[PATCH] D156040: [AMDGPU] Add dynamic stack bit info to kernel-resource-usage Rpass output

2023-07-25 Thread Corbin Robeck via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG7a4968b5a378: [AMDGPU] Add dynamic stack bit info to 
kernel-resource-usage Rpass output (authored by crobeck).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D156040/new/

https://reviews.llvm.org/D156040

Files:
  clang/test/Frontend/amdgcn-machine-analysis-remarks.cl
  llvm/lib/Target/AMDGPU/AMDGPUAsmPrinter.cpp
  llvm/test/CodeGen/AMDGPU/resource-optimization-remarks.ll

Index: llvm/test/CodeGen/AMDGPU/resource-optimization-remarks.ll
===
--- llvm/test/CodeGen/AMDGPU/resource-optimization-remarks.ll
+++ llvm/test/CodeGen/AMDGPU/resource-optimization-remarks.ll
@@ -1,4 +1,4 @@
-; RUN: llc -mtriple=amdgcn-amd-amdhsa -mcpu=gfx908 -pass-remarks-output=%t -pass-remarks-analysis=kernel-resource-usage -filetype=obj -o /dev/null %s 2>&1 | FileCheck -check-prefix=STDERR %s
+; RUN: llc -mtriple=amdgcn-amd-amdhsa -mcpu=gfx908 -pass-remarks-output=%t -pass-remarks-analysis=kernel-resource-usage -filetype=null %s 2>&1 | FileCheck -check-prefix=STDERR %s
 ; RUN: FileCheck -check-prefix=REMARK %s < %t
 
 ; STDERR: remark: foo.cl:27:0: Function Name: test_kernel
@@ -6,6 +6,7 @@
 ; STDERR-NEXT: remark: foo.cl:27:0: VGPRs: 9
 ; STDERR-NEXT: remark: foo.cl:27:0: AGPRs: 43
 ; STDERR-NEXT: remark: foo.cl:27:0: ScratchSize [bytes/lane]: 0
+; STDERR-NEXT: remark: foo.cl:27:0: Dynamic Stack: False
 ; STDERR-NEXT: remark: foo.cl:27:0: Occupancy [waves/SIMD]: 5
 ; STDERR-NEXT: remark: foo.cl:27:0: SGPRs Spill: 0
 ; STDERR-NEXT: remark: foo.cl:27:0: VGPRs Spill: 0
@@ -55,7 +56,16 @@
 ; REMARK-NEXT: Args:
 ; REMARK-NEXT:   - String:  'ScratchSize [bytes/lane]: '
 ; REMARK-NEXT:   - ScratchSize: '0'
-; REMARK-NEXT: ...
+; REMARK-NEXT: ..
+; REMARK-NEXT: --- !Analysis
+; REMARK-NEXT: Pass:kernel-resource-usage
+; REMARK-NEXT: Name:DynamicStack
+; REMARK-NEXT: DebugLoc:{ File: foo.cl, Line: 27, Column: 0 }
+; REMARK-NEXT: Function:test_kernel
+; REMARK-NEXT: Args:
+; REMARK-NEXT:   - String: ' Dynamic Stack: 
+; REMARK-NEXT:   - DynamicStack: 'False' 
+; REMARK-NEXT: ..
 ; REMARK-NEXT: --- !Analysis
 ; REMARK-NEXT: Pass:kernel-resource-usage
 ; REMARK-NEXT: Name:Occupancy
@@ -108,6 +118,7 @@
 ; 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
@@ -124,6 +135,7 @@
 ; STDERR-NEXT: remark: foo.cl:8:0: VGPRs: 0
 ; STDERR-NEXT: remark: foo.cl:8:0: AGPRs: 0
 ; STDERR-NEXT: remark: foo.cl:8:0: ScratchSize [bytes/lane]: 0
+; STDERR-NEXT: remark: foo.cl:8:0: Dynamic Stack: False
 ; STDERR-NEXT: remark: foo.cl:8:0: Occupancy [waves/SIMD]: 8
 ; STDERR-NEXT: remark: foo.cl:8:0: SGPRs Spill: 0
 ; STDERR-NEXT: remark: foo.cl:8:0: VGPRs Spill: 0
@@ -137,6 +149,7 @@
 ; 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
@@ -144,8 +157,48 @@
   ret void
 }
 
+; STDERR: remark: foo.cl:64:0: Function Name: test_indirect_call
+; STDERR-NEXT: remark: foo.cl:64:0: SGPRs: 39
+; STDERR-NEXT: remark: foo.cl:64:0: VGPRs: 32
+; STDERR-NEXT: remark: foo.cl:64:0: AGPRs: 10
+; STDERR-NEXT: remark: foo.cl:64:0: ScratchSize [bytes/lane]: 0
+; STDERR-NEXT: remark: foo.cl:64:0: Dynamic Stack: True
+; STDERR-NEXT: remark: foo.cl:64:0: Occupancy [waves/SIMD]: 8
+; STDERR-NEXT: remark: foo.cl:64:0: SGPRs Spill: 0
+; STDERR-NEXT: remark: foo.cl:64:0: VGPRs Spill: 0
+; STDERR-NEXT: remark: foo.cl:64:0: LDS Size [bytes/block]: 0
+@gv.fptr0 = external hidden unnamed_addr addrspace(4) constant ptr, align 4
+
+define amdgpu_kernel void @test_indirect_call() !dbg !9 {
+  %fptr = load ptr, ptr addrspace(4) @gv.fptr0
+  call void %fptr()
+  ret void
+}
+
+; STDERR: remark: foo.cl:74:0: Function Name: test_indirect_w_static_stack
+; STDERR-NEXT: remark: foo.cl:74:0: SGPRs: 39
+; STDERR-NEXT: remark: foo.cl:74:0: VGPRs: 32
+; STDERR-NEXT: remark: foo.cl:74:0: AGPRs: 10
+; STDERR-NEXT: remark: foo.cl:74:0: ScratchSize [bytes/lane]: 64
+; STDERR-NEXT: remark: foo.cl:74:0: Dynamic Stack: True
+; STDERR-NEXT: remark: foo.cl:74:0: 

[PATCH] D156040: [AMDGPU] Add dynamic stack bit info to kernel-resource-usage Rpass output

2023-07-25 Thread Corbin Robeck via Phabricator via cfe-commits
crobeck updated this revision to Diff 544049.

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D156040/new/

https://reviews.llvm.org/D156040

Files:
  clang/test/Frontend/amdgcn-machine-analysis-remarks.cl
  llvm/lib/Target/AMDGPU/AMDGPUAsmPrinter.cpp
  llvm/test/CodeGen/AMDGPU/resource-optimization-remarks.ll

Index: llvm/test/CodeGen/AMDGPU/resource-optimization-remarks.ll
===
--- llvm/test/CodeGen/AMDGPU/resource-optimization-remarks.ll
+++ llvm/test/CodeGen/AMDGPU/resource-optimization-remarks.ll
@@ -1,4 +1,4 @@
-; RUN: llc -mtriple=amdgcn-amd-amdhsa -mcpu=gfx908 -pass-remarks-output=%t -pass-remarks-analysis=kernel-resource-usage -filetype=obj -o /dev/null %s 2>&1 | FileCheck -check-prefix=STDERR %s
+; RUN: llc -mtriple=amdgcn-amd-amdhsa -mcpu=gfx908 -pass-remarks-output=%t -pass-remarks-analysis=kernel-resource-usage -filetype=null %s 2>&1 | FileCheck -check-prefix=STDERR %s
 ; RUN: FileCheck -check-prefix=REMARK %s < %t
 
 ; STDERR: remark: foo.cl:27:0: Function Name: test_kernel
@@ -6,6 +6,7 @@
 ; STDERR-NEXT: remark: foo.cl:27:0: VGPRs: 9
 ; STDERR-NEXT: remark: foo.cl:27:0: AGPRs: 43
 ; STDERR-NEXT: remark: foo.cl:27:0: ScratchSize [bytes/lane]: 0
+; STDERR-NEXT: remark: foo.cl:27:0: Dynamic Stack: False
 ; STDERR-NEXT: remark: foo.cl:27:0: Occupancy [waves/SIMD]: 5
 ; STDERR-NEXT: remark: foo.cl:27:0: SGPRs Spill: 0
 ; STDERR-NEXT: remark: foo.cl:27:0: VGPRs Spill: 0
@@ -55,7 +56,16 @@
 ; REMARK-NEXT: Args:
 ; REMARK-NEXT:   - String:  'ScratchSize [bytes/lane]: '
 ; REMARK-NEXT:   - ScratchSize: '0'
-; REMARK-NEXT: ...
+; REMARK-NEXT: ..
+; REMARK-NEXT: --- !Analysis
+; REMARK-NEXT: Pass:kernel-resource-usage
+; REMARK-NEXT: Name:DynamicStack
+; REMARK-NEXT: DebugLoc:{ File: foo.cl, Line: 27, Column: 0 }
+; REMARK-NEXT: Function:test_kernel
+; REMARK-NEXT: Args:
+; REMARK-NEXT:   - String: ' Dynamic Stack: 
+; REMARK-NEXT:   - DynamicStack: 'False' 
+; REMARK-NEXT: ..
 ; REMARK-NEXT: --- !Analysis
 ; REMARK-NEXT: Pass:kernel-resource-usage
 ; REMARK-NEXT: Name:Occupancy
@@ -108,6 +118,7 @@
 ; 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
@@ -124,6 +135,7 @@
 ; STDERR-NEXT: remark: foo.cl:8:0: VGPRs: 0
 ; STDERR-NEXT: remark: foo.cl:8:0: AGPRs: 0
 ; STDERR-NEXT: remark: foo.cl:8:0: ScratchSize [bytes/lane]: 0
+; STDERR-NEXT: remark: foo.cl:8:0: Dynamic Stack: False
 ; STDERR-NEXT: remark: foo.cl:8:0: Occupancy [waves/SIMD]: 8
 ; STDERR-NEXT: remark: foo.cl:8:0: SGPRs Spill: 0
 ; STDERR-NEXT: remark: foo.cl:8:0: VGPRs Spill: 0
@@ -137,6 +149,7 @@
 ; 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
@@ -144,8 +157,48 @@
   ret void
 }
 
+; STDERR: remark: foo.cl:64:0: Function Name: test_indirect_call
+; STDERR-NEXT: remark: foo.cl:64:0: SGPRs: 39
+; STDERR-NEXT: remark: foo.cl:64:0: VGPRs: 32
+; STDERR-NEXT: remark: foo.cl:64:0: AGPRs: 10
+; STDERR-NEXT: remark: foo.cl:64:0: ScratchSize [bytes/lane]: 0
+; STDERR-NEXT: remark: foo.cl:64:0: Dynamic Stack: True
+; STDERR-NEXT: remark: foo.cl:64:0: Occupancy [waves/SIMD]: 8
+; STDERR-NEXT: remark: foo.cl:64:0: SGPRs Spill: 0
+; STDERR-NEXT: remark: foo.cl:64:0: VGPRs Spill: 0
+; STDERR-NEXT: remark: foo.cl:64:0: LDS Size [bytes/block]: 0
+@gv.fptr0 = external hidden unnamed_addr addrspace(4) constant ptr, align 4
+
+define amdgpu_kernel void @test_indirect_call() !dbg !9 {
+  %fptr = load ptr, ptr addrspace(4) @gv.fptr0
+  call void %fptr()
+  ret void
+}
+
+; STDERR: remark: foo.cl:74:0: Function Name: test_indirect_w_static_stack
+; STDERR-NEXT: remark: foo.cl:74:0: SGPRs: 39
+; STDERR-NEXT: remark: foo.cl:74:0: VGPRs: 32
+; STDERR-NEXT: remark: foo.cl:74:0: AGPRs: 10
+; STDERR-NEXT: remark: foo.cl:74:0: ScratchSize [bytes/lane]: 64
+; STDERR-NEXT: remark: foo.cl:74:0: Dynamic Stack: True
+; STDERR-NEXT: remark: foo.cl:74:0: Occupancy [waves/SIMD]: 8
+; STDERR-NEXT: remark: foo.cl:74:0: SGPRs Spill: 0
+; STDERR-NEXT: remark: foo.cl:74:0: VGPRs Spill: 0
+; STDERR-NEXT: remark: foo.cl:74:0: LDS Size [bytes/block]: 0
+
+declare void 

[PATCH] D156040: [AMDGPU] Add dynamic stack bit info to kernel-resource-usage Rpass output

2023-07-25 Thread Corbin Robeck via Phabricator via cfe-commits
crobeck added a subscriber: carlo.bertolli.
crobeck added a comment.

> The openmp runtime needs to do the same if not being done already.

Should be on @carlo.bertolli's TODO list


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D156040/new/

https://reviews.llvm.org/D156040

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D156040: [AMDGPU] Add dynamic stack bit info to kernel-resource-usage Rpass output

2023-07-25 Thread Matt Arsenault via Phabricator via cfe-commits
arsenm added a comment.

In D156040#4526036 , @JonChesterfield 
wrote:

> What's the use case I'm missing which makes this flag necessary/beneficial?

The metadata is also irrelevant to this patch which is just reporting 
optimization hint information


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D156040/new/

https://reviews.llvm.org/D156040

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D156040: [AMDGPU] Add dynamic stack bit info to kernel-resource-usage Rpass output

2023-07-25 Thread Matt Arsenault via Phabricator via cfe-commits
arsenm accepted this revision.
arsenm added a comment.
This revision is now accepted and ready to land.

lgtm with nits




Comment at: llvm/lib/Target/AMDGPU/AMDGPUAsmPrinter.cpp:1298
+  CurrentProgramInfo.DynamicCallStack ? "True" : "False";
+  EmitResourceUsageRemark("UsesDynamicStack", "Uses Dynamic Stack",
+  UsesDynamicStackStr);

Drop "Uses". Could also just inline the bool->string



Comment at: llvm/test/CodeGen/AMDGPU/resource-optimization-remarks.ll:189
+
+declare void @llvm.memset.p0i8.i64(i8* nocapture writeonly, i8, i64, i1 immarg)
+ 

No typed pointers


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D156040/new/

https://reviews.llvm.org/D156040

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D156040: [AMDGPU] Add dynamic stack bit info to kernel-resource-usage Rpass output

2023-07-24 Thread Corbin Robeck via Phabricator via cfe-commits
crobeck updated this revision to Diff 543772.
crobeck edited the summary of this revision.
crobeck added a comment.

Change remark order and add static stack w/ indirect function call test case


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D156040/new/

https://reviews.llvm.org/D156040

Files:
  clang/test/Frontend/amdgcn-machine-analysis-remarks.cl
  llvm/lib/Target/AMDGPU/AMDGPUAsmPrinter.cpp
  llvm/test/CodeGen/AMDGPU/resource-optimization-remarks.ll

Index: llvm/test/CodeGen/AMDGPU/resource-optimization-remarks.ll
===
--- llvm/test/CodeGen/AMDGPU/resource-optimization-remarks.ll
+++ llvm/test/CodeGen/AMDGPU/resource-optimization-remarks.ll
@@ -1,4 +1,4 @@
-; RUN: llc -mtriple=amdgcn-amd-amdhsa -mcpu=gfx908 -pass-remarks-output=%t -pass-remarks-analysis=kernel-resource-usage -filetype=obj -o /dev/null %s 2>&1 | FileCheck -check-prefix=STDERR %s
+; RUN: llc -mtriple=amdgcn-amd-amdhsa -mcpu=gfx908 -pass-remarks-output=%t -pass-remarks-analysis=kernel-resource-usage -filetype=null %s 2>&1 | FileCheck -check-prefix=STDERR %s
 ; RUN: FileCheck -check-prefix=REMARK %s < %t
 
 ; STDERR: remark: foo.cl:27:0: Function Name: test_kernel
@@ -6,6 +6,7 @@
 ; STDERR-NEXT: remark: foo.cl:27:0: VGPRs: 9
 ; STDERR-NEXT: remark: foo.cl:27:0: AGPRs: 43
 ; STDERR-NEXT: remark: foo.cl:27:0: ScratchSize [bytes/lane]: 0
+; STDERR-NEXT: remark: foo.cl:27:0: Uses Dynamic Stack: False
 ; STDERR-NEXT: remark: foo.cl:27:0: Occupancy [waves/SIMD]: 5
 ; STDERR-NEXT: remark: foo.cl:27:0: SGPRs Spill: 0
 ; STDERR-NEXT: remark: foo.cl:27:0: VGPRs Spill: 0
@@ -55,7 +56,16 @@
 ; REMARK-NEXT: Args:
 ; REMARK-NEXT:   - String:  'ScratchSize [bytes/lane]: '
 ; REMARK-NEXT:   - ScratchSize: '0'
-; REMARK-NEXT: ...
+; REMARK-NEXT: ..
+; REMARK-NEXT: --- !Analysis
+; REMARK-NEXT: Pass:kernel-resource-usage
+; REMARK-NEXT: Name:UsesDynamicStack
+; REMARK-NEXT: DebugLoc:{ File: foo.cl, Line: 27, Column: 0 }
+; REMARK-NEXT: Function:test_kernel
+; REMARK-NEXT: Args:
+; REMARK-NEXT:   - String: ' Uses Dynamic Stack: 
+; REMARK-NEXT:   - UsesDynamicStack: 'False' 
+; REMARK-NEXT: ..
 ; REMARK-NEXT: --- !Analysis
 ; REMARK-NEXT: Pass:kernel-resource-usage
 ; REMARK-NEXT: Name:Occupancy
@@ -108,6 +118,7 @@
 ; 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: Uses 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
@@ -124,6 +135,7 @@
 ; STDERR-NEXT: remark: foo.cl:8:0: VGPRs: 0
 ; STDERR-NEXT: remark: foo.cl:8:0: AGPRs: 0
 ; STDERR-NEXT: remark: foo.cl:8:0: ScratchSize [bytes/lane]: 0
+; STDERR-NEXT: remark: foo.cl:8:0: Uses Dynamic Stack: False
 ; STDERR-NEXT: remark: foo.cl:8:0: Occupancy [waves/SIMD]: 8
 ; STDERR-NEXT: remark: foo.cl:8:0: SGPRs Spill: 0
 ; STDERR-NEXT: remark: foo.cl:8:0: VGPRs Spill: 0
@@ -137,6 +149,7 @@
 ; 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: Uses 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
@@ -144,8 +157,50 @@
   ret void
 }
 
+; STDERR: remark: foo.cl:64:0: Function Name: test_indirect_call
+; STDERR-NEXT: remark: foo.cl:64:0: SGPRs: 39
+; STDERR-NEXT: remark: foo.cl:64:0: VGPRs: 32
+; STDERR-NEXT: remark: foo.cl:64:0: AGPRs: 10
+; STDERR-NEXT: remark: foo.cl:64:0: ScratchSize [bytes/lane]: 0
+; STDERR-NEXT: remark: foo.cl:64:0: Uses Dynamic Stack: True
+; STDERR-NEXT: remark: foo.cl:64:0: Occupancy [waves/SIMD]: 8
+; STDERR-NEXT: remark: foo.cl:64:0: SGPRs Spill: 0
+; STDERR-NEXT: remark: foo.cl:64:0: VGPRs Spill: 0
+; STDERR-NEXT: remark: foo.cl:64:0: LDS Size [bytes/block]: 0
+@gv.fptr0 = external hidden unnamed_addr addrspace(4) constant ptr, align 4
+
+define amdgpu_kernel void @test_indirect_call() !dbg !9 {
+  %fptr = load ptr, ptr addrspace(4) @gv.fptr0
+  call void %fptr()
+  ret void
+}
+
+; STDERR: remark: foo.cl:74:0: Function Name: test_indirect_w_static_stack
+; STDERR-NEXT: remark: foo.cl:74:0: SGPRs: 39
+; STDERR-NEXT: remark: foo.cl:74:0: VGPRs: 32
+; STDERR-NEXT: remark: foo.cl:74:0: AGPRs: 10
+; STDERR-NEXT: remark: foo.cl:74:0: ScratchSize [bytes/lane]: 64
+; STDERR-NEXT: remark: foo.cl:74:0: Uses Dynamic Stack: True
+; STDERR-NEXT: remark: foo.cl:74:0: Occupancy [waves/SIMD]: 8
+; 

[PATCH] D156040: [AMDGPU] Add dynamic stack bit info to kernel-resource-usage Rpass output

2023-07-24 Thread Brian Sumner via Phabricator via cfe-commits
b-sumner added a comment.

In D156040#4528606 , @arsenm wrote:

> In D156040#4526036 , 
> @JonChesterfield wrote:
>
>> I don't see how this conveys any information. The compiler writes the stack 
>> size to be allocated. If it doesn't know what is sufficient, it's going to 
>> request some maximum and hope for the best.
>
> That was the old broken workaround for the old bit that was never actually 
> implemented in the runtime. The runtime now does properly respect some field 
> to switch to interpreting the reported size as a minimum and then allocates 
> the max of that minimum and some API provided size value

"runtime" == "hip/opencl runtime".  The openmp runtime needs to do the same if 
not being done already.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D156040/new/

https://reviews.llvm.org/D156040

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D156040: [AMDGPU] Add dynamic stack bit info to kernel-resource-usage Rpass output

2023-07-24 Thread Matt Arsenault via Phabricator via cfe-commits
arsenm added inline comments.



Comment at: clang/test/Frontend/amdgcn-machine-analysis-remarks.cl:13
+// expected-remark@+2 {{LDS Size [bytes/block]: 0}}
+// expected-remark@+1 {{Uses Dynamic Stack: False}}
 __kernel void foo() {

Print right after the scratch size



Comment at: llvm/lib/Target/AMDGPU/AMDGPUAsmPrinter.cpp:1305
 CurrentProgramInfo.LDSSize);
+  std::string UsesDynamicStackStr =
+  CurrentProgramInfo.DynamicCallStack ? "True" : "False";

don't need std::string for simple literals? StringRef?



Comment at: llvm/test/CodeGen/AMDGPU/resource-optimization-remarks.ll:168
+}
+
+

Maybe add another that has a static component too


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D156040/new/

https://reviews.llvm.org/D156040

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D156040: [AMDGPU] Add dynamic stack bit info to kernel-resource-usage Rpass output

2023-07-24 Thread Matt Arsenault via Phabricator via cfe-commits
arsenm added a comment.

In D156040#4526036 , @JonChesterfield 
wrote:

> I don't see how this conveys any information. The compiler writes the stack 
> size to be allocated. If it doesn't know what is sufficient, it's going to 
> request some maximum and hope for the best.

That was the old broken workaround for the old bit that was never actually 
implemented in the runtime. The runtime now does properly respect some field to 
switch to interpreting the reported size as a minimum and then allocates the 
max of that minimum and some API provided size value


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D156040/new/

https://reviews.llvm.org/D156040

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D156040: [AMDGPU] Add dynamic stack bit info to kernel-resource-usage Rpass output

2023-07-23 Thread Corbin Robeck via Phabricator via cfe-commits
crobeck updated this revision to Diff 543318.
crobeck added a comment.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Update clang frontend test


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D156040/new/

https://reviews.llvm.org/D156040

Files:
  clang/test/Frontend/amdgcn-machine-analysis-remarks.cl
  llvm/lib/Target/AMDGPU/AMDGPUAsmPrinter.cpp
  llvm/test/CodeGen/AMDGPU/resource-optimization-remarks.ll

Index: llvm/test/CodeGen/AMDGPU/resource-optimization-remarks.ll
===
--- llvm/test/CodeGen/AMDGPU/resource-optimization-remarks.ll
+++ llvm/test/CodeGen/AMDGPU/resource-optimization-remarks.ll
@@ -1,4 +1,4 @@
-; RUN: llc -mtriple=amdgcn-amd-amdhsa -mcpu=gfx908 -pass-remarks-output=%t -pass-remarks-analysis=kernel-resource-usage -filetype=obj -o /dev/null %s 2>&1 | FileCheck -check-prefix=STDERR %s
+; RUN: llc -mtriple=amdgcn-amd-amdhsa -mcpu=gfx908 -pass-remarks-output=%t -pass-remarks-analysis=kernel-resource-usage -filetype=null %s 2>&1 | FileCheck -check-prefix=STDERR %s
 ; RUN: FileCheck -check-prefix=REMARK %s < %t
 
 ; STDERR: remark: foo.cl:27:0: Function Name: test_kernel
@@ -10,6 +10,7 @@
 ; STDERR-NEXT: remark: foo.cl:27:0: SGPRs Spill: 0
 ; STDERR-NEXT: remark: foo.cl:27:0: VGPRs Spill: 0
 ; STDERR-NEXT: remark: foo.cl:27:0: LDS Size [bytes/block]: 512
+; STDERR-NEXT: remark: foo.cl:27:0: Uses Dynamic Stack: False
 
 ; REMARK-LABEL: --- !Analysis
 ; REMARK: Pass:kernel-resource-usage
@@ -111,6 +112,7 @@
 ; 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-NEXT: remark: foo.cl:42:0: Uses Dynamic Stack: False
 ; STDERR-NOT: LDS Size
 define void @test_func() !dbg !6 {
   call void asm sideeffect "; clobber v17", "~{v17}"()
@@ -128,6 +130,7 @@
 ; STDERR-NEXT: remark: foo.cl:8:0: SGPRs Spill: 0
 ; STDERR-NEXT: remark: foo.cl:8:0: VGPRs Spill: 0
 ; STDERR-NEXT: remark: foo.cl:8:0: LDS Size [bytes/block]: 0
+; STDERR-NEXT: remark: foo.cl:8:0: Uses Dynamic Stack: False
 define amdgpu_kernel void @empty_kernel() !dbg !7 {
   ret void
 }
@@ -140,12 +143,33 @@
 ; 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-NEXT: remark: foo.cl:52:0: Uses Dynamic Stack: False
 define void @empty_func() !dbg !8 {
   ret void
 }
 
+; STDERR: remark: foo.cl:64:0: Function Name: test_indirect_call
+; STDERR-NEXT: remark: foo.cl:64:0: SGPRs: 39
+; STDERR-NEXT: remark: foo.cl:64:0: VGPRs: 32
+; STDERR-NEXT: remark: foo.cl:64:0: AGPRs: 10
+; STDERR-NEXT: remark: foo.cl:64:0: ScratchSize [bytes/lane]: 0
+; STDERR-NEXT: remark: foo.cl:64:0: Occupancy [waves/SIMD]: 8
+; STDERR-NEXT: remark: foo.cl:64:0: SGPRs Spill: 0
+; STDERR-NEXT: remark: foo.cl:64:0: VGPRs Spill: 0
+; STDERR-NEXT: remark: foo.cl:64:0: LDS Size [bytes/block]: 0
+; STDERR-NEXT: remark: foo.cl:64:0: Uses Dynamic Stack: True
+@gv.fptr0 = external hidden unnamed_addr addrspace(4) constant ptr, align 4
+
+define amdgpu_kernel void @test_indirect_call() !dbg !9 {
+  %fptr = load ptr, ptr addrspace(4) @gv.fptr0
+  call void %fptr()
+  ret void
+}
+
+
 !llvm.dbg.cu = !{!0}
 !llvm.module.flags = !{!2}
+!llvm.module.flags = !{!10}
 
 !0 = distinct !DICompileUnit(language: DW_LANG_C99, file: !1, isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug)
 !1 = !DIFile(filename: "foo.cl", directory: "/tmp")
@@ -156,3 +180,5 @@
 !6 = distinct !DISubprogram(name: "test_func", scope: !1, file: !1, type: !4, scopeLine: 42, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition, unit: !0)
 !7 = distinct !DISubprogram(name: "empty_kernel", scope: !1, file: !1, type: !4, scopeLine: 8, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition, unit: !0)
 !8 = distinct !DISubprogram(name: "empty_func", scope: !1, file: !1, type: !4, scopeLine: 52, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition, unit: !0)
+!9 = distinct !DISubprogram(name: "test_indirect_call", scope: !1, file: !1, type: !4, scopeLine: 64, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition, unit: !0)
+!10 = !{i32 1, !"amdgpu_code_object_version", i32 500}
Index: llvm/lib/Target/AMDGPU/AMDGPUAsmPrinter.cpp
===
--- llvm/lib/Target/AMDGPU/AMDGPUAsmPrinter.cpp
+++ llvm/lib/Target/AMDGPU/AMDGPUAsmPrinter.cpp
@@ -1302,4 +1302,8 @@
   if (isModuleEntryFunction)
 EmitResourceUsageRemark("BytesLDS", "LDS Size [bytes/block]",
 CurrentProgramInfo.LDSSize);
+  std::string UsesDynamicStackStr =
+  CurrentProgramInfo.DynamicCallStack ? "True" : "False";
+  EmitResourceUsageRemark("UsesDynamicStack", "Uses Dynamic Stack",
+