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