aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/LTO/LTO.cpp
diff options
context:
space:
mode:
authorMingming Liu <mingmingl@google.com>2024-05-18 19:39:57 -0700
committerGitHub <noreply@github.com>2024-05-18 19:39:57 -0700
commitd34be649af1aa849c21a5a0570617c3a89d5f0b8 (patch)
tree7965a47de94ad0e838f2e3ab4b7183b943dfc9f6 /llvm/lib/LTO/LTO.cpp
parent597ac471cc7da97ccf957362a7e9f7a52d6910ee (diff)
downloadllvm-d34be649af1aa849c21a5a0570617c3a89d5f0b8.zip
llvm-d34be649af1aa849c21a5a0570617c3a89d5f0b8.tar.gz
llvm-d34be649af1aa849c21a5a0570617c3a89d5f0b8.tar.bz2
[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.
Diffstat (limited to 'llvm/lib/LTO/LTO.cpp')
-rw-r--r--llvm/lib/LTO/LTO.cpp8
1 files changed, 7 insertions, 1 deletions
diff --git a/llvm/lib/LTO/LTO.cpp b/llvm/lib/LTO/LTO.cpp
index 21cad1d..5c603ac 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.