[lld] [DO NOT MERGE][WIP] -- [lld][ICF] Don't merge symbols with different addends (PR #139493)
via llvm-commits
llvm-commits at lists.llvm.org
Sun May 11 21:27:58 PDT 2025
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 HEAD~1 HEAD --extensions cpp -- lld/ELF/ICF.cpp
``````````
</details>
<details>
<summary>
View the diff from clang-format here.
</summary>
``````````diff
diff --git a/lld/ELF/ICF.cpp b/lld/ELF/ICF.cpp
index 797d0968d..9f56f957a 100644
--- a/lld/ELF/ICF.cpp
+++ b/lld/ELF/ICF.cpp
@@ -335,8 +335,8 @@ bool ICF<ELFT>::equalsConstant(const InputSection *a, const InputSection *b) {
}
template <class ELFT, class RelTy>
-static SmallVector<std::pair<Symbol *, uint64_t>> getReloc(const InputSection *sec,
- Relocs<RelTy> relocs) {
+static SmallVector<std::pair<Symbol *, uint64_t>>
+getReloc(const InputSection *sec, Relocs<RelTy> relocs) {
SmallVector<std::pair<Symbol *, uint64_t>> syms;
for (auto ri = relocs.begin(), re = relocs.end(); ri != re; ++ri) {
Symbol &sym = sec->file->getRelocTargetSym(*ri);
@@ -347,7 +347,8 @@ static SmallVector<std::pair<Symbol *, uint64_t>> getReloc(const InputSection *s
}
template <class ELFT>
-static SmallVector<std::pair<Symbol *, uint64_t>> getRelocTargets(const InputSection *sec) {
+static SmallVector<std::pair<Symbol *, uint64_t>>
+getRelocTargets(const InputSection *sec) {
const RelsOrRelas<ELFT> rel = sec->template relsOrRelas<ELFT>();
if (rel.areRelocsCrel())
return getReloc<ELFT>(sec, rel.crels);
@@ -569,7 +570,8 @@ template <class ELFT> void ICF<ELFT>::run() {
if (end - begin == 1)
return;
print() << "selected section " << sections[begin];
- SmallVector<std::pair<Symbol *, uint64_t>> syms = getRelocTargets<ELFT>(sections[begin]);
+ SmallVector<std::pair<Symbol *, uint64_t>> syms =
+ getRelocTargets<ELFT>(sections[begin]);
for (size_t i = begin + 1; i < end; ++i) {
print() << " removing identical section " << sections[i];
sections[begin]->replace(sections[i]);
@@ -578,8 +580,9 @@ template <class ELFT> void ICF<ELFT>::run() {
assert(syms.size() == replacedSyms.size() &&
"Should have same number of syms!");
for (size_t i = 0; i < syms.size(); i++) {
- if (syms[i].first == replacedSyms[i].first || !syms[i].first->isGlobal() ||
- !replacedSyms[i].first->isGlobal() || syms[i].second != replacedSyms[i].second)
+ if (syms[i].first == replacedSyms[i].first ||
+ !syms[i].first->isGlobal() || !replacedSyms[i].first->isGlobal() ||
+ syms[i].second != replacedSyms[i].second)
continue;
symbolEquivalence.unionSets(syms[i].first, replacedSyms[i].first);
}
``````````
</details>
https://github.com/llvm/llvm-project/pull/139493
More information about the llvm-commits
mailing list