[lld] 6e5ed35 - [lld-macho] Fix category merging category map non-determinism (#91159)
via llvm-commits
llvm-commits at lists.llvm.org
Mon May 6 16:54:45 PDT 2024
Author: alx32
Date: 2024-05-06T16:54:41-07:00
New Revision: 6e5ed351be68017e46120b8ad1aa89d75b0ca204
URL: https://github.com/llvm/llvm-project/commit/6e5ed351be68017e46120b8ad1aa89d75b0ca204
DIFF: https://github.com/llvm/llvm-project/commit/6e5ed351be68017e46120b8ad1aa89d75b0ca204.diff
LOG: [lld-macho] Fix category merging category map non-determinism (#91159)
Currently in `ObjcCategoryMerger::doMerge` and
`generateCatListForNonErasedCategories` we use maps of pointers which
leads to non-determinism. Switch instead to using `MapVector` which
preserves determinism.
Added:
Modified:
lld/MachO/ObjC.cpp
Removed:
################################################################################
diff --git a/lld/MachO/ObjC.cpp b/lld/MachO/ObjC.cpp
index f7d7e3a7ad70dc..15b89a808b05ee 100644
--- a/lld/MachO/ObjC.cpp
+++ b/lld/MachO/ObjC.cpp
@@ -437,7 +437,7 @@ class ObjcCategoryMerger {
void eraseMergedCategories();
void generateCatListForNonErasedCategories(
- std::map<ConcatInputSection *, std::set<uint64_t>>
+ MapVector<ConcatInputSection *, std::set<uint64_t>>
catListToErasedOffsets);
void collectSectionWriteInfoFromIsec(const InputSection *isec,
InfoWriteSection &catWriteInfo);
@@ -491,7 +491,7 @@ class ObjcCategoryMerger {
InfoCategoryWriter infoCategoryWriter;
std::vector<ConcatInputSection *> &allInputSections;
// Map of base class Symbol to list of InfoInputCategory's for it
- DenseMap<const Symbol *, std::vector<InfoInputCategory>> categoryMap;
+ MapVector<const Symbol *, std::vector<InfoInputCategory>> categoryMap;
// Set for tracking InputSection erased via eraseISec
DenseSet<InputSection *> erasedIsecs;
@@ -1104,7 +1104,7 @@ void ObjcCategoryMerger::collectAndValidateCategoriesData() {
// (not erased). For these not erased categories, we generate new __objc_catlist
// entries since the parent __objc_catlist entry will be erased
void ObjcCategoryMerger::generateCatListForNonErasedCategories(
- const std::map<ConcatInputSection *, std::set<uint64_t>>
+ const MapVector<ConcatInputSection *, std::set<uint64_t>>
catListToErasedOffsets) {
// Go through all offsets of all __objc_catlist's that we process and if there
@@ -1171,7 +1171,7 @@ void ObjcCategoryMerger::eraseISec(ConcatInputSection *isec) {
// them.
void ObjcCategoryMerger::eraseMergedCategories() {
// Map of InputSection to a set of offsets of the categories that were merged
- std::map<ConcatInputSection *, std::set<uint64_t>> catListToErasedOffsets;
+ MapVector<ConcatInputSection *, std::set<uint64_t>> catListToErasedOffsets;
for (auto &mapEntry : categoryMap) {
for (InfoInputCategory &catInfo : mapEntry.second) {
More information about the llvm-commits
mailing list