[lld] r337967 - ELF: Do not ICF SHF_LINK_ORDER sections.

Peter Collingbourne via llvm-commits llvm-commits at lists.llvm.org
Wed Jul 25 14:40:55 PDT 2018


Author: pcc
Date: Wed Jul 25 14:40:54 2018
New Revision: 337967

URL: http://llvm.org/viewvc/llvm-project?rev=337967&view=rev
Log:
ELF: Do not ICF SHF_LINK_ORDER sections.

We are already ICF'ing these sections as a unit with their dependent
sections, so they don't need to be considered for ICF individually.

This change also "fixes" slowness caused by our quadratic-in-group-size
relocation segregation algorithm on 32-bit ARM platforms with unwind
data and ICF on rodata. In this scenario almost every function's
.ARM.exidx is identical except for the targets of the relocations
that refer to the function and its .ARM.extab, which causes almost
all of the program's .ARM.exidx sections to be initially added to the
same class, which causes us to compare every such section with every
other such section.

Differential Revision: https://reviews.llvm.org/D49716

Added:
    lld/trunk/test/ELF/icf-link-order.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=337967&r1=337966&r2=337967&view=diff
==============================================================================
--- lld/trunk/ELF/ICF.cpp (original)
+++ lld/trunk/ELF/ICF.cpp Wed Jul 25 14:40:54 2018
@@ -172,6 +172,11 @@ static bool isEligible(InputSection *S)
       !S->Name.startswith(".data.rel.ro."))
     return false;
 
+  // SHF_LINK_ORDER sections are ICF'd as a unit with their dependent sections,
+  // so we don't consider them for ICF individually.
+  if (S->Flags & SHF_LINK_ORDER)
+    return false;
+
   // Don't merge synthetic sections as their Data member is not valid and empty.
   // The Data member needs to be valid for ICF as it is used by ICF to determine
   // the equality of section contents.

Added: lld/trunk/test/ELF/icf-link-order.s
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/ELF/icf-link-order.s?rev=337967&view=auto
==============================================================================
--- lld/trunk/test/ELF/icf-link-order.s (added)
+++ lld/trunk/test/ELF/icf-link-order.s Wed Jul 25 14:40:54 2018
@@ -0,0 +1,18 @@
+# REQUIRES: x86
+
+# RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %s -o %t.o
+# RUN: ld.lld %t.o -o %t --icf=all --print-icf-sections | count 0
+
+.section .foo,"a", at progbits,unique,1
+foo1:
+.byte 1
+
+.section .foo,"a", at progbits,unique,2
+foo2:
+.byte 2
+
+.section .bar,"ao", at progbits,foo1,unique,1
+.byte 3
+
+.section .bar,"ao", at progbits,foo2,unique,2
+.byte 3




More information about the llvm-commits mailing list