[lld] b07292f - [ELF] Serialize deleteFallThruJmpInsn to fix concurrency issue
Fangrui Song via llvm-commits
llvm-commits at lists.llvm.org
Sun Dec 26 23:26:26 PST 2021
Author: Fangrui Song
Date: 2021-12-26T23:26:13-08:00
New Revision: b07292f77a1e82c27fd98105d69f351ef41ac29f
URL: https://github.com/llvm/llvm-project/commit/b07292f77a1e82c27fd98105d69f351ef41ac29f
DIFF: https://github.com/llvm/llvm-project/commit/b07292f77a1e82c27fd98105d69f351ef41ac29f.diff
LOG: [ELF] Serialize deleteFallThruJmpInsn to fix concurrency issue
New deleteFallThruJmpInsn calls `make<JumpInstrMod>` which cannot be called
concurrently. Losing parallelism is unfortunate but we can think of a better
approach if parallelism here justifies itself.
Added:
Modified:
lld/ELF/Writer.cpp
Removed:
################################################################################
diff --git a/lld/ELF/Writer.cpp b/lld/ELF/Writer.cpp
index acc78dd06734..986cca27fdf8 100644
--- a/lld/ELF/Writer.cpp
+++ b/lld/ELF/Writer.cpp
@@ -1774,12 +1774,11 @@ template <class ELFT> void Writer<ELFT>::optimizeBasicBlockJumps() {
// Delete all fall through jump instructions. Also, check if two
// consecutive jump instructions can be flipped so that a fall
// through jmp instruction can be deleted.
- parallelForEachN(0, sections.size(), [&](size_t i) {
+ for (size_t i = 0, e = sections.size(); i != e; ++i) {
InputSection *next = i + 1 < sections.size() ? sections[i + 1] : nullptr;
- InputSection &is = *sections[i];
- result[i] =
- target->deleteFallThruJmpInsn(is, is.getFile<ELFT>(), next) ? 1 : 0;
- });
+ InputSection &sec = *sections[i];
+ result[i] = target->deleteFallThruJmpInsn(sec, sec.file, next) ? 1 : 0;
+ }
size_t numDeleted = std::count(result.begin(), result.end(), 1);
if (numDeleted > 0) {
script->assignAddresses();
More information about the llvm-commits
mailing list