diff options
author | NAKAMURA Takumi <geek4civic@gmail.com> | 2025-01-09 17:50:40 +0900 |
---|---|---|
committer | NAKAMURA Takumi <geek4civic@gmail.com> | 2025-01-09 17:50:40 +0900 |
commit | fea7da1b00cc97d742faede2df96c7d327950f49 (patch) | |
tree | 4de1d6b4ddc69f4f32daabb11ad5c71ab0cf895e /llvm/tools/llvm-profgen/PerfReader.cpp | |
parent | 9b99dde0d47102625d93c5d1cbbc04951025a6c9 (diff) | |
parent | 0aa930a41f2d1ebf1fa90ec42da8f96d15a4dcbb (diff) | |
download | llvm-users/chapuni/cov/single/nextcount.zip llvm-users/chapuni/cov/single/nextcount.tar.gz llvm-users/chapuni/cov/single/nextcount.tar.bz2 |
Merge branch 'users/chapuni/cov/single/nextcount-base' into users/chapuni/cov/single/nextcountusers/chapuni/cov/single/nextcount
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; } |