[lld] r288511 - Removed a wrong assertion about non-colorable sections.
Rui Ueyama via llvm-commits
llvm-commits at lists.llvm.org
Fri Dec 2 09:23:59 PST 2016
Author: ruiu
Date: Fri Dec 2 11:23:58 2016
New Revision: 288511
URL: http://llvm.org/viewvc/llvm-project?rev=288511&view=rev
Log:
Removed a wrong assertion about non-colorable sections.
The assertion asserted that colorable sections can never have
a reference to non-colorable sections, but that was simply wrong.
They can have references to non-colorable sections. If that's the
case, referenced sections must be the same in terms of pointer
comparison.
Added:
lld/trunk/test/ELF/Inputs/icf-non-mergeable.s
lld/trunk/test/ELF/icf-non-mergeable.s
Modified:
lld/trunk/ELF/ICF.cpp
Modified: lld/trunk/ELF/ICF.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/ICF.cpp?rev=288511&r1=288510&r2=288511&view=diff
==============================================================================
--- lld/trunk/ELF/ICF.cpp (original)
+++ lld/trunk/ELF/ICF.cpp Fri Dec 2 11:23:58 2016
@@ -242,9 +242,10 @@ bool ICF<ELFT>::variableEq(const InputSe
// same iteration.
size_t Idx = (Config->Threads ? Cnt : Cnt + 1) % 2;
- // All colorable sections must have some colors.
- // 0 is a default non-color value.
- assert(X->Color[Idx] != 0 && Y->Color[Idx] != 0);
+ // Ineligible sections have the special color 0.
+ // They can never be the same in terms of section colors.
+ if (X->Color[Idx] == 0)
+ return false;
return X->Color[Idx] == Y->Color[Idx];
};
Added: lld/trunk/test/ELF/Inputs/icf-non-mergeable.s
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/ELF/Inputs/icf-non-mergeable.s?rev=288511&view=auto
==============================================================================
--- lld/trunk/test/ELF/Inputs/icf-non-mergeable.s (added)
+++ lld/trunk/test/ELF/Inputs/icf-non-mergeable.s Fri Dec 2 11:23:58 2016
@@ -0,0 +1,8 @@
+.globl d1, d2
+.section .data.d1, "aw"
+d1:
+ .quad 0
+
+.section .data.d2, "aw"
+d2:
+ .quad 0
Added: lld/trunk/test/ELF/icf-non-mergeable.s
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/ELF/icf-non-mergeable.s?rev=288511&view=auto
==============================================================================
--- lld/trunk/test/ELF/icf-non-mergeable.s (added)
+++ lld/trunk/test/ELF/icf-non-mergeable.s Fri Dec 2 11:23:58 2016
@@ -0,0 +1,28 @@
+// REQUIRES: x86
+
+// This file contains two functions. They are themselves identical,
+// but because they have reloactions against different data section,
+// they are not mergeable.
+
+// RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t1
+// RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux \
+// RUN: %p/Inputs/icf-non-mergeable.s -o %t2
+
+// RUN: ld.lld %t1 %t2 -o %t3 --icf=all --verbose | FileCheck %s
+
+// CHECK-NOT: selected .text.f1
+// CHECK-NOT: removed .text.f2
+
+.globl _start, f1, f2, d1, d2
+_start:
+ ret
+
+.section .text.f1, "ax"
+f1:
+ movl $5, d1
+ ret
+
+.section .text.f2, "ax"
+f2:
+ movl $5, d2
+ ret
More information about the llvm-commits
mailing list