[lld] [COFF] Make ICF compare .pdata xdata references (PR #205456)
via llvm-commits
llvm-commits at lists.llvm.org
Tue Jun 23 16:53:49 PDT 2026
github-actions[bot] wrote:
<!--LLVM CODE FORMAT COMMENT: {clang-format}-->
:warning: C/C++ code formatter, clang-format found issues in your code. :warning:
<details>
<summary>
You can test this locally with the following command:
</summary>
``````````bash
git-clang-format --diff origin/main HEAD --extensions cpp -- lld/COFF/ICF.cpp --diff_from_common_commit
``````````
:warning:
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.
:warning:
</details>
<details>
<summary>
View the diff from clang-format here.
</summary>
``````````diff
diff --git a/lld/COFF/ICF.cpp b/lld/COFF/ICF.cpp
index 0b4cb9b19..9e1a4708a 100644
--- a/lld/COFF/ICF.cpp
+++ b/lld/COFF/ICF.cpp
@@ -23,8 +23,8 @@
#include "Symbols.h"
#include "lld/Common/Timer.h"
#include "llvm/ADT/DenseMap.h"
-#include "llvm/ADT/SmallVector.h"
#include "llvm/ADT/STLExtras.h"
+#include "llvm/ADT/SmallVector.h"
#include "llvm/Support/Parallel.h"
#include "llvm/Support/TimeProfiler.h"
#include "llvm/Support/xxhash.h"
@@ -47,12 +47,10 @@ private:
bool sectionEquals(const SectionChunk *a, const SectionChunk *b,
bool constant);
- bool pdataEquals(const SectionChunk *a, const SectionChunk *b,
- bool constant);
+ bool pdataEquals(const SectionChunk *a, const SectionChunk *b, bool constant);
bool describedPdataEquals(const SectionChunk *a, const SectionChunk *b,
bool constant);
- bool assocEquals(const SectionChunk *a, const SectionChunk *b,
- bool constant);
+ bool assocEquals(const SectionChunk *a, const SectionChunk *b, bool constant);
bool equalsConstant(const SectionChunk *a, const SectionChunk *b);
bool equalsVariable(const SectionChunk *a, const SectionChunk *b);
@@ -180,17 +178,17 @@ void ICF::recordPdataRefs() {
}
for (auto &it : pdataRefs) {
- llvm::stable_sort(it.second, [](const SectionChunk *a,
- const SectionChunk *b) {
- if (a->getSectionName() != b->getSectionName())
- return a->getSectionName() < b->getSectionName();
- ArrayRef<uint8_t> ac = a->getContents();
- ArrayRef<uint8_t> bc = b->getContents();
- if (!std::equal(ac.begin(), ac.end(), bc.begin(), bc.end()))
- return std::lexicographical_compare(ac.begin(), ac.end(), bc.begin(),
- bc.end());
- return a < b;
- });
+ llvm::stable_sort(
+ it.second, [](const SectionChunk *a, const SectionChunk *b) {
+ if (a->getSectionName() != b->getSectionName())
+ return a->getSectionName() < b->getSectionName();
+ ArrayRef<uint8_t> ac = a->getContents();
+ ArrayRef<uint8_t> bc = b->getContents();
+ if (!std::equal(ac.begin(), ac.end(), bc.begin(), bc.end()))
+ return std::lexicographical_compare(ac.begin(), ac.end(),
+ bc.begin(), bc.end());
+ return a < b;
+ });
}
}
@@ -245,8 +243,8 @@ static bool sectionNamesEqual(const SectionChunk *a, const SectionChunk *b) {
// identical .text may still behave differently if their .pdata records refer to
// different .xdata. Associative COMDAT children normally make that dependency
// visible to ICF, but old MSVC-produced object files do not always associate
-// .xdata with the parent .text section. Follow .pdata relocations defensively so
-// folding is allowed only when the reachable unwind info is equivalent.
+// .xdata with the parent .text section. Follow .pdata relocations defensively
+// so folding is allowed only when the reachable unwind info is equivalent.
bool ICF::pdataEquals(const SectionChunk *ap, const SectionChunk *bp,
bool constant) {
if (!isPData(ap) || !isPData(bp) || ap->getMachine() != bp->getMachine())
@@ -285,8 +283,7 @@ bool ICF::pdataEquals(const SectionChunk *ap, const SectionChunk *bp,
if (constant && ad->getValue() != bd->getValue())
return false;
- return ad->getChunk()->eqClass[cnt % 2] ==
- bd->getChunk()->eqClass[cnt % 2];
+ return ad->getChunk()->eqClass[cnt % 2] == bd->getChunk()->eqClass[cnt % 2];
};
for (size_t i = 0; i != ar.size(); ++i) {
``````````
</details>
https://github.com/llvm/llvm-project/pull/205456
More information about the llvm-commits
mailing list