From 0bde74ab04992bcd63bc0bfd8b79e2ef5eab270b Mon Sep 17 00:00:00 2001 From: Fangrui Song Date: Wed, 1 Apr 2026 22:07:42 -0700 Subject: [PATCH] [ELF] Pass SectionPiece by reference in getSectionPiece. NFC (#190110) The generated assembly looks more optimized. In addition, this avoids widened load, which would cause a TSan-detected data race with parallel --gc-sections (#189321). --- lld/ELF/InputSection.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lld/ELF/InputSection.cpp b/lld/ELF/InputSection.cpp index fc82433cdcc9..2177090c0b46 100644 --- a/lld/ELF/InputSection.cpp +++ b/lld/ELF/InputSection.cpp @@ -1557,7 +1557,8 @@ SectionPiece &MergeInputSection::getSectionPiece(uint64_t offset) { if (!(flags & SHF_STRINGS)) return pieces[offset / entsize]; return partition_point( - pieces, [=](SectionPiece p) { return p.inputOff <= offset; })[-1]; + pieces, + [=](const SectionPiece &p) { return p.inputOff <= offset; })[-1]; } // Return the offset in an output section for a given input offset.