Skip to content

[ELF] Pass SectionPiece by reference in getSectionPiece. NFC#190110

Merged
MaskRay merged 1 commit into
llvm:mainfrom
MaskRay:users/MaskRay/getSectionPiece-ref-1
Apr 2, 2026
Merged

[ELF] Pass SectionPiece by reference in getSectionPiece. NFC#190110
MaskRay merged 1 commit into
llvm:mainfrom
MaskRay:users/MaskRay/getSectionPiece-ref-1

Conversation

@MaskRay

@MaskRay MaskRay commented Apr 2, 2026

Copy link
Copy Markdown
Member

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

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).
@MaskRay MaskRay added the skip-precommit-approval PR for CI feedback, not intended for review label Apr 2, 2026
@MaskRay MaskRay merged commit 0bde74a into llvm:main Apr 2, 2026
6 of 11 checks passed
@github-actions

github-actions Bot commented Apr 2, 2026

Copy link
Copy Markdown

⚠️ C/C++ code formatter, clang-format found issues in your code. ⚠️

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

⚠️
The reproduction instructions above might return results for more than one PR
in a stack if you are using a stacked PR workflow. You can limit the results by
changing origin/main to the base branch/commit you want to compare against.
⚠️

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).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

lld:ELF lld skip-precommit-approval PR for CI feedback, not intended for review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants