[llvm] Make WriteIndexesThinBackend multi threaded (PR #109847)
Nuri Amari via llvm-commits
llvm-commits at lists.llvm.org
Wed Sep 25 11:26:26 PDT 2024
================
@@ -1645,19 +1648,48 @@ class WriteIndexesThinBackend : public ThinBackendProc {
*LinkedObjectsFile << LinkedObjectsFilePath << '\n';
}
- if (auto E = emitFiles(ImportList, ModulePath, NewModulePath))
- return E;
+ BackendThreadPool.async(
+ [this](const StringRef ModulePath,
+ const FunctionImporter::ImportMapTy &ImportList,
+ const std::string &OldPrefix, const std::string &NewPrefix) {
+ std::string NewModulePath =
+ getThinLTOOutputFile(ModulePath, OldPrefix, NewPrefix);
+ auto E = emitFiles(ImportList, ModulePath, NewModulePath);
+ if (E) {
+ std::unique_lock<std::mutex> L(ErrMu);
+ if (Err)
+ Err = joinErrors(std::move(*Err), std::move(E));
+ else
+ Err = std::move(E);
+ return;
+ }
+ if (OnWrite) {
----------------
NuriAmari wrote:
I tried that at first, but that would be a change in behavior and causes this test to fail here: https://github.com/llvm/llvm-project/blob/main/lld/test/ELF/lto/thinlto-emit-imports.ll#L12-L13
We should only call `OnWrite` if `emitFiles` succeeded, returning early if not.
https://github.com/llvm/llvm-project/pull/109847
More information about the llvm-commits
mailing list