https://github.com/arsenm created https://github.com/llvm/llvm-project/pull/227196
Co-Authored-By: Claude Sonnet 5 <[email protected]> >From 418d1ff60497108767d7abbbec74035f44815199 Mon Sep 17 00:00:00 2001 From: Matt Arsenault <[email protected]> Date: Tue, 29 Sep 2026 08:15:26 +0200 Subject: [PATCH] MIR: Serialize MachineBasicBlock::IsEHContTarget Co-Authored-By: Claude Sonnet 5 <[email protected]> --- 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-ehcont-target.mir | 16 ++++++++++++++++ 5 files changed, 29 insertions(+) create mode 100644 llvm/test/CodeGen/MIR/Generic/machine-basic-block-ehcont-target.mir diff --git a/llvm/lib/CodeGen/MIRParser/MILexer.cpp b/llvm/lib/CodeGen/MIRParser/MILexer.cpp index d686be44b3ba7..a07047a25bb63 100644 --- a/llvm/lib/CodeGen/MIRParser/MILexer.cpp +++ b/llvm/lib/CodeGen/MIRParser/MILexer.cpp @@ -281,6 +281,7 @@ static MIToken::TokenKind getIdentifierKind(StringRef Identifier) { .Case("ehscope-entry", MIToken::kw_ehscope_entry) .Case("ehfunclet-entry", MIToken::kw_ehfunclet_entry) .Case("cleanup-funclet-entry", MIToken::kw_cleanup_funclet_entry) + .Case("ehcont-target", MIToken::kw_ehcont_target) .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 0548cc2fe1baa..6c27eff9cd4da 100644 --- a/llvm/lib/CodeGen/MIRParser/MILexer.h +++ b/llvm/lib/CodeGen/MIRParser/MILexer.h @@ -135,6 +135,7 @@ struct MIToken { kw_ehscope_entry, kw_ehfunclet_entry, kw_cleanup_funclet_entry, + kw_ehcont_target, kw_liveins, kw_successors, kw_floatpred, diff --git a/llvm/lib/CodeGen/MIRParser/MIParser.cpp b/llvm/lib/CodeGen/MIRParser/MIParser.cpp index b74730689c4cf..64ee526f4119a 100644 --- a/llvm/lib/CodeGen/MIRParser/MIParser.cpp +++ b/llvm/lib/CodeGen/MIRParser/MIParser.cpp @@ -745,6 +745,7 @@ bool MIParser::parseBasicBlockDefinition( bool IsEHFuncletEntry = false; bool IsEHScopeEntry = false; bool IsCleanupFuncletEntry = false; + bool IsEHContTarget = false; std::optional<MBBSectionID> SectionID; uint64_t Alignment = 0; unsigned MaxBytesForAlignment = 0; @@ -783,6 +784,10 @@ bool MIParser::parseBasicBlockDefinition( IsCleanupFuncletEntry = true; lex(); break; + case MIToken::kw_ehcont_target: + IsEHContTarget = true; + lex(); + break; case MIToken::kw_align: if (parseAlignment(Alignment)) return true; @@ -848,6 +853,7 @@ bool MIParser::parseBasicBlockDefinition( MBB->setIsEHFuncletEntry(IsEHFuncletEntry); MBB->setIsEHScopeEntry(IsEHScopeEntry); MBB->setIsCleanupFuncletEntry(IsCleanupFuncletEntry); + MBB->setIsEHContTarget(IsEHContTarget); if (SectionID) { MBB->setSectionID(*SectionID); MF.setBBSectionsType(BasicBlockSection::List); diff --git a/llvm/lib/CodeGen/MachineBasicBlock.cpp b/llvm/lib/CodeGen/MachineBasicBlock.cpp index fbf79d0eb2f9c..c829411ab23c4 100644 --- a/llvm/lib/CodeGen/MachineBasicBlock.cpp +++ b/llvm/lib/CodeGen/MachineBasicBlock.cpp @@ -567,6 +567,11 @@ void MachineBasicBlock::printName(raw_ostream &os, unsigned printNameFlags, os << "cleanup-funclet-entry"; hasAttributes = true; } + if (isEHContTarget()) { + os << (hasAttributes ? ", " : " ("); + os << "ehcont-target"; + hasAttributes = true; + } if (getAlignment() != Align(1)) { os << (hasAttributes ? ", " : " ("); os << "align " << getAlignment().value(); diff --git a/llvm/test/CodeGen/MIR/Generic/machine-basic-block-ehcont-target.mir b/llvm/test/CodeGen/MIR/Generic/machine-basic-block-ehcont-target.mir new file mode 100644 index 0000000000000..87fa501e8830d --- /dev/null +++ b/llvm/test/CodeGen/MIR/Generic/machine-basic-block-ehcont-target.mir @@ -0,0 +1,16 @@ +# RUN: llc -run-pass=none -o - %s | FileCheck %s + +# Test ehcont-target machine basic block attribute + +--- +name: test +body: | + ; CHECK: bb.0 (ehcont-target): + bb.0 (ehcont-target): +... +--- +name: withalign +body: | + ; CHECK: bb.0 (ehcont-target, align 8): + bb.0 (align 8, ehcont-target): +... _______________________________________________ llvm-branch-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
