[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).
This commit is contained in:
Fangrui Song
2026-04-01 22:07:42 -07:00
committed by GitHub
parent 3346a76d32
commit 0bde74ab04

View File

@@ -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.