[llvm] Gsymutil aggregation similar to DwarfDump --verify (PR #81154)
Greg Clayton via llvm-commits
llvm-commits at lists.llvm.org
Fri Feb 9 11:45:03 PST 2024
================
@@ -596,29 +612,26 @@ Error DwarfTransformer::convert(uint32_t NumThreads, raw_ostream *OS) {
DWARFDie Die = getDie(*CU);
if (Die) {
CUInfo CUI(DICtx, dyn_cast<DWARFCompileUnit>(CU.get()));
- pool.async([this, CUI, &LogMutex, OS, Die]() mutable {
- std::string ThreadLogStorage;
- raw_string_ostream ThreadOS(ThreadLogStorage);
- handleDie(OS ? &ThreadOS: nullptr, CUI, Die);
- ThreadOS.flush();
- if (OS && !ThreadLogStorage.empty()) {
- // Print ThreadLogStorage lines into an actual stream under a lock
- std::lock_guard<std::mutex> guard(LogMutex);
- *OS << ThreadLogStorage;
- }
+ pool.async([this, CUI, &LogMutex, Out, Die]() mutable {
+ StringAggregator ThreadOut(Out.IsShowingDetail());
+ handleDie(ThreadOut, CUI, Die);
+ // Print ThreadLogStorage lines into an actual stream under a lock
+ std::lock_guard<std::mutex> guard(LogMutex);
+ Out.Merge(ThreadOut);
});
}
}
pool.wait();
}
size_t FunctionsAddedCount = Gsym.getNumFunctionInfos() - NumBefore;
- if (OS)
- *OS << "Loaded " << FunctionsAddedCount << " functions from DWARF.\n";
+ if (Out.IsShowingDetail())
----------------
clayborg wrote:
```
if (Out.GetOS())
```
or we can rely on the fact that the `Out` object will not foward the info if there is no stream by just writing:
```
Out << "Loaded " << FunctionsAddedCount << " functions from DWARF.\n";
```
(no need to check if there is a stream because `template <typename T> OutputAggregator &operator<<(T &&value)` checks the stream and we aren't putting anything too expensive into the stream
https://github.com/llvm/llvm-project/pull/81154
More information about the llvm-commits
mailing list