diff options
Diffstat (limited to 'llvm/lib/ProfileData/MemProfReader.cpp')
-rw-r--r-- | llvm/lib/ProfileData/MemProfReader.cpp | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/llvm/lib/ProfileData/MemProfReader.cpp b/llvm/lib/ProfileData/MemProfReader.cpp index e0f280b..7fe5145 100644 --- a/llvm/lib/ProfileData/MemProfReader.cpp +++ b/llvm/lib/ProfileData/MemProfReader.cpp @@ -37,6 +37,7 @@ #include "llvm/Support/Debug.h" #include "llvm/Support/Endian.h" #include "llvm/Support/Error.h" +#include "llvm/Support/ErrorHandling.h" #include "llvm/Support/MemoryBuffer.h" #include "llvm/Support/Path.h" @@ -823,6 +824,35 @@ void YAMLMemProfReader::parse(StringRef YAMLData) { MemProfData.Records.try_emplace(GUID, std::move(IndexedRecord)); } + + if (Doc.YamlifiedDataAccessProfiles.isEmpty()) + return; + + auto ToSymHandleRef = [](data_access_prof::SymbolHandle Handle) + -> data_access_prof::SymbolHandleRef { + if (std::holds_alternative<std::string>(Handle)) + return StringRef(std::get<std::string>(Handle)); + return std::get<uint64_t>(Handle); + }; + + auto DataAccessProfileData = + std::make_unique<data_access_prof::DataAccessProfData>(); + for (const auto &Record : Doc.YamlifiedDataAccessProfiles.Records) + if (Error E = DataAccessProfileData->setDataAccessProfile( + ToSymHandleRef(Record.SymHandle), Record.AccessCount, + Record.Locations)) + reportFatalInternalError(std::move(E)); + + for (const uint64_t Hash : Doc.YamlifiedDataAccessProfiles.KnownColdHashes) + if (Error E = DataAccessProfileData->addKnownSymbolWithoutSamples(Hash)) + reportFatalInternalError(std::move(E)); + + for (const std::string &Sym : + Doc.YamlifiedDataAccessProfiles.KnownColdSymbols) + if (Error E = DataAccessProfileData->addKnownSymbolWithoutSamples(Sym)) + reportFatalInternalError(std::move(E)); + + setDataAccessProfileData(std::move(DataAccessProfileData)); } } // namespace memprof } // namespace llvm |