diff options
author | NAKAMURA Takumi <geek4civic@gmail.com> | 2025-01-09 18:15:55 +0900 |
---|---|---|
committer | NAKAMURA Takumi <geek4civic@gmail.com> | 2025-01-09 18:15:55 +0900 |
commit | bdcf47e4bcb92889665825654bb80a8bbe30379e (patch) | |
tree | 4de1d6b4ddc69f4f32daabb11ad5c71ab0cf895e /llvm/tools/llvm-profgen/PerfReader.cpp | |
parent | e7fd5cd25334048980ea207a9eff72698724721a (diff) | |
parent | fea7da1b00cc97d742faede2df96c7d327950f49 (diff) | |
download | llvm-users/chapuni/cov/single/base.zip llvm-users/chapuni/cov/single/base.tar.gz llvm-users/chapuni/cov/single/base.tar.bz2 |
Merge branch 'users/chapuni/cov/single/nextcount' into users/chapuni/cov/single/baseusers/chapuni/cov/single/base
Diffstat (limited to 'llvm/tools/llvm-profgen/PerfReader.cpp')
-rw-r--r-- | llvm/tools/llvm-profgen/PerfReader.cpp | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/llvm/tools/llvm-profgen/PerfReader.cpp b/llvm/tools/llvm-profgen/PerfReader.cpp index 111c546..ad113ed 100644 --- a/llvm/tools/llvm-profgen/PerfReader.cpp +++ b/llvm/tools/llvm-profgen/PerfReader.cpp @@ -42,6 +42,11 @@ static cl::opt<bool> cl::opt<bool> ShowDetailedWarning("show-detailed-warning", cl::desc("Show detailed warning message.")); +static cl::opt<int> CSProfMaxUnsymbolizedCtxDepth( + "csprof-max-unsymbolized-context-depth", cl::init(-1), + cl::desc("Keep the last K contexts while merging unsymbolized profile. -1 " + "means no depth limit.")); + extern cl::opt<std::string> PerfTraceFilename; extern cl::opt<bool> ShowDisassemblyOnly; extern cl::opt<bool> ShowSourceLocations; @@ -172,7 +177,19 @@ std::shared_ptr<AddrBasedCtxKey> AddressStack::getContextKey() { std::shared_ptr<AddrBasedCtxKey> KeyStr = std::make_shared<AddrBasedCtxKey>(); KeyStr->Context = Stack; CSProfileGenerator::compressRecursionContext<uint64_t>(KeyStr->Context); - CSProfileGenerator::trimContext<uint64_t>(KeyStr->Context); + // MaxContextDepth(--csprof-max-context-depth) is used to trim both symbolized + // and unsymbolized profile context. Sometimes we want to at least preserve + // the inlinings for the leaf frame(the profiled binary inlining), + // --csprof-max-context-depth may not be flexible enough, in this case, + // --csprof-max-unsymbolized-context-depth is used to limit the context for + // unsymbolized profile. If both are set, use the minimum of them. + int Depth = CSProfileGenerator::MaxContextDepth != -1 + ? CSProfileGenerator::MaxContextDepth + : KeyStr->Context.size(); + Depth = CSProfMaxUnsymbolizedCtxDepth != -1 + ? std::min(static_cast<int>(CSProfMaxUnsymbolizedCtxDepth), Depth) + : Depth; + CSProfileGenerator::trimContext<uint64_t>(KeyStr->Context, Depth); return KeyStr; } |