aboutsummaryrefslogtreecommitdiff
path: root/backend/lib/MIR/MIRDocumentReferenceValidation.cpp
diff options
context:
space:
mode:
authorRichard-Qin-X <richard.qin.001@gmail.com>2026-08-11 17:37:42 +0800
committerRichard-Qin-X <richard.qin.001@gmail.com>2026-08-11 17:37:42 +0800
commit6a7b083f322f4ac47e58cbf9d4d5fd4d1f6fecd0 (patch)
treef363c502f0e2b9cda2f12928049275a433db6ad4 /backend/lib/MIR/MIRDocumentReferenceValidation.cpp
parentadcf8c9b1bd1b47e00bf859693112cea1f7e8c9f (diff)
downloadrcc-project-6a7b083f322f4ac47e58cbf9d4d5fd4d1f6fecd0.tar.gz
rcc-project-6a7b083f322f4ac47e58cbf9d4d5fd4d1f6fecd0.tar.xz
[MIR] Accept fixed-baseline LLVM syntax
Diffstat (limited to 'backend/lib/MIR/MIRDocumentReferenceValidation.cpp')
-rw-r--r--backend/lib/MIR/MIRDocumentReferenceValidation.cpp18
1 files changed, 17 insertions, 1 deletions
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<void> 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");