aboutsummaryrefslogtreecommitdiff
path: root/llvm/tools/llvm-profdata/llvm-profdata.cpp
diff options
context:
space:
mode:
authorKazu Hirata <kazu@google.com>2024-03-28 14:29:34 -0700
committerGitHub <noreply@github.com>2024-03-28 14:29:34 -0700
commit44253a9ce6de749aee06057e578fb3ccbcda3ffd (patch)
treed7b58023a9c68cc1860a3c068f9006c44ac32c10 /llvm/tools/llvm-profdata/llvm-profdata.cpp
parent17c3f102be328b8a2d065cdbc230ccacfa9046a9 (diff)
downloadllvm-44253a9ce6de749aee06057e578fb3ccbcda3ffd.zip
llvm-44253a9ce6de749aee06057e578fb3ccbcda3ffd.tar.gz
llvm-44253a9ce6de749aee06057e578fb3ccbcda3ffd.tar.bz2
[memprof] Add MemProf version (#86414)
This patch adds a version field to the MemProf section of the indexed profile format, calling the new version "version 1". The existing version is called "version 0". The writer supports both versions via a command-line option: llvm-profdata merge --memprof-version=1 ... The reader supports both versions by automatically detecting the version from the header.
Diffstat (limited to 'llvm/tools/llvm-profdata/llvm-profdata.cpp')
-rw-r--r--llvm/tools/llvm-profdata/llvm-profdata.cpp10
1 files changed, 9 insertions, 1 deletions
diff --git a/llvm/tools/llvm-profdata/llvm-profdata.cpp b/llvm/tools/llvm-profdata/llvm-profdata.cpp
index 3a7bd06..e8ee3c2 100644
--- a/llvm/tools/llvm-profdata/llvm-profdata.cpp
+++ b/llvm/tools/llvm-profdata/llvm-profdata.cpp
@@ -300,6 +300,13 @@ cl::opt<bool> DoWritePrevVersion(
cl::desc("Write the previous version of indexed format, to enable "
"some forward compatibility."));
+cl::opt<memprof::IndexedVersion> MemProfVersionRequested(
+ "memprof-version", cl::Hidden, cl::sub(MergeSubcommand),
+ cl::desc("Specify the version of the memprof format to use"),
+ cl::init(memprof::Version0),
+ cl::values(clEnumValN(memprof::Version0, "0", "version 0"),
+ clEnumValN(memprof::Version1, "1", "version 1")));
+
// Options specific to overlap subcommand.
cl::opt<std::string> BaseFilename(cl::Positional, cl::Required,
cl::desc("<base profile file>"),
@@ -588,7 +595,8 @@ struct WriterContext {
WriterContext(bool IsSparse, std::mutex &ErrLock,
SmallSet<instrprof_error, 4> &WriterErrorCodes,
uint64_t ReservoirSize = 0, uint64_t MaxTraceLength = 0)
- : Writer(IsSparse, ReservoirSize, MaxTraceLength, DoWritePrevVersion),
+ : Writer(IsSparse, ReservoirSize, MaxTraceLength, DoWritePrevVersion,
+ MemProfVersionRequested),
ErrLock(ErrLock), WriterErrorCodes(WriterErrorCodes) {}
};