aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/ProfileData/Coverage/CoverageMapping.cpp
diff options
context:
space:
mode:
authorMike Hommey <mh@glandium.org>2025-01-17 15:56:12 +0900
committerGitHub <noreply@github.com>2025-01-17 07:56:12 +0100
commite8999309f16a248cb14ac09bc1f256cbf202f475 (patch)
tree522c2171fe6a9d33a9ac065cace852e5ef25c07d /llvm/lib/ProfileData/Coverage/CoverageMapping.cpp
parent606d0a7cdc0c551df754eb4494a2c16861b6a9b9 (diff)
downloadllvm-e8999309f16a248cb14ac09bc1f256cbf202f475.zip
llvm-e8999309f16a248cb14ac09bc1f256cbf202f475.tar.gz
llvm-e8999309f16a248cb14ac09bc1f256cbf202f475.tar.bz2
[Coverage] Speed up function record iteration (#122050)
When iterating over function records, filtered by file name, currently, the iteration goes over all the function records, repeatedly for each source file, essentially giving quadratic behavior. 413647d730972eac9675f695c2ea63fb393a5531 sped up some cases by keeping track of the indices of the function records corresponding to each file name. This change expands the use of that map to FunctionRecordIterator. On a test case with Firefox's libxul.so and a 2.5MB profile, this brings down the runtime of `llvm-cov export $lib --instr-profile $prof -t lcov` from 12 minutes with 90% spent in skipOtherFiles to 19 seconds with no samples in skipOtherFiles at all under a sampling profiler (with a sampling interval of 1ms). Fixes #62079
Diffstat (limited to 'llvm/lib/ProfileData/Coverage/CoverageMapping.cpp')
-rw-r--r--llvm/lib/ProfileData/Coverage/CoverageMapping.cpp2
1 files changed, 1 insertions, 1 deletions
diff --git a/llvm/lib/ProfileData/Coverage/CoverageMapping.cpp b/llvm/lib/ProfileData/Coverage/CoverageMapping.cpp
index 6d6678e..c395856 100644
--- a/llvm/lib/ProfileData/Coverage/CoverageMapping.cpp
+++ b/llvm/lib/ProfileData/Coverage/CoverageMapping.cpp
@@ -618,7 +618,7 @@ unsigned CounterMappingContext::getMaxCounterID(const Counter &C) const {
void FunctionRecordIterator::skipOtherFiles() {
while (Current != Records.end() && !Filename.empty() &&
Filename != Current->Filenames[0])
- ++Current;
+ advanceOne();
if (Current == Records.end())
*this = FunctionRecordIterator();
}