[PATCH] D121458: [lld-macho] Don't allocate memory in parallelForEach
Jez Ng via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Mar 11 10:32:38 PST 2022
This revision was automatically updated to reflect the committed changes.
Closed by commit rG9b7b21d2f7cf: [lld-macho] Don't allocate memory in parallelForEach (authored by int3).
Changed prior to commit:
https://reviews.llvm.org/D121458?vs=414641&id=414696#toc
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D121458/new/
https://reviews.llvm.org/D121458
Files:
lld/MachO/ICF.cpp
Index: lld/MachO/ICF.cpp
===================================================================
--- lld/MachO/ICF.cpp
+++ lld/MachO/ICF.cpp
@@ -383,22 +383,26 @@
for (Defined *d : isec->symbols)
if (d->unwindEntry)
hashable.push_back(d->unwindEntry);
+
+ // __cfstring has embedded addends that foil ICF's hashing / equality
+ // checks. (We can ignore embedded addends when doing ICF because the same
+ // information gets recorded in our Reloc structs.) We therefore create a
+ // mutable copy of the CFString and zero out the embedded addends before
+ // performing any hashing / equality checks.
+ if (isCfStringSection(isec) || isClassRefsSection(isec)) {
+ // We have to do this copying serially as the BumpPtrAllocator is not
+ // thread-safe. FIXME: Make a thread-safe allocator.
+ MutableArrayRef<uint8_t> copy = isec->data.copy(bAlloc());
+ for (const Reloc &r : isec->relocs)
+ target->relocateOne(copy.data() + r.offset, r, /*va=*/0,
+ /*relocVA=*/0);
+ isec->data = copy;
+ }
} else {
isec->icfEqClass[0] = ++icfUniqueID;
}
}
parallelForEach(hashable, [](ConcatInputSection *isec) {
- // __cfstring has embedded addends that foil ICF's hashing / equality
- // checks. (We can ignore embedded addends when doing ICF because the same
- // information gets recorded in our Reloc structs.) We therefore create a
- // mutable copy of the CFString and zero out the embedded addends before
- // performing any hashing / equality checks.
- if (isCfStringSection(isec) || isClassRefsSection(isec)) {
- MutableArrayRef<uint8_t> copy = isec->data.copy(bAlloc());
- for (const Reloc &r : isec->relocs)
- target->relocateOne(copy.data() + r.offset, r, /*va=*/0, /*relocVA=*/0);
- isec->data = copy;
- }
assert(isec->icfEqClass[0] == 0); // don't overwrite a unique ID!
// Turn-on the top bit to guarantee that valid hashes have no collisions
// with the small-integer unique IDs for ICF-ineligible sections
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D121458.414696.patch
Type: text/x-patch
Size: 2120 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220311/dd1e5628/attachment.bin>
More information about the llvm-commits
mailing list