[lld] r288630 - Simplify ICF alignment handling.
Rui Ueyama via llvm-commits
llvm-commits at lists.llvm.org
Sun Dec 4 17:31:40 PST 2016
Author: ruiu
Date: Sun Dec 4 19:31:39 2016
New Revision: 288630
URL: http://llvm.org/viewvc/llvm-project?rev=288630&view=rev
Log:
Simplify ICF alignment handling.
Modified:
lld/trunk/ELF/ICF.cpp
lld/trunk/ELF/InputSection.cpp
lld/trunk/test/ELF/icf7.s
Modified: lld/trunk/ELF/ICF.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/ICF.cpp?rev=288630&r1=288629&r2=288630&view=diff
==============================================================================
--- lld/trunk/ELF/ICF.cpp (original)
+++ lld/trunk/ELF/ICF.cpp Sun Dec 4 19:31:39 2016
@@ -339,11 +339,7 @@ template <class ELFT> void ICF<ELFT>::ru
// the same color are consecutive in the vector.
std::stable_sort(Sections.begin(), Sections.end(),
[](InputSection<ELFT> *A, InputSection<ELFT> *B) {
- if (A->Color[0] != B->Color[0])
- return A->Color[0] < B->Color[0];
- // Within a group, put the highest alignment
- // requirement first, so that's the one we'll keep.
- return B->Alignment < A->Alignment;
+ return A->Color[0] < B->Color[0];
});
// Compare static contents and assign unique IDs for each static content.
Modified: lld/trunk/ELF/InputSection.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/InputSection.cpp?rev=288630&r1=288629&r2=288630&view=diff
==============================================================================
--- lld/trunk/ELF/InputSection.cpp (original)
+++ lld/trunk/ELF/InputSection.cpp Sun Dec 4 19:31:39 2016
@@ -622,7 +622,7 @@ template <class ELFT> void InputSection<
template <class ELFT>
void InputSection<ELFT>::replace(InputSection<ELFT> *Other) {
- assert(Other->Alignment <= this->Alignment);
+ this->Alignment = std::max(this->Alignment, Other->Alignment);
Other->Repl = this->Repl;
Other->Live = false;
}
Modified: lld/trunk/test/ELF/icf7.s
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/ELF/icf7.s?rev=288630&r1=288629&r2=288630&view=diff
==============================================================================
--- lld/trunk/test/ELF/icf7.s (original)
+++ lld/trunk/test/ELF/icf7.s Sun Dec 4 19:31:39 2016
@@ -4,8 +4,8 @@
# RUN: ld.lld %t -o %t2 --icf=all --verbose | FileCheck %s
# RUN: llvm-objdump -t %t2 | FileCheck -check-prefix=ALIGN %s
-# CHECK: selected .text.f2
-# CHECK: removed .text.f1
+# CHECK: selected .text.f1
+# CHECK: removed .text.f2
# ALIGN: 0000000000201000 .text 00000000 _start
# ALIGN: 0000000000201100 .text 00000000 f1
More information about the llvm-commits
mailing list