[llvm] d34be64 - [ThinLTO]Sort imported GUIDs before cache key update (#92622)
via llvm-commits
llvm-commits at lists.llvm.org
Sat May 18 19:40:01 PDT 2024
Author: Mingming Liu
Date: 2024-05-18T19:39:57-07:00
New Revision: d34be649af1aa849c21a5a0570617c3a89d5f0b8
URL: https://github.com/llvm/llvm-project/commit/d34be649af1aa849c21a5a0570617c3a89d5f0b8
DIFF: https://github.com/llvm/llvm-project/commit/d34be649af1aa849c21a5a0570617c3a89d5f0b8.diff
LOG: [ThinLTO]Sort imported GUIDs before cache key update (#92622)
Add 'sort' here since it's helpful when container type
changes (for example, https://github.com/llvm/llvm-project/pull/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.
Added:
Modified:
llvm/lib/LTO/LTO.cpp
Removed:
################################################################################
diff --git a/llvm/lib/LTO/LTO.cpp b/llvm/lib/LTO/LTO.cpp
index 21cad1de0ced5..5c603ac6ab472 100644
--- a/llvm/lib/LTO/LTO.cpp
+++ b/llvm/lib/LTO/LTO.cpp
@@ -199,13 +199,19 @@ void llvm::computeLTOCacheKey(
[](const ImportModule &Lhs, const ImportModule &Rhs) -> bool {
return Lhs.getHash() < Rhs.getHash();
});
+ std::vector<uint64_t> ImportedGUIDs;
for (const ImportModule &Entry : ImportModulesVector) {
auto ModHash = Entry.getHash();
Hasher.update(ArrayRef<uint8_t>((uint8_t *)&ModHash[0], sizeof(ModHash)));
AddUint64(Entry.getFunctions().size());
+
+ ImportedGUIDs.clear();
for (auto &Fn : Entry.getFunctions())
- AddUint64(Fn);
+ ImportedGUIDs.push_back(Fn);
+ llvm::sort(ImportedGUIDs);
+ for (auto &GUID : ImportedGUIDs)
+ AddUint64(GUID);
}
// Include the hash for the resolved ODR.
More information about the llvm-commits
mailing list