[llvm] 4ef8803 - [llvm-profdata] Fix assertion from invalid iterator
Wenlei He via llvm-commits
llvm-commits at lists.llvm.org
Wed Sep 1 14:42:13 PDT 2021
Author: Wenlei He
Date: 2021-09-01T14:42:00-07:00
New Revision: 4ef88031f52f7c21356295e609ecea3c10d29d9f
URL: https://github.com/llvm/llvm-project/commit/4ef88031f52f7c21356295e609ecea3c10d29d9f
DIFF: https://github.com/llvm/llvm-project/commit/4ef88031f52f7c21356295e609ecea3c10d29d9f.diff
LOG: [llvm-profdata] Fix assertion from invalid iterator
Differential Revision: https://reviews.llvm.org/D109096
Added:
Modified:
llvm/tools/llvm-profdata/llvm-profdata.cpp
Removed:
################################################################################
diff --git a/llvm/tools/llvm-profdata/llvm-profdata.cpp b/llvm/tools/llvm-profdata/llvm-profdata.cpp
index 488dc8fa4317c..6692c54755af2 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 &&
More information about the llvm-commits
mailing list