[llvm] [AMDGPU][MFI] Implement missing deserialization of dynamicVGPRBlockSize (PR #201939)
via llvm-commits
llvm-commits at lists.llvm.org
Sat Jun 6 12:29:41 PDT 2026
https://github.com/vporpo updated https://github.com/llvm/llvm-project/pull/201939
>From d56394505fc9f21beb5d7e504767af08ae01efc7 Mon Sep 17 00:00:00 2001
From: Vasileios Porpodas <vasileios.porpodas at amd.com>
Date: Fri, 5 Jun 2026 20:59:36 +0000
Subject: [PATCH] [AMDGPU][MFI] Implement missing deserialization of
dynamicVGPRBlockSize
---
.../Target/AMDGPU/SIMachineFunctionInfo.cpp | 4 +++
.../mir-dynamic-vgpr-block-size-roundtrip.mir | 35 +++++++++++++++++++
2 files changed, 39 insertions(+)
create mode 100644 llvm/test/CodeGen/AMDGPU/mir-dynamic-vgpr-block-size-roundtrip.mir
diff --git a/llvm/lib/Target/AMDGPU/SIMachineFunctionInfo.cpp b/llvm/lib/Target/AMDGPU/SIMachineFunctionInfo.cpp
index df3a3903b5bc2..38aa98736b735 100644
--- a/llvm/lib/Target/AMDGPU/SIMachineFunctionInfo.cpp
+++ b/llvm/lib/Target/AMDGPU/SIMachineFunctionInfo.cpp
@@ -804,6 +804,10 @@ bool SIMachineFunctionInfo::initializeBaseYamlFields(
ReturnsVoid = YamlMFI.ReturnsVoid;
IsWholeWaveFunction = YamlMFI.IsWholeWaveFunction;
MinNumAGPRs = YamlMFI.MinNumAGPRs;
+ // A non-zero value means that we got this value from the function attribute.
+ // It takes precedence over the MFI value.
+ if (DynamicVGPRBlockSize == 0)
+ DynamicVGPRBlockSize = YamlMFI.DynamicVGPRBlockSize;
UserSGPRInfo.allocKernargPreloadSGPRs(YamlMFI.NumKernargPreloadSGPRs);
diff --git a/llvm/test/CodeGen/AMDGPU/mir-dynamic-vgpr-block-size-roundtrip.mir b/llvm/test/CodeGen/AMDGPU/mir-dynamic-vgpr-block-size-roundtrip.mir
new file mode 100644
index 0000000000000..09308e61adcbc
--- /dev/null
+++ b/llvm/test/CodeGen/AMDGPU/mir-dynamic-vgpr-block-size-roundtrip.mir
@@ -0,0 +1,35 @@
+# RUN: llc -mtriple=amdgcn-amd-amdpal -mcpu=gfx1200 -run-pass=none -o - %s | FileCheck %s
+
+# Test that dynamicVGPRBlockSize round-trips through MIR serialization.
+
+--- |
+ define amdgpu_ps void @dynvgpr_roundtrip_no_fn_attr() { ret void }
+ define amdgpu_ps void @dynvgpr_roundtrip_with_fn_attr() #0 { ret void }
+ attributes #0 = { "amdgpu-dynamic-vgpr-block-size" = "16" }
+...
+
+# CHECK-LABEL: name: dynvgpr_roundtrip_no_fn_attr
+# CHECK: dynamicVGPRBlockSize: 32
+
+---
+name: dynvgpr_roundtrip_no_fn_attr
+machineFunctionInfo:
+ dynamicVGPRBlockSize: 32
+body: |
+ bb.0:
+ S_ENDPGM 0
+...
+
+# In this test the function attribute is 16 but MFI is set to 32.
+# The attribute takes precedence over MFI, so check for 16.
+
+# CHECK-LABEL: name: dynvgpr_roundtrip_with_fn_attr
+# CHECK: dynamicVGPRBlockSize: 16
+---
+name: dynvgpr_roundtrip_with_fn_attr
+machineFunctionInfo:
+ dynamicVGPRBlockSize: 32
+body: |
+ bb.0:
+ S_ENDPGM 0
+...
More information about the llvm-commits
mailing list