summaryrefslogtreecommitdiffstats
path: root/llvm/tools/llvm-profdata
diff options
context:
space:
mode:
authorDavid Blaikie <dblaikie@gmail.com>2017-07-10 03:04:59 +0000
committerDavid Blaikie <dblaikie@gmail.com>2017-07-10 03:04:59 +0000
commit98cce00371d271c9da8de806e4cc4c886a85d56c (patch)
tree7bf32e24c96e9efc62e1c316ab80b595c02a5fba /llvm/tools/llvm-profdata
parent625cc0ecaf2621cc779780826922e012502e2fa6 (diff)
downloadbcm5719-llvm-98cce00371d271c9da8de806e4cc4c886a85d56c.tar.gz
bcm5719-llvm-98cce00371d271c9da8de806e4cc4c886a85d56c.zip
llvm-profdata: Reduce memory usage by using Error callback rather than member
Reduces llvm-profdata memory usage on a large profile from 7.8GB to 5.1GB. The ProfData API now supports reporting all the errors/warnings rather than only the first, though llvm-profdata ignores everything after the first for now to preserve existing behavior. (if there's a desire for other behavior, happy to implement that - but might be as well left for a separate patch) Reviewers: davidxl Differential Revision: https://reviews.llvm.org/D35149 llvm-svn: 307516
Diffstat (limited to 'llvm/tools/llvm-profdata')
-rw-r--r--llvm/tools/llvm-profdata/llvm-profdata.cpp19
1 files changed, 16 insertions, 3 deletions
diff --git a/llvm/tools/llvm-profdata/llvm-profdata.cpp b/llvm/tools/llvm-profdata/llvm-profdata.cpp
index bcc16f364a2..f7d1c622f8f 100644
--- a/llvm/tools/llvm-profdata/llvm-profdata.cpp
+++ b/llvm/tools/llvm-profdata/llvm-profdata.cpp
@@ -159,14 +159,20 @@ static void loadInput(const WeightedFile &Input, WriterContext *WC) {
for (auto &I : *Reader) {
const StringRef FuncName = I.Name;
- if (Error E = WC->Writer.addRecord(std::move(I), Input.Weight)) {
+ bool Reported = false;
+ WC->Writer.addRecord(std::move(I), Input.Weight, [&](Error E) {
+ if (Reported) {
+ consumeError(std::move(E));
+ return;
+ }
+ Reported = true;
// Only show hint the first time an error occurs.
instrprof_error IPE = InstrProfError::take(std::move(E));
std::unique_lock<std::mutex> ErrGuard{WC->ErrLock};
bool firstTime = WC->WriterErrorCodes.insert(IPE).second;
handleMergeWriterError(make_error<InstrProfError>(IPE), Input.Filename,
FuncName, firstTime);
- }
+ });
}
if (Reader->hasError())
WC->Err = Reader->getError();
@@ -174,8 +180,15 @@ static void loadInput(const WeightedFile &Input, WriterContext *WC) {
/// Merge the \p Src writer context into \p Dst.
static void mergeWriterContexts(WriterContext *Dst, WriterContext *Src) {
- if (Error E = Dst->Writer.mergeRecordsFromWriter(std::move(Src->Writer)))
+ bool Reported = false;
+ Dst->Writer.mergeRecordsFromWriter(std::move(Src->Writer), [&](Error E) {
+ if (Reported) {
+ consumeError(std::move(E));
+ return;
+ }
+ Reported = true;
Dst->Err = std::move(E);
+ });
}
static void mergeInstrProfile(const WeightedFileVector &Inputs,
OpenPOWER on IntegriCloud