diff options
| author | Dimitry Andric <dim@FreeBSD.org> | 2023-12-17 20:41:09 +0000 |
|---|---|---|
| committer | Dimitry Andric <dim@FreeBSD.org> | 2023-12-17 20:41:09 +0000 |
| commit | 312c0ed19cc5276a17bacf2120097bec4515b0f1 (patch) | |
| tree | e6e4a4163840b73ba54bb0d3b70ee4899e4b7434 /llvm/lib/Object/ELFObjectFile.cpp | |
| parent | b1c73532ee8997fe5dfbeb7d223027bdf99758a0 (diff) | |
Diffstat (limited to 'llvm/lib/Object/ELFObjectFile.cpp')
| -rw-r--r-- | llvm/lib/Object/ELFObjectFile.cpp | 23 |
1 files changed, 15 insertions, 8 deletions
diff --git a/llvm/lib/Object/ELFObjectFile.cpp b/llvm/lib/Object/ELFObjectFile.cpp index 25dbcbd68431..3c86b0f25dda 100644 --- a/llvm/lib/Object/ELFObjectFile.cpp +++ b/llvm/lib/Object/ELFObjectFile.cpp @@ -716,10 +716,13 @@ std::vector<ELFPltEntry> ELFObjectFileBase::getPltEntries() const { template <class ELFT> Expected<std::vector<BBAddrMap>> static readBBAddrMapImpl( - const ELFFile<ELFT> &EF, std::optional<unsigned> TextSectionIndex) { + const ELFFile<ELFT> &EF, std::optional<unsigned> TextSectionIndex, + std::vector<PGOAnalysisMap> *PGOAnalyses) { using Elf_Shdr = typename ELFT::Shdr; bool IsRelocatable = EF.getHeader().e_type == ELF::ET_REL; std::vector<BBAddrMap> BBAddrMaps; + if (PGOAnalyses) + PGOAnalyses->clear(); const auto &Sections = cantFail(EF.sections()); auto IsMatch = [&](const Elf_Shdr &Sec) -> Expected<bool> { @@ -748,10 +751,13 @@ Expected<std::vector<BBAddrMap>> static readBBAddrMapImpl( return createError("unable to get relocation section for " + describe(EF, *Sec)); Expected<std::vector<BBAddrMap>> BBAddrMapOrErr = - EF.decodeBBAddrMap(*Sec, RelocSec); - if (!BBAddrMapOrErr) + EF.decodeBBAddrMap(*Sec, RelocSec, PGOAnalyses); + if (!BBAddrMapOrErr) { + if (PGOAnalyses) + PGOAnalyses->clear(); return createError("unable to read " + describe(EF, *Sec) + ": " + toString(BBAddrMapOrErr.takeError())); + } std::move(BBAddrMapOrErr->begin(), BBAddrMapOrErr->end(), std::back_inserter(BBAddrMaps)); } @@ -828,13 +834,14 @@ ELFObjectFileBase::readDynsymVersions() const { } Expected<std::vector<BBAddrMap>> ELFObjectFileBase::readBBAddrMap( - std::optional<unsigned> TextSectionIndex) const { + std::optional<unsigned> TextSectionIndex, + std::vector<PGOAnalysisMap> *PGOAnalyses) const { if (const auto *Obj = dyn_cast<ELF32LEObjectFile>(this)) - return readBBAddrMapImpl(Obj->getELFFile(), TextSectionIndex); + return readBBAddrMapImpl(Obj->getELFFile(), TextSectionIndex, PGOAnalyses); if (const auto *Obj = dyn_cast<ELF64LEObjectFile>(this)) - return readBBAddrMapImpl(Obj->getELFFile(), TextSectionIndex); + return readBBAddrMapImpl(Obj->getELFFile(), TextSectionIndex, PGOAnalyses); if (const auto *Obj = dyn_cast<ELF32BEObjectFile>(this)) - return readBBAddrMapImpl(Obj->getELFFile(), TextSectionIndex); + return readBBAddrMapImpl(Obj->getELFFile(), TextSectionIndex, PGOAnalyses); return readBBAddrMapImpl(cast<ELF64BEObjectFile>(this)->getELFFile(), - TextSectionIndex); + TextSectionIndex, PGOAnalyses); } |
