diff options
Diffstat (limited to 'backend/lib/MIR/MIRDocumentReferenceValidation.cpp')
| -rw-r--r-- | backend/lib/MIR/MIRDocumentReferenceValidation.cpp | 18 |
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"); |
