[llvm] [DTLTO] [Clang] Initial DTLTO cache implementation (PR #156433)
via llvm-commits
llvm-commits at lists.llvm.org
Tue Sep 2 02:37:56 PDT 2025
github-actions[bot] wrote:
<!--LLVM CODE FORMAT COMMENT: {clang-format}-->
:warning: C/C++ code formatter, clang-format found issues in your code. :warning:
<details>
<summary>
You can test this locally with the following command:
</summary>
``````````bash
git-clang-format --diff origin/main HEAD --extensions cpp,h -- llvm/include/llvm/LTO/Config.h llvm/lib/LTO/LTO.cpp
``````````
:warning:
The reproduction instructions above might return results for more than one PR
in a stack if you are using a stacked PR workflow. You can limit the results by
changing `origin/main` to the base branch/commit you want to compare against.
:warning:
</details>
<details>
<summary>
View the diff from clang-format here.
</summary>
``````````diff
diff --git a/llvm/lib/LTO/LTO.cpp b/llvm/lib/LTO/LTO.cpp
index 4ae51d2f4..9fcdb1142 100644
--- a/llvm/lib/LTO/LTO.cpp
+++ b/llvm/lib/LTO/LTO.cpp
@@ -2290,7 +2290,6 @@ public:
RemoteCompilerArgs(RemoteCompilerArgs), SaveTemps(SaveTemps),
Cache(std::move(CacheFn)) {}
-
virtual void setup(unsigned ThinLTONumTasks, unsigned ThinLTOTaskOffset,
llvm::Triple Triple) override {
UID = itostr(sys::Process::getProcessId());
@@ -2537,7 +2536,8 @@ public:
std::string ErrMsg;
if (sys::ExecuteAndWait(Args[0], Args,
/*Env=*/std::nullopt, /*Redirects=*/{},
- /*SecondsToWait=*/0, /*MemoryLimit=*/0, &ErrMsg)) {
+ /*SecondsToWait=*/0, /*MemoryLimit=*/0,
+ &ErrMsg)) {
return make_error<StringError>(
BCError + "distributor execution failed" +
(!ErrMsg.empty() ? ": " + ErrMsg + Twine(".") : Twine(".")),
@@ -2560,31 +2560,30 @@ public:
Job.NativeObjectPath + ": " + EC.message(),
inconvertibleErrorCode());
- MemoryBufferRef ObjFileMbRef = ObjFileMbOrErr->get()->getMemBufferRef();
- if (Cache.isValid() && Job.CacheAddStream) {
- // Obtain a file stream for a storing a cache entry.
- auto CachedFileStreamOrErr =
- Job.CacheAddStream(Job.Task, Job.ModuleID);
- if (!CachedFileStreamOrErr)
- return joinErrors(
- CachedFileStreamOrErr.takeError(),
- createStringError(inconvertibleErrorCode(),
- "Cannot get a cache file stream: %s",
- Job.NativeObjectPath.data()));
- // Store a file buffer into the cache stream.
- auto &CacheStream = *(CachedFileStreamOrErr->get());
- *(CacheStream.OS) << ObjFileMbRef.getBuffer();
- if (Error Err = CacheStream.commit())
- return Err;
- } else {
- auto StreamOrErr = AddStream(Job.Task, Job.ModuleID);
- if (Error Err = StreamOrErr.takeError())
- report_fatal_error(std::move(Err));
- auto &Stream = *StreamOrErr->get();
- *Stream.OS << ObjFileMbRef.getBuffer();
- if (Error Err = Stream.commit())
- report_fatal_error(std::move(Err));
- }
+ MemoryBufferRef ObjFileMbRef = ObjFileMbOrErr->get()->getMemBufferRef();
+ if (Cache.isValid() && Job.CacheAddStream) {
+ // Obtain a file stream for a storing a cache entry.
+ auto CachedFileStreamOrErr = Job.CacheAddStream(Job.Task, Job.ModuleID);
+ if (!CachedFileStreamOrErr)
+ return joinErrors(
+ CachedFileStreamOrErr.takeError(),
+ createStringError(inconvertibleErrorCode(),
+ "Cannot get a cache file stream: %s",
+ Job.NativeObjectPath.data()));
+ // Store a file buffer into the cache stream.
+ auto &CacheStream = *(CachedFileStreamOrErr->get());
+ *(CacheStream.OS) << ObjFileMbRef.getBuffer();
+ if (Error Err = CacheStream.commit())
+ return Err;
+ } else {
+ auto StreamOrErr = AddStream(Job.Task, Job.ModuleID);
+ if (Error Err = StreamOrErr.takeError())
+ report_fatal_error(std::move(Err));
+ auto &Stream = *StreamOrErr->get();
+ *Stream.OS << ObjFileMbRef.getBuffer();
+ if (Error Err = Stream.commit())
+ report_fatal_error(std::move(Err));
+ }
}
return Error::success();
}
@@ -2603,9 +2602,9 @@ ThinBackend lto::createOutOfProcessThinBackend(
AddStreamFn AddStream, FileCache Cache) {
return std::make_unique<OutOfProcessThinBackend>(
Conf, CombinedIndex, Parallelism, ModuleToDefinedGVSummaries,
- AddStream, Cache, OnWrite, ShouldEmitIndexFiles, ShouldEmitImportsFiles,
- LinkerOutputFile, Distributor, DistributorArgs, RemoteCompiler,
- RemoteCompilerArgs, SaveTemps);
+ AddStream, Cache, OnWrite, ShouldEmitIndexFiles,
+ ShouldEmitImportsFiles, LinkerOutputFile, Distributor,
+ DistributorArgs, RemoteCompiler, RemoteCompilerArgs, SaveTemps);
};
return ThinBackend(Func, Parallelism);
}
``````````
</details>
https://github.com/llvm/llvm-project/pull/156433
More information about the llvm-commits
mailing list