[llvm-branch-commits] [llvm] cc4b572 - [MIR] Add parsing for ehscope_entry. (#175592)

Cullen Rhodes via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Tue Jan 13 02:21:19 PST 2026


Author: David Green
Date: 2026-01-13T10:18:55Z
New Revision: cc4b5725f3cdfd7e008f68f6707d79133a4880f3

URL: https://github.com/llvm/llvm-project/commit/cc4b5725f3cdfd7e008f68f6707d79133a4880f3
DIFF: https://github.com/llvm/llvm-project/commit/cc4b5725f3cdfd7e008f68f6707d79133a4880f3.diff

LOG: [MIR] Add parsing for ehscope_entry. (#175592)

This makes sure that IsEHScopeEntry is written and can be re-parsed.

Added: 
    llvm/test/CodeGen/MIR/Generic/machine-basic-block-ehscope-entry.mir

Modified: 
    llvm/lib/CodeGen/MIRParser/MILexer.cpp
    llvm/lib/CodeGen/MIRParser/MILexer.h
    llvm/lib/CodeGen/MIRParser/MIParser.cpp
    llvm/lib/CodeGen/MachineBasicBlock.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/lib/CodeGen/MIRParser/MILexer.cpp b/llvm/lib/CodeGen/MIRParser/MILexer.cpp
index aa79aad781ee8..f9852c6c889b8 100644
--- a/llvm/lib/CodeGen/MIRParser/MILexer.cpp
+++ b/llvm/lib/CodeGen/MIRParser/MILexer.cpp
@@ -271,6 +271,7 @@ static MIToken::TokenKind getIdentifierKind(StringRef Identifier) {
       .Case("landing-pad", MIToken::kw_landing_pad)
       .Case("inlineasm-br-indirect-target",
             MIToken::kw_inlineasm_br_indirect_target)
+      .Case("ehscope-entry", MIToken::kw_ehscope_entry)
       .Case("ehfunclet-entry", MIToken::kw_ehfunclet_entry)
       .Case("liveins", MIToken::kw_liveins)
       .Case("successors", MIToken::kw_successors)

diff  --git a/llvm/lib/CodeGen/MIRParser/MILexer.h b/llvm/lib/CodeGen/MIRParser/MILexer.h
index ff4c0c6f6d59d..a9dc9af6858da 100644
--- a/llvm/lib/CodeGen/MIRParser/MILexer.h
+++ b/llvm/lib/CodeGen/MIRParser/MILexer.h
@@ -126,6 +126,7 @@ struct MIToken {
     kw_liveout,
     kw_landing_pad,
     kw_inlineasm_br_indirect_target,
+    kw_ehscope_entry,
     kw_ehfunclet_entry,
     kw_liveins,
     kw_successors,

diff  --git a/llvm/lib/CodeGen/MIRParser/MIParser.cpp b/llvm/lib/CodeGen/MIRParser/MIParser.cpp
index 51862b501cc47..baac77fbd2dc0 100644
--- a/llvm/lib/CodeGen/MIRParser/MIParser.cpp
+++ b/llvm/lib/CodeGen/MIRParser/MIParser.cpp
@@ -719,6 +719,7 @@ bool MIParser::parseBasicBlockDefinition(
   bool IsLandingPad = false;
   bool IsInlineAsmBrIndirectTarget = false;
   bool IsEHFuncletEntry = false;
+  bool IsEHScopeEntry = false;
   std::optional<MBBSectionID> SectionID;
   uint64_t Alignment = 0;
   std::optional<UniqueBBID> BBID;
@@ -748,6 +749,10 @@ bool MIParser::parseBasicBlockDefinition(
         IsEHFuncletEntry = true;
         lex();
         break;
+      case MIToken::kw_ehscope_entry:
+        IsEHScopeEntry = true;
+        lex();
+        break;
       case MIToken::kw_align:
         if (parseAlignment(Alignment))
           return true;
@@ -804,6 +809,7 @@ bool MIParser::parseBasicBlockDefinition(
   MBB->setIsEHPad(IsLandingPad);
   MBB->setIsInlineAsmBrIndirectTarget(IsInlineAsmBrIndirectTarget);
   MBB->setIsEHFuncletEntry(IsEHFuncletEntry);
+  MBB->setIsEHScopeEntry(IsEHScopeEntry);
   if (SectionID) {
     MBB->setSectionID(*SectionID);
     MF.setBBSectionsType(BasicBlockSection::List);

diff  --git a/llvm/lib/CodeGen/MachineBasicBlock.cpp b/llvm/lib/CodeGen/MachineBasicBlock.cpp
index ba0f9c3f64ada..f5634567d8988 100644
--- a/llvm/lib/CodeGen/MachineBasicBlock.cpp
+++ b/llvm/lib/CodeGen/MachineBasicBlock.cpp
@@ -551,6 +551,11 @@ void MachineBasicBlock::printName(raw_ostream &os, unsigned printNameFlags,
       os << "ehfunclet-entry";
       hasAttributes = true;
     }
+    if (isEHScopeEntry()) {
+      os << (hasAttributes ? ", " : " (");
+      os << "ehscope-entry";
+      hasAttributes = true;
+    }
     if (getAlignment() != Align(1)) {
       os << (hasAttributes ? ", " : " (");
       os << "align " << getAlignment().value();

diff  --git a/llvm/test/CodeGen/MIR/Generic/machine-basic-block-ehscope-entry.mir b/llvm/test/CodeGen/MIR/Generic/machine-basic-block-ehscope-entry.mir
new file mode 100644
index 0000000000000..c6bdf594c2395
--- /dev/null
+++ b/llvm/test/CodeGen/MIR/Generic/machine-basic-block-ehscope-entry.mir
@@ -0,0 +1,16 @@
+# RUN: llc -run-pass none -o - %s 2>&1 | FileCheck %s
+
+# Test ehscope-entry machine basic block parameters
+
+---
+name:            test
+body: |
+  ; CHECK: bb.0 (ehscope-entry):
+  bb.0 (ehscope-entry):
+...
+---
+name:            withalign
+body: |
+  ; CHECK: bb.0 (ehscope-entry, align 8):
+  bb.0 (align 8, ehscope-entry):
+...


        


More information about the llvm-branch-commits mailing list