[clang] [llvm] [AMDGPU] Convert AMDGPUResourceUsageAnalysis pass from Module to MF pass (PR #102913)

Janek van Oirschot via llvm-commits llvm-commits at lists.llvm.org
Thu Aug 22 09:01:08 PDT 2024


================
@@ -0,0 +1,533 @@
+; RUN: llc -mtriple=amdgcn-amd-amdhsa -mcpu=gfx900 -enable-ipra=0 -verify-machineinstrs < %s | FileCheck -check-prefix=GCN %s
+
+; SGPR use may not seem equal to the sgpr use provided in comments as the latter includes extra sgprs (e.g., for vcc use).
+
+; Functions that don't make calls should have constants as its resource usage as no resource information has to be propagated.
+
+; GCN-LABEL: {{^}}use_vcc:
+; GCN: .set use_vcc.num_vgpr, 0
+; GCN: .set use_vcc.num_agpr, 0
+; GCN: .set use_vcc.num_sgpr, 32
+; GCN: .set use_vcc.private_seg_size, 0
+; GCN: .set use_vcc.uses_vcc, 1
+; GCN: .set use_vcc.uses_flat_scratch, 0
+; GCN: .set use_vcc.has_dyn_sized_stack, 0
+; GCN: .set use_vcc.has_recursion, 0
+; GCN: .set use_vcc.has_indirect_call, 0
+; GCN: NumSgprs: 36
+; GCN: NumVgprs: 0
+; GCN: ScratchSize: 0
+define void @use_vcc() #1 {
+  call void asm sideeffect "", "~{vcc}" () #0
+  ret void
+}
+
+; GCN-LABEL: {{^}}indirect_use_vcc:
+; GCN: .set indirect_use_vcc.num_vgpr, max(41, use_vcc.num_vgpr)
----------------
JanekvO wrote:

If we were to go from `function-resource-usage.ll` to `funcion-resource-usage.s` and try to assemble `function-resource-usage.s` through `llvm-mc`, it would resolve whatever it can at the time of emitting again. In the specific case you've highlighted it would resolve into a constant as `use_vcc.num_vgpr` is defined before its use.

However, cases which use/depend on the module level maximum (e.g., `max_num_vgpr`) wouldn't be able to resolve to a constant as these module level maximums are defined at the bottom of the file.

TL;DR: order of symbol define/use dependent

https://github.com/llvm/llvm-project/pull/102913


More information about the llvm-commits mailing list