[llvm-branch-commits] [llvm] [AMDGPU] Add `.amdgpu.info` section for per-function metadata (PR #192384)

Juan Manuel Martinez CaamaƱo via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Fri Apr 17 07:13:50 PDT 2026


================
@@ -729,6 +879,26 @@ bool AMDGPUAsmPrinter::runOnMachineFunction(MachineFunction &MF) {
 
   RI.gatherResourceInfo(MF, *ResourceUsage, OutContext);
 
+  if (AMDGPUTargetMachine::EnableObjectLinking) {
+    PerFunctionResourceInfo PFRI = {&MF.getFunction(), *ResourceUsage};
+    if (AMDGPU::isKernel(MF.getFunction().getCallingConv())) {
+      unsigned TotalLDS = STM.getLocalMemorySize();
+      const auto [MinWEU, MaxWEU] = AMDGPU::getIntegerPairAttribute(
+          MF.getFunction(), "amdgpu-waves-per-eu", {0, 0}, true);
+      if (MinWEU > 0) {
+        const SIMachineFunctionInfo &SIMFI =
+            *MF.getInfo<SIMachineFunctionInfo>();
+        unsigned FlatWGSizeMax = SIMFI.getFlatWorkGroupSizes().second;
+        unsigned WavesPerWG = divideCeil(FlatWGSizeMax, STM.getWavefrontSize());
+        unsigned MinWGs = divideCeil(MinWEU * STM.getEUsPerCU(), WavesPerWG);
+        PFRI.Occupancy = MinWGs > 0 ? TotalLDS / MinWGs : TotalLDS;
----------------
jmmartinez wrote:

`MinWGs` cannot be 0 right ? Since `MinWEU` and `STM.getEUsPerCU()` are both `> 0` at this point.

It's a bit confusing to assign this to `Occupancy` when it's actually the LDS size per WG (but I also haven't read the whole PR).

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


More information about the llvm-branch-commits mailing list