@@ -123,6 +123,9 @@ void llvm::computeLTOCacheKey(
123
123
support::endian::write64le (Data, I);
124
124
Hasher.update (Data);
125
125
};
126
+ auto AddUint8 = [&](const uint8_t I) {
127
+ Hasher.update (ArrayRef<uint8_t >((const uint8_t *)&I, 1 ));
128
+ };
126
129
AddString (Conf.CPU );
127
130
// FIXME: Hash more of Options. For now all clients initialize Options from
128
131
// command-line flags (which is unsupported in production), but may set
@@ -158,18 +161,18 @@ void llvm::computeLTOCacheKey(
158
161
auto ModHash = Index.getModuleHash (ModuleID);
159
162
Hasher.update (ArrayRef<uint8_t >((uint8_t *)&ModHash[0 ], sizeof (ModHash)));
160
163
161
- std::vector<uint64_t > ExportsGUID;
164
+ std::vector<std::pair< uint64_t , uint8_t > > ExportsGUID;
162
165
ExportsGUID.reserve (ExportList.size ());
163
- for (const auto &VI : ExportList) {
164
- auto GUID = VI.getGUID ();
165
- ExportsGUID.push_back (GUID);
166
- }
166
+ for (const auto &[VI, ExportType] : ExportList)
167
+ ExportsGUID.push_back (
168
+ std::make_pair (VI.getGUID (), static_cast <uint8_t >(ExportType)));
167
169
168
170
// Sort the export list elements GUIDs.
169
171
llvm::sort (ExportsGUID);
170
- for (uint64_t GUID : ExportsGUID) {
172
+ for (auto [ GUID, ExportType] : ExportsGUID) {
171
173
// The export list can impact the internalization, be conservative here
172
174
Hasher.update (ArrayRef<uint8_t >((uint8_t *)&GUID, sizeof (GUID)));
175
+ AddUint8 (ExportType);
173
176
}
174
177
175
178
// Include the hash for every module we import functions from. The set of
@@ -201,19 +204,21 @@ void llvm::computeLTOCacheKey(
201
204
[](const ImportModule &Lhs, const ImportModule &Rhs) -> bool {
202
205
return Lhs.getHash () < Rhs.getHash ();
203
206
});
204
- std::vector<uint64_t > ImportedGUIDs;
207
+ std::vector<std::pair< uint64_t , uint8_t > > ImportedGUIDs;
205
208
for (const ImportModule &Entry : ImportModulesVector) {
206
209
auto ModHash = Entry.getHash ();
207
210
Hasher.update (ArrayRef<uint8_t >((uint8_t *)&ModHash[0 ], sizeof (ModHash)));
208
211
209
212
AddUint64 (Entry.getFunctions ().size ());
210
213
211
214
ImportedGUIDs.clear ();
212
- for (auto &Fn : Entry.getFunctions ())
213
- ImportedGUIDs.push_back (Fn );
215
+ for (auto &[Fn, ImportType] : Entry.getFunctions ())
216
+ ImportedGUIDs.push_back (std::make_pair (Fn, ImportType) );
214
217
llvm::sort (ImportedGUIDs);
215
- for (auto &GUID : ImportedGUIDs)
218
+ for (auto &[ GUID, Type] : ImportedGUIDs) {
216
219
AddUint64 (GUID);
220
+ AddUint8 (Type);
221
+ }
217
222
}
218
223
219
224
// Include the hash for the resolved ODR.
@@ -283,9 +288,9 @@ void llvm::computeLTOCacheKey(
283
288
// Imported functions may introduce new uses of type identifier resolutions,
284
289
// so we need to collect their used resolutions as well.
285
290
for (const ImportModule &ImpM : ImportModulesVector)
286
- for (auto &ImpF : ImpM.getFunctions ()) {
291
+ for (auto &[GUID, UnusedImportType] : ImpM.getFunctions ()) {
287
292
GlobalValueSummary *S =
288
- Index.findSummaryInModule (ImpF , ImpM.getIdentifier ());
293
+ Index.findSummaryInModule (GUID , ImpM.getIdentifier ());
289
294
AddUsedThings (S);
290
295
// If this is an alias, we also care about any types/etc. that the aliasee
291
296
// may reference.
@@ -1397,6 +1402,7 @@ class lto::ThinBackendProc {
1397
1402
llvm::StringRef ModulePath,
1398
1403
const std::string &NewModulePath) {
1399
1404
std::map<std::string, GVSummaryMapTy> ModuleToSummariesForIndex;
1405
+
1400
1406
std::error_code EC;
1401
1407
gatherImportedSummariesForModule (ModulePath, ModuleToDefinedGVSummaries,
1402
1408
ImportList, ModuleToSummariesForIndex);
@@ -1405,6 +1411,8 @@ class lto::ThinBackendProc {
1405
1411
sys::fs::OpenFlags::OF_None);
1406
1412
if (EC)
1407
1413
return errorCodeToError (EC);
1414
+
1415
+ // TODO: Serialize declaration bits to bitcode.
1408
1416
writeIndexToFile (CombinedIndex, OS, &ModuleToSummariesForIndex);
1409
1417
1410
1418
if (ShouldEmitImportsFiles) {
0 commit comments