[llvm] CodeGen: Add UsesBlockArgs MachineFunction property (PR #218892)

Matt Arsenault via llvm-commits llvm-commits at lists.llvm.org
Wed Aug 26 06:50:15 PDT 2026


https://github.com/arsenm updated https://github.com/llvm/llvm-project/pull/218892

>From e22fc69e6daebf970e0c135ababab0ddd4255d86 Mon Sep 17 00:00:00 2001
From: Matt Arsenault <Matthew.Arsenault at amd.com>
Date: Fri, 14 Aug 2026 00:04:19 +0200
Subject: [PATCH] CodeGen: Add UsesBlockArgs MachineFunction property

Bringup guard for block argument support.

Co-authored-by: Claude (Claude-Opus-4.8) <noreply at anthropic.com>
---
 llvm/include/llvm/CodeGen/MIRYamlMapping.h    |  2 ++
 llvm/include/llvm/CodeGen/MachineFunction.h   |  4 +++-
 llvm/lib/CodeGen/MIRParser/MIRParser.cpp      |  2 ++
 llvm/lib/CodeGen/MIRPrinter.cpp               |  1 +
 llvm/lib/CodeGen/MachineFunction.cpp          |  1 +
 .../MIR/X86/uses-block-args-property.mir      | 20 +++++++++++++++++++
 6 files changed, 29 insertions(+), 1 deletion(-)
 create mode 100644 llvm/test/CodeGen/MIR/X86/uses-block-args-property.mir

diff --git a/llvm/include/llvm/CodeGen/MIRYamlMapping.h b/llvm/include/llvm/CodeGen/MIRYamlMapping.h
index de61b8d3fec12..45a7102d4239f 100644
--- a/llvm/include/llvm/CodeGen/MIRYamlMapping.h
+++ b/llvm/include/llvm/CodeGen/MIRYamlMapping.h
@@ -845,6 +845,7 @@ struct MachineFunction {
   bool FailsVerification = false;
   bool TracksDebugUserValues = false;
   bool UseDebugInstrRef = false;
+  bool UsesBlockArgs = false;
   std::vector<VirtualRegisterDefinition> VirtualRegisters;
   std::vector<MachineFunctionLiveIn> LiveIns;
   std::optional<std::vector<FlowStringValue>> CalleeSavedRegisters;
@@ -895,6 +896,7 @@ template <> struct MappingTraits<MachineFunction> {
     YamlIO.mapOptional("failsVerification", MF.FailsVerification, false);
     YamlIO.mapOptional("tracksDebugUserValues", MF.TracksDebugUserValues,
                        false);
+    YamlIO.mapOptional("usesBlockArgs", MF.UsesBlockArgs, false);
     YamlIO.mapOptional("registers", MF.VirtualRegisters,
                        std::vector<VirtualRegisterDefinition>());
     YamlIO.mapOptional("liveins", MF.LiveIns,
diff --git a/llvm/include/llvm/CodeGen/MachineFunction.h b/llvm/include/llvm/CodeGen/MachineFunction.h
index d84ce80e10a3c..78781ffdc317a 100644
--- a/llvm/include/llvm/CodeGen/MachineFunction.h
+++ b/llvm/include/llvm/CodeGen/MachineFunction.h
@@ -198,7 +198,8 @@ class MachineFunctionProperties {
     FailsVerification,
     FailedRegAlloc,
     TracksDebugUserValues,
-    LastProperty = TracksDebugUserValues,
+    UsesBlockArgs,
+    LastProperty = UsesBlockArgs,
   };
 
   bool hasProperty(Property P) const {
@@ -233,6 +234,7 @@ class MachineFunctionProperties {
   PPACCESSORS(FailsVerification)
   PPACCESSORS(FailedRegAlloc)
   PPACCESSORS(TracksDebugUserValues)
+  PPACCESSORS(UsesBlockArgs)
 
   /// Reset all the properties.
   MachineFunctionProperties &reset() {
diff --git a/llvm/lib/CodeGen/MIRParser/MIRParser.cpp b/llvm/lib/CodeGen/MIRParser/MIRParser.cpp
index 6f1e7594f34da..f7b6c7b6e0aae 100644
--- a/llvm/lib/CodeGen/MIRParser/MIRParser.cpp
+++ b/llvm/lib/CodeGen/MIRParser/MIRParser.cpp
@@ -599,6 +599,8 @@ MIRParserImpl::initializeMachineFunction(const yaml::MachineFunction &YamlMF,
     Props.setFailsVerification();
   if (YamlMF.TracksDebugUserValues)
     Props.setTracksDebugUserValues();
+  if (YamlMF.UsesBlockArgs)
+    Props.setUsesBlockArgs();
 
   PerFunctionMIParsingState PFS(MF, SM, IRSlots, *Target);
   if (parseRegisterInfo(PFS, YamlMF))
diff --git a/llvm/lib/CodeGen/MIRPrinter.cpp b/llvm/lib/CodeGen/MIRPrinter.cpp
index 8acd6f14ebc2e..f66300c17509c 100644
--- a/llvm/lib/CodeGen/MIRPrinter.cpp
+++ b/llvm/lib/CodeGen/MIRPrinter.cpp
@@ -206,6 +206,7 @@ static void printMF(raw_ostream &OS, MFGetterFnT Fn, const MachineFunction &MF,
   YamlMF.NoPHIs = Props.hasNoPHIs();
   YamlMF.IsSSA = Props.hasIsSSA();
   YamlMF.NoVRegs = Props.hasNoVRegs();
+  YamlMF.UsesBlockArgs = Props.hasUsesBlockArgs();
 
   convertMRI(YamlMF, MF, MF.getRegInfo(), MF.getSubtarget().getRegisterInfo(),
              VRM);
diff --git a/llvm/lib/CodeGen/MachineFunction.cpp b/llvm/lib/CodeGen/MachineFunction.cpp
index 144f165e17973..213d4ae1ce434 100644
--- a/llvm/lib/CodeGen/MachineFunction.cpp
+++ b/llvm/lib/CodeGen/MachineFunction.cpp
@@ -105,6 +105,7 @@ static const char *getPropertyName(MachineFunctionProperties::Property Prop) {
   case P::FailsVerification: return "FailsVerification";
   case P::FailedRegAlloc: return "FailedRegAlloc";
   case P::TracksDebugUserValues: return "TracksDebugUserValues";
+  case P::UsesBlockArgs: return "UsesBlockArgs";
   }
   // clang-format on
   llvm_unreachable("Invalid machine function property");
diff --git a/llvm/test/CodeGen/MIR/X86/uses-block-args-property.mir b/llvm/test/CodeGen/MIR/X86/uses-block-args-property.mir
new file mode 100644
index 0000000000000..27806d39fa8fe
--- /dev/null
+++ b/llvm/test/CodeGen/MIR/X86/uses-block-args-property.mir
@@ -0,0 +1,20 @@
+# RUN: llc -mtriple=x86_64-- -run-pass=none -o - %s | FileCheck %s
+# Round-trip test for the usesBlockArgs machine function property.
+
+---
+# CHECK-LABEL: name: with_block_args
+# CHECK: usesBlockArgs: true
+name: with_block_args
+usesBlockArgs: true
+body: |
+  bb.0:
+    RET64
+...
+---
+# CHECK-LABEL: name: without_block_args
+# CHECK: usesBlockArgs: false
+name: without_block_args
+body: |
+  bb.0:
+    RET64
+...



More information about the llvm-commits mailing list