From 6a7b083f322f4ac47e58cbf9d4d5fd4d1f6fecd0 Mon Sep 17 00:00:00 2001 From: Richard-Qin-X Date: Tue, 11 Aug 2026 17:37:42 +0800 Subject: [MIR] Accept fixed-baseline LLVM syntax --- backend/lib/MIR/MIRDocumentReferenceValidation.cpp | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) (limited to 'backend/lib/MIR/MIRDocumentReferenceValidation.cpp') diff --git a/backend/lib/MIR/MIRDocumentReferenceValidation.cpp b/backend/lib/MIR/MIRDocumentReferenceValidation.cpp index a6dbb56..69b0dd1 100644 --- a/backend/lib/MIR/MIRDocumentReferenceValidation.cpp +++ b/backend/lib/MIR/MIRDocumentReferenceValidation.cpp @@ -27,7 +27,23 @@ Expected verifyMIRDocumentReferences(const MIRDocument &Document, const EmbeddedIRReferenceIndex *Embedded = UseEmbeddedIR ? Document.embeddedIR() : nullptr; const EmbeddedIRFunction *IRFunction = nullptr; if (Embedded != nullptr) { - IRFunction = Embedded->function(Function.name()); + if (Function.name().empty()) { + std::size_t AnonymousOrdinal = 0; + bool FoundFunction = false; + for (std::size_t Index = 0; Index < Document.unit().functionCount(); ++Index) { + const MachineFunction *Candidate = Document.unit().functionAt(Index); + if (Candidate == &Function) { + FoundFunction = true; + break; + } + if (Candidate != nullptr && Candidate->name().empty()) + ++AnonymousOrdinal; + } + if (FoundFunction) + IRFunction = Embedded->unnamedFunction(AnonymousOrdinal); + } else { + IRFunction = Embedded->function(Function.name()); + } if (IRFunction == nullptr) { return makeUnexpected(ErrorCode::VerificationError, "machine function has no matching embedded LLVM IR function"); -- cgit v1.2.3