aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/ProfileData/InstrProfWriter.cpp
diff options
context:
space:
mode:
authorNathan Slingerland <slingn@gmail.com>2015-12-02 18:19:24 +0000
committerNathan Slingerland <slingn@gmail.com>2015-12-02 18:19:24 +0000
commitaa5702d92b75427d9900703c0b4226f9bb24d1d4 (patch)
tree1ed72cfb44966d882db475e8e51fb83d94cb253d /llvm/lib/ProfileData/InstrProfWriter.cpp
parentf520eff7827912ab1f9aa2dd08fcd2b0bfa4f945 (diff)
downloadllvm-aa5702d92b75427d9900703c0b4226f9bb24d1d4.zip
llvm-aa5702d92b75427d9900703c0b4226f9bb24d1d4.tar.gz
llvm-aa5702d92b75427d9900703c0b4226f9bb24d1d4.tar.bz2
[llvm-profdata] Change instr prof counter overflow to saturate rather than discard
Summary: This changes overflow handling during instrumentation profile merge. Rathar than throwing away records that would result in counter overflow, merged counts are instead clamped to the maximum representable value. A warning about counter overflow is still surfaced to the user as before. Reviewers: dnovillo, davidxl, silvas Subscribers: llvm-commits Differential Revision: http://reviews.llvm.org/D14893 llvm-svn: 254525
Diffstat (limited to 'llvm/lib/ProfileData/InstrProfWriter.cpp')
-rw-r--r--llvm/lib/ProfileData/InstrProfWriter.cpp11
1 files changed, 6 insertions, 5 deletions
diff --git a/llvm/lib/ProfileData/InstrProfWriter.cpp b/llvm/lib/ProfileData/InstrProfWriter.cpp
index f9cc2af..78bec01 100644
--- a/llvm/lib/ProfileData/InstrProfWriter.cpp
+++ b/llvm/lib/ProfileData/InstrProfWriter.cpp
@@ -107,22 +107,23 @@ std::error_code InstrProfWriter::addRecord(InstrProfRecord &&I) {
std::tie(Where, NewFunc) =
ProfileDataMap.insert(std::make_pair(I.Hash, InstrProfRecord()));
InstrProfRecord &Dest = Where->second;
+
+ instrprof_error Result;
if (NewFunc) {
// We've never seen a function with this name and hash, add it.
Dest = std::move(I);
+ Result = instrprof_error::success;
} else {
// We're updating a function we've seen before.
- instrprof_error MergeResult = Dest.merge(I);
- if (MergeResult != instrprof_error::success) {
- return MergeResult;
- }
+ Result = Dest.merge(I);
}
// We keep track of the max function count as we go for simplicity.
+ // Update this statistic no matter the result of the merge.
if (Dest.Counts[0] > MaxFunctionCount)
MaxFunctionCount = Dest.Counts[0];
- return instrprof_error::success;
+ return Result;
}
std::pair<uint64_t, uint64_t> InstrProfWriter::writeImpl(raw_ostream &OS) {