1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-11-26 04:32:44 +01:00

[llvm-profdata] Fix a dangling reference to an error string

llvm-svn: 318502
This commit is contained in:
Vedant Kumar 2017-11-17 02:58:23 +00:00
parent 20bb22fbf9
commit 96e5de6b03
6 changed files with 43 additions and 3 deletions

View File

@ -0,0 +1,4 @@
foo
1024
1
0

View File

@ -0,0 +1,5 @@
foo
1024
2
0
0

View File

@ -0,0 +1,6 @@
foo
1024
3
0
0
0

View File

@ -0,0 +1,7 @@
foo
1024
4
0
0
0
0

View File

@ -0,0 +1,10 @@
# Test multithreaded error reporting.
RUN: not llvm-profdata merge -j 4 -o %t.profdata \
RUN: %S/Inputs/counter-mismatch-1.proftext \
RUN: %S/Inputs/counter-mismatch-2.proftext \
RUN: %S/Inputs/counter-mismatch-3.proftext \
RUN: %S/Inputs/counter-mismatch-4.proftext \
RUN: 2>&1 | FileCheck %s
CHECK: Function basic block count change detected (counter mismatch)

View File

@ -37,8 +37,8 @@ using namespace llvm;
enum ProfileFormat { PF_None = 0, PF_Text, PF_Binary, PF_GCC };
static void exitWithError(const Twine &Message, StringRef Whence = "",
StringRef Hint = "") {
static void exitWithError(Twine Message, std::string Whence = "",
std::string Hint = "") {
errs() << "error: ";
if (!Whence.empty())
errs() << Whence << ": ";
@ -119,7 +119,7 @@ struct WriterContext {
std::mutex Lock;
InstrProfWriter Writer;
Error Err;
StringRef ErrWhence;
std::string ErrWhence;
std::mutex &ErrLock;
SmallSet<instrprof_error, 4> &WriterErrorCodes;
@ -137,6 +137,9 @@ static void loadInput(const WeightedFile &Input, WriterContext *WC) {
if (WC->Err)
return;
// Copy the filename, because llvm::ThreadPool copied the input "const
// WeightedFile &" by value, making a reference to the filename within it
// invalid outside of this packaged task.
WC->ErrWhence = Input.Filename;
auto ReaderOrErr = InstrProfReader::create(Input.Filename);
@ -180,6 +183,11 @@ 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 we've already seen a hard error, continuing with the merge would
// clobber it.
if (Dst->Err || Src->Err)
return;
bool Reported = false;
Dst->Writer.mergeRecordsFromWriter(std::move(Src->Writer), [&](Error E) {
if (Reported) {