llvm.org GIT mirror llvm / 0ff70a6
[llvm-profdata] Fix a dangling reference to an error string git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@318502 91177308-0d34-0410-b5e6-96231b3b80d8 Vedant Kumar 1 year, 9 months ago
6 changed file(s) with 43 addition(s) and 3 deletion(s). Raw diff Collapse all Expand all
0 # Test multithreaded error reporting.
1
2 RUN: not llvm-profdata merge -j 4 -o %t.profdata \
3 RUN: %S/Inputs/counter-mismatch-1.proftext \
4 RUN: %S/Inputs/counter-mismatch-2.proftext \
5 RUN: %S/Inputs/counter-mismatch-3.proftext \
6 RUN: %S/Inputs/counter-mismatch-4.proftext \
7 RUN: 2>&1 | FileCheck %s
8
9 CHECK: Function basic block count change detected (counter mismatch)
3636
3737 enum ProfileFormat { PF_None = 0, PF_Text, PF_Binary, PF_GCC };
3838
39 static void exitWithError(const Twine &Message, StringRef Whence = "",
40 StringRef Hint = "") {
39 static void exitWithError(Twine Message, std::string Whence = "",
40 std::string Hint = "") {
4141 errs() << "error: ";
4242 if (!Whence.empty())
4343 errs() << Whence << ": ";
118118 std::mutex Lock;
119119 InstrProfWriter Writer;
120120 Error Err;
121 StringRef ErrWhence;
121 std::string ErrWhence;
122122 std::mutex &ErrLock;
123123 SmallSet &WriterErrorCodes;
124124
136136 if (WC->Err)
137137 return;
138138
139 // Copy the filename, because llvm::ThreadPool copied the input "const
140 // WeightedFile &" by value, making a reference to the filename within it
141 // invalid outside of this packaged task.
139142 WC->ErrWhence = Input.Filename;
140143
141144 auto ReaderOrErr = InstrProfReader::create(Input.Filename);
179182
180183 /// Merge the \p Src writer context into \p Dst.
181184 static void mergeWriterContexts(WriterContext *Dst, WriterContext *Src) {
185 // If we've already seen a hard error, continuing with the merge would
186 // clobber it.
187 if (Dst->Err || Src->Err)
188 return;
189
182190 bool Reported = false;
183191 Dst->Writer.mergeRecordsFromWriter(std::move(Src->Writer), [&](Error E) {
184192 if (Reported) {