Skip to content

Commit d34be64

Browse files
[ThinLTO]Sort imported GUIDs before cache key update (#92622)
Add 'sort' here since it's helpful when container type changes (for example, #88024 wants to change container type from `unordered_set` to `DenseMap) @MaskRay points out `std::` doesn't randomize the iteration order of `unordered_{set,map}`, and the iteration order for single build is deterministic.
1 parent 597ac47 commit d34be64

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

llvm/lib/LTO/LTO.cpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -199,13 +199,19 @@ void llvm::computeLTOCacheKey(
199199
[](const ImportModule &Lhs, const ImportModule &Rhs) -> bool {
200200
return Lhs.getHash() < Rhs.getHash();
201201
});
202+
std::vector<uint64_t> ImportedGUIDs;
202203
for (const ImportModule &Entry : ImportModulesVector) {
203204
auto ModHash = Entry.getHash();
204205
Hasher.update(ArrayRef<uint8_t>((uint8_t *)&ModHash[0], sizeof(ModHash)));
205206

206207
AddUint64(Entry.getFunctions().size());
208+
209+
ImportedGUIDs.clear();
207210
for (auto &Fn : Entry.getFunctions())
208-
AddUint64(Fn);
211+
ImportedGUIDs.push_back(Fn);
212+
llvm::sort(ImportedGUIDs);
213+
for (auto &GUID : ImportedGUIDs)
214+
AddUint64(GUID);
209215
}
210216

211217
// Include the hash for the resolved ODR.

0 commit comments

Comments
 (0)