[ELF] Pass SectionPiece by reference in getSectionPiece. NFC#190110
Merged
Conversation
The generated assembly looks more optimized. In addition, this avoids widened load, which would cause a TSan-detected data race with parallel --gc-sections (llvm#189321).
You can test this locally with the following command:git-clang-format --diff origin/main HEAD --extensions cpp -- lld/ELF/InputSection.cpp --diff_from_common_commit
View the diff from clang-format here.diff --git a/lld/ELF/InputSection.cpp b/lld/ELF/InputSection.cpp
index 2177090c0..07022948b 100644
--- a/lld/ELF/InputSection.cpp
+++ b/lld/ELF/InputSection.cpp
@@ -1557,8 +1557,7 @@ SectionPiece &MergeInputSection::getSectionPiece(uint64_t offset) {
if (!(flags & SHF_STRINGS))
return pieces[offset / entsize];
return partition_point(
- pieces,
- [=](const 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.
|
zwu-2025
pushed a commit
to zwu-2025/llvm-project
that referenced
this pull request
May 17, 2026
…0110) The generated assembly looks more optimized. In addition, this avoids widened load, which would cause a TSan-detected data race with parallel --gc-sections (llvm#189321).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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).