Skip to content

Commit 94447cf

Browse files
authored
Merge pull request #8614 from apple/jan_svoboda/async-thinlto-release
2 parents ef51a35 + e5a688c commit 94447cf

File tree

6 files changed

+817
-266
lines changed

6 files changed

+817
-266
lines changed

llvm/include/llvm/CAS/ObjectStore.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -257,6 +257,10 @@ class ObjectStore {
257257
/// Asynchronous version of \c getProxyIfExists.
258258
std::future<AsyncProxyValue> getProxyFuture(ObjectRef Ref);
259259

260+
/// Asynchronous version of \c getProxyIfExists using a callback.
261+
void getProxyAsync(
262+
const CASID &ID,
263+
unique_function<void(Expected<std::optional<ObjectProxy>>)> Callback);
260264
/// Asynchronous version of \c getProxyIfExists using a callback.
261265
void getProxyAsync(
262266
ObjectRef Ref,

llvm/include/llvm/LTO/legacy/ThinLTOCodeGenerator.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,8 @@ class ModuleCacheEntry {
6262
}
6363

6464
virtual ~ModuleCacheEntry() {}
65-
protected:
66-
std::optional<std::string> computeCacheKey(
65+
66+
static std::optional<std::string> computeCacheKey(
6767
const ModuleSummaryIndex &Index, StringRef ModuleID,
6868
const FunctionImporter::ImportMapTy &ImportList,
6969
const FunctionImporter::ExportSetTy &ExportList,

llvm/include/llvm/RemoteCachingService/Client.h

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,17 +68,37 @@ class KeyValueDBClient {
6868
Expected<std::optional<ValueTy>> getValueSync(ArrayRef<uint8_t> Key) {
6969
return getValueSync(toStringRef(Key).str());
7070
}
71+
72+
using GetValueCb = std::function<void(Expected<std::optional<ValueTy>>)>;
73+
void getValueAsync(std::string Key, GetValueCb Callback) {
74+
return getValueAsyncImpl(std::move(Key), std::move(Callback));
75+
}
76+
void getValueAsync(ArrayRef<uint8_t> Key, GetValueCb Callback) {
77+
return getValueAsync(toStringRef(Key).str(), std::move(Callback));
78+
}
79+
7180
Error putValueSync(std::string Key, const ValueTy &Value) {
7281
return putValueSyncImpl(std::move(Key), Value);
7382
}
7483
Error putValueSync(ArrayRef<uint8_t> Key, const ValueTy &Value) {
7584
return putValueSync(toStringRef(Key).str(), Value);
7685
}
86+
void putValueAsync(std::string Key, const ValueTy &Value,
87+
std::function<void(Error)> Callback) {
88+
return putValueAsyncImpl(std::move(Key), Value, std::move(Callback));
89+
}
90+
void putValueAsync(ArrayRef<uint8_t> Key, const ValueTy &Value,
91+
std::function<void(Error)> Callback) {
92+
return putValueAsync(toStringRef(Key).str(), Value, std::move(Callback));
93+
}
7794

7895
protected:
7996
virtual Expected<std::optional<ValueTy>>
8097
getValueSyncImpl(std::string Key) = 0;
98+
virtual void getValueAsyncImpl(std::string Key, GetValueCb Callback) = 0;
8199
virtual Error putValueSyncImpl(std::string Key, const ValueTy &Value) = 0;
100+
virtual void putValueAsyncImpl(std::string Key, const ValueTy &Value,
101+
std::function<void(Error)> Callback) = 0;
82102

83103
public:
84104
class GetValueAsyncQueue : public AsyncQueueBase {
@@ -184,17 +204,32 @@ class CASDBClient {
184204
std::optional<std::string> BlobData;
185205
std::vector<std::string> Refs;
186206
};
207+
187208
Expected<LoadResponse>
188209
loadSync(std::string CASID,
189210
std::optional<std::string> OutFilePath = std::nullopt) {
190211
return loadSyncImpl(std::move(CASID), std::move(OutFilePath));
191212
}
213+
214+
using LoadCb = std::function<void(Expected<LoadResponse>)>;
215+
void loadAsync(std::string CASID, std::optional<std::string> OutFilePath,
216+
LoadCb Callback) {
217+
return loadAsyncImpl(std::move(CASID), std::move(OutFilePath),
218+
std::move(Callback));
219+
}
220+
192221
Expected<std::string> saveDataSync(std::string BlobData) {
193222
return saveDataSyncImpl(std::move(BlobData));
194223
}
195224
Expected<std::string> saveFileSync(std::string FilePath) {
196225
return saveFileSyncImpl(std::move(FilePath));
197226
}
227+
228+
using SaveFileCb = std::function<void(Expected<std::string>)>;
229+
void saveFileAsync(std::string FilePath, SaveFileCb Callback) {
230+
return saveFileAsyncImpl(std::move(FilePath), std::move(Callback));
231+
}
232+
198233
Expected<GetResponse>
199234
getSync(std::string CASID,
200235
std::optional<std::string> OutFilePath = std::nullopt) {
@@ -212,8 +247,14 @@ class CASDBClient {
212247
protected:
213248
virtual Expected<LoadResponse>
214249
loadSyncImpl(std::string CASID, std::optional<std::string> OutFilePath) = 0;
250+
virtual void loadAsyncImpl(std::string CASID,
251+
std::optional<std::string> OutFilePath,
252+
LoadCb Callback) = 0;
253+
215254
virtual Expected<std::string> saveDataSyncImpl(std::string BlobData) = 0;
216255
virtual Expected<std::string> saveFileSyncImpl(std::string FilePath) = 0;
256+
virtual void saveFileAsyncImpl(std::string FilePath, SaveFileCb Callback) = 0;
257+
217258
virtual Expected<GetResponse>
218259
getSyncImpl(std::string CASID, std::optional<std::string> OutFilePath) = 0;
219260
virtual Expected<std::string> putDataSyncImpl(std::string BlobData,

llvm/lib/CAS/ObjectStore.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,15 @@ std::future<AsyncProxyValue> ObjectStore::getProxyFuture(ObjectRef Ref) {
127127
return Future;
128128
}
129129

130+
void ObjectStore::getProxyAsync(
131+
const CASID &ID,
132+
unique_function<void(Expected<std::optional<ObjectProxy>>)> Callback) {
133+
std::optional<ObjectRef> Ref = getReference(ID);
134+
if (!Ref)
135+
return Callback(createUnknownObjectError(ID));
136+
return getProxyAsync(*Ref, std::move(Callback));
137+
}
138+
130139
void ObjectStore::getProxyAsync(
131140
ObjectRef Ref,
132141
unique_function<void(Expected<std::optional<ObjectProxy>>)> Callback) {

0 commit comments

Comments
 (0)