diff options
-rw-r--r-- | llvm/include/llvm/Object/ELFObjectFile.h | 11 | ||||
-rw-r--r-- | llvm/lib/Object/ELFObjectFile.cpp | 4 |
2 files changed, 10 insertions, 5 deletions
diff --git a/llvm/include/llvm/Object/ELFObjectFile.h b/llvm/include/llvm/Object/ELFObjectFile.h index 86f4265..7124df5 100644 --- a/llvm/include/llvm/Object/ELFObjectFile.h +++ b/llvm/include/llvm/Object/ELFObjectFile.h @@ -110,11 +110,12 @@ public: Expected<std::vector<VersionEntry>> readDynsymVersions() const; /// Returns a vector of all BB address maps in the object file. When - // `TextSectionIndex` is specified, only returns the BB address maps - // corresponding to the section with that index. When `PGOAnalyses`is - // specified, the vector is cleared then filled with extra PGO data. - // `PGOAnalyses` will always be the same length as the return value on - // success, otherwise it is empty. + /// `TextSectionIndex` is specified, only returns the BB address maps + /// corresponding to the section with that index. When `PGOAnalyses`is + /// specified (PGOAnalyses is not nullptr), the vector is cleared then filled + /// with extra PGO data. `PGOAnalyses` will always be the same length as the + /// return value when it is requested assuming no error occurs. Upon failure, + /// `PGOAnalyses` will be emptied. Expected<std::vector<BBAddrMap>> readBBAddrMap(std::optional<unsigned> TextSectionIndex = std::nullopt, std::vector<PGOAnalysisMap> *PGOAnalyses = nullptr) const; diff --git a/llvm/lib/Object/ELFObjectFile.cpp b/llvm/lib/Object/ELFObjectFile.cpp index ae21b81..28b96c3 100644 --- a/llvm/lib/Object/ELFObjectFile.cpp +++ b/llvm/lib/Object/ELFObjectFile.cpp @@ -830,6 +830,10 @@ Expected<std::vector<BBAddrMap>> static readBBAddrMapImpl( std::move(BBAddrMapOrErr->begin(), BBAddrMapOrErr->end(), std::back_inserter(BBAddrMaps)); } + if (PGOAnalyses) + assert(PGOAnalyses->size() == BBAddrMaps.size() && + "The same number of BBAddrMaps and PGOAnalysisMaps should be " + "returned when PGO information is requested"); return BBAddrMaps; } |