[PATCH] D23599: [ThinLTO] Add caching to the new LTO API
Teresa Johnson via llvm-commits
llvm-commits at lists.llvm.org
Tue Aug 23 13:20:42 PDT 2016
tejohnson accepted this revision.
tejohnson added a comment.
This revision is now accepted and ready to land.
This now works with the support I added to gold-plugin (will commit as a follow-on) with the following change. This is required because append() will cause EntryPath to be CacheDirectoryPath+"/" and the test later in the destructor will not think they are equal.
diff --git a/lib/LTO/Caching.cpp b/lib/LTO/Caching.cpp
index 11e9fd6..9bba3ab 100644
- a/lib/LTO/Caching.cpp
+++ b/lib/LTO/Caching.cpp
@@ -93,10 +93,12 @@ std::unique_ptr<raw_pwrite_stream> CacheObjectOutput::getStream() {
bool CacheObjectOutput::tryLoadFromCache(StringRef Key) {
assert(!CacheDirectoryPath.empty() &&
"CacheObjectOutput was initialized without a cache path");
- sys::path::append(EntryPath, CacheDirectoryPath, Key);
- if (Key.empty())
- // Client didn't compute a valid key. EntryPath has been set to
+ if (Key.empty()) {
+ // Client didn't compute a valid key. Set EntryPath to
// CacheDirectoryPath.
+ EntryPath = CacheDirectoryPath;
return false;
+ }
+ sys::path::append(EntryPath, CacheDirectoryPath, Key);
return sys::fs::exists(EntryPath);
}
================
Comment at: lib/LTO/LTOBackend.cpp:248
@@ +247,3 @@
+ };
+ codegen(C, TM.get(), AddOutputWrapper, 0, *M);
+ } else {
----------------
Consider refactoring this so the above block from the AddOutput call through the codegen call are in a helper passed a ThreadId, then it can be called here and in splitCodeGen.
https://reviews.llvm.org/D23599
More information about the llvm-commits
mailing list