[lld] 603d41a - [ELF] decompress: remove mutex
Fangrui Song via llvm-commits
llvm-commits at lists.llvm.org
Sun Dec 1 14:02:49 PST 2024
Author: Fangrui Song
Date: 2024-12-01T14:02:44-08:00
New Revision: 603d41ab7b4078a00a5d3b899d3b9d14eea2d8ff
URL: https://github.com/llvm/llvm-project/commit/603d41ab7b4078a00a5d3b899d3b9d14eea2d8ff
DIFF: https://github.com/llvm/llvm-project/commit/603d41ab7b4078a00a5d3b899d3b9d14eea2d8ff.diff
LOG: [ELF] decompress: remove mutex
decompress() is in the parallel code path splitIntoPieces
and we should avoid mutex.
Added:
Modified:
lld/ELF/InputSection.cpp
Removed:
################################################################################
diff --git a/lld/ELF/InputSection.cpp b/lld/ELF/InputSection.cpp
index 51065b63f7b83a..30c2ff4d79ba5b 100644
--- a/lld/ELF/InputSection.cpp
+++ b/lld/ELF/InputSection.cpp
@@ -128,15 +128,9 @@ static void decompressAux(Ctx &ctx, const InputSectionBase &sec, uint8_t *out,
void InputSectionBase::decompress() const {
Ctx &ctx = getCtx();
- uint8_t *uncompressedBuf;
- {
- static std::mutex mu;
- std::lock_guard<std::mutex> lock(mu);
- uncompressedBuf = ctx.bAlloc.Allocate<uint8_t>(size);
- }
-
- invokeELFT(decompressAux, ctx, *this, uncompressedBuf, size);
- content_ = uncompressedBuf;
+ uint8_t *buf = makeThreadLocalN<uint8_t>(size);
+ invokeELFT(decompressAux, ctx, *this, buf, size);
+ content_ = buf;
compressed = false;
}
More information about the llvm-commits
mailing list