aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/ProfileData/MemProfReader.cpp
diff options
context:
space:
mode:
authormingmingl <mingmingl@google.com>2025-05-15 09:56:52 -0700
committermingmingl <mingmingl@google.com>2025-05-15 09:56:52 -0700
commitd15ae3e73589b50edeb2ab823976734eaa3806e5 (patch)
tree53f7fa084c3d06a60461fea2125e26ec0b07e771 /llvm/lib/ProfileData/MemProfReader.cpp
parent6dd04e46542851b84bf26cd95245399204072085 (diff)
downloadllvm-users/mingmingl-llvm/test.zip
llvm-users/mingmingl-llvm/test.tar.gz
llvm-users/mingmingl-llvm/test.tar.bz2
Support reading and writing data access profiles in memprof v4.users/mingmingl-llvm/test
Diffstat (limited to 'llvm/lib/ProfileData/MemProfReader.cpp')
-rw-r--r--llvm/lib/ProfileData/MemProfReader.cpp30
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