[llvm-branch-commits] [llvm] MIR: Serialize MachineBasicBlock::IsCleanupFuncletEntry (PR #227194)

Matt Arsenault via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Mon Sep 28 23:00:32 PDT 2026


https://github.com/arsenm created https://github.com/llvm/llvm-project/pull/227194

Co-authored-by: Claude Sonnet 5 <noreply at anthropic.com>

>From 37cda3712d7188852602ca01d8adf30e21f066f3 Mon Sep 17 00:00:00 2001
From: Matt Arsenault <Matthew.Arsenault at amd.com>
Date: Tue, 29 Sep 2026 00:42:28 +0200
Subject: [PATCH] MIR: Serialize MachineBasicBlock::IsCleanupFuncletEntry

Co-authored-by: Claude Sonnet 5 <noreply at anthropic.com>
---
 llvm/lib/CodeGen/MIRParser/MILexer.cpp           |  1 +
 llvm/lib/CodeGen/MIRParser/MILexer.h             |  1 +
 llvm/lib/CodeGen/MIRParser/MIParser.cpp          |  6 ++++++
 llvm/lib/CodeGen/MachineBasicBlock.cpp           |  5 +++++
 ...machine-basic-block-cleanup-funclet-entry.mir | 16 ++++++++++++++++
 5 files changed, 29 insertions(+)
 create mode 100644 llvm/test/CodeGen/MIR/Generic/machine-basic-block-cleanup-funclet-entry.mir

diff --git a/llvm/lib/CodeGen/MIRParser/MILexer.cpp b/llvm/lib/CodeGen/MIRParser/MILexer.cpp
index c220047bac32c2..d686be44b3ba74 100644
--- a/llvm/lib/CodeGen/MIRParser/MILexer.cpp
+++ b/llvm/lib/CodeGen/MIRParser/MILexer.cpp
@@ -280,6 +280,7 @@ static MIToken::TokenKind getIdentifierKind(StringRef Identifier) {
             MIToken::kw_inlineasm_br_indirect_target)
       .Case("ehscope-entry", MIToken::kw_ehscope_entry)
       .Case("ehfunclet-entry", MIToken::kw_ehfunclet_entry)
+      .Case("cleanup-funclet-entry", MIToken::kw_cleanup_funclet_entry)
       .Case("liveins", MIToken::kw_liveins)
       .Case("successors", MIToken::kw_successors)
       .Case("floatpred", MIToken::kw_floatpred)
diff --git a/llvm/lib/CodeGen/MIRParser/MILexer.h b/llvm/lib/CodeGen/MIRParser/MILexer.h
index 452a7bba1b12b8..0548cc2fe1baae 100644
--- a/llvm/lib/CodeGen/MIRParser/MILexer.h
+++ b/llvm/lib/CodeGen/MIRParser/MILexer.h
@@ -134,6 +134,7 @@ struct MIToken {
     kw_inlineasm_br_indirect_target,
     kw_ehscope_entry,
     kw_ehfunclet_entry,
+    kw_cleanup_funclet_entry,
     kw_liveins,
     kw_successors,
     kw_floatpred,
diff --git a/llvm/lib/CodeGen/MIRParser/MIParser.cpp b/llvm/lib/CodeGen/MIRParser/MIParser.cpp
index bd67f067eb8aed..b74730689c4cfc 100644
--- a/llvm/lib/CodeGen/MIRParser/MIParser.cpp
+++ b/llvm/lib/CodeGen/MIRParser/MIParser.cpp
@@ -744,6 +744,7 @@ bool MIParser::parseBasicBlockDefinition(
   bool IsInlineAsmBrIndirectTarget = false;
   bool IsEHFuncletEntry = false;
   bool IsEHScopeEntry = false;
+  bool IsCleanupFuncletEntry = false;
   std::optional<MBBSectionID> SectionID;
   uint64_t Alignment = 0;
   unsigned MaxBytesForAlignment = 0;
@@ -778,6 +779,10 @@ bool MIParser::parseBasicBlockDefinition(
         IsEHScopeEntry = true;
         lex();
         break;
+      case MIToken::kw_cleanup_funclet_entry:
+        IsCleanupFuncletEntry = true;
+        lex();
+        break;
       case MIToken::kw_align:
         if (parseAlignment(Alignment))
           return true;
@@ -842,6 +847,7 @@ bool MIParser::parseBasicBlockDefinition(
   MBB->setIsInlineAsmBrIndirectTarget(IsInlineAsmBrIndirectTarget);
   MBB->setIsEHFuncletEntry(IsEHFuncletEntry);
   MBB->setIsEHScopeEntry(IsEHScopeEntry);
+  MBB->setIsCleanupFuncletEntry(IsCleanupFuncletEntry);
   if (SectionID) {
     MBB->setSectionID(*SectionID);
     MF.setBBSectionsType(BasicBlockSection::List);
diff --git a/llvm/lib/CodeGen/MachineBasicBlock.cpp b/llvm/lib/CodeGen/MachineBasicBlock.cpp
index e920e825dda2c6..fbf79d0eb2f9cc 100644
--- a/llvm/lib/CodeGen/MachineBasicBlock.cpp
+++ b/llvm/lib/CodeGen/MachineBasicBlock.cpp
@@ -562,6 +562,11 @@ void MachineBasicBlock::printName(raw_ostream &os, unsigned printNameFlags,
       os << "ehscope-entry";
       hasAttributes = true;
     }
+    if (isCleanupFuncletEntry()) {
+      os << (hasAttributes ? ", " : " (");
+      os << "cleanup-funclet-entry";
+      hasAttributes = true;
+    }
     if (getAlignment() != Align(1)) {
       os << (hasAttributes ? ", " : " (");
       os << "align " << getAlignment().value();
diff --git a/llvm/test/CodeGen/MIR/Generic/machine-basic-block-cleanup-funclet-entry.mir b/llvm/test/CodeGen/MIR/Generic/machine-basic-block-cleanup-funclet-entry.mir
new file mode 100644
index 00000000000000..3ea9773eb373c7
--- /dev/null
+++ b/llvm/test/CodeGen/MIR/Generic/machine-basic-block-cleanup-funclet-entry.mir
@@ -0,0 +1,16 @@
+# RUN: llc -run-pass=none -o - %s | FileCheck %s
+
+# Test cleanup-funclet-entry machine basic block attribute
+
+---
+name:            test
+body: |
+  ; CHECK: bb.0 (cleanup-funclet-entry):
+  bb.0 (cleanup-funclet-entry):
+...
+---
+name:            withalign
+body: |
+  ; CHECK: bb.0 (cleanup-funclet-entry, align 8):
+  bb.0 (align 8, cleanup-funclet-entry):
+...



More information about the llvm-branch-commits mailing list