diff options
author | Wenlei He <aktoon@gmail.com> | 2021-09-01 14:37:18 -0700 |
---|---|---|
committer | Wenlei He <aktoon@gmail.com> | 2021-09-01 14:42:00 -0700 |
commit | 4ef88031f52f7c21356295e609ecea3c10d29d9f (patch) | |
tree | 60fbc59324d407b8a7adebd636ec805fa04e4a34 /llvm/tools/llvm-profdata/llvm-profdata.cpp | |
parent | 4b04d54206a5b7f549af9a2f0a9588ee8e933eb2 (diff) | |
download | llvm-4ef88031f52f7c21356295e609ecea3c10d29d9f.zip llvm-4ef88031f52f7c21356295e609ecea3c10d29d9f.tar.gz llvm-4ef88031f52f7c21356295e609ecea3c10d29d9f.tar.bz2 |
[llvm-profdata] Fix assertion from invalid iterator
Differential Revision: https://reviews.llvm.org/D109096
Diffstat (limited to 'llvm/tools/llvm-profdata/llvm-profdata.cpp')
-rw-r--r-- | llvm/tools/llvm-profdata/llvm-profdata.cpp | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/llvm/tools/llvm-profdata/llvm-profdata.cpp b/llvm/tools/llvm-profdata/llvm-profdata.cpp index 488dc8f..6692c54 100644 --- a/llvm/tools/llvm-profdata/llvm-profdata.cpp +++ b/llvm/tools/llvm-profdata/llvm-profdata.cpp @@ -1633,6 +1633,7 @@ void SampleOverlapAggregator::computeSampleProfileOverlap(raw_fd_ostream &OS) { "except inlinees"); FuncOverlap.TestSample = TestStats[FuncOverlap.TestName].SampleSum; + bool Matched = false; const auto Match = BaseFuncProf.find(FuncOverlap.TestName); if (Match == BaseFuncProf.end()) { const FuncSampleStats &FuncStats = TestStats[FuncOverlap.TestName]; @@ -1677,6 +1678,7 @@ void SampleOverlapAggregator::computeSampleProfileOverlap(raw_fd_ostream &OS) { // Remove matched base functions for later reporting functions not found // in test profile. BaseFuncProf.erase(Match); + Matched = true; } // Print function-level similarity information if specified by options. @@ -1684,9 +1686,8 @@ void SampleOverlapAggregator::computeSampleProfileOverlap(raw_fd_ostream &OS) { "TestStats should have records for all functions in test profile " "except inlinees"); if (TestStats[FuncOverlap.TestName].MaxSample >= FuncFilter.ValueCutoff || - (Match != BaseFuncProf.end() && - FuncOverlap.Similarity < LowSimilarityThreshold) || - (Match != BaseFuncProf.end() && !FuncFilter.NameFilter.empty() && + (Matched && FuncOverlap.Similarity < LowSimilarityThreshold) || + (Matched && !FuncFilter.NameFilter.empty() && FuncOverlap.BaseName.toString().find(FuncFilter.NameFilter) != std::string::npos)) { assert(ProfOverlap.BaseSample > 0 && |