[PATCH] D49716: ELF: Do not ICF SHF_LINK_ORDER sections.

Peter Collingbourne via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Jul 23 19:50:55 PDT 2018


pcc created this revision.
pcc added reviewers: ruiu, grimar, peter.smith.
Herald added subscribers: kristof.beyls, arichardson, emaste.
Herald added a reviewer: javed.absar.
Herald added a reviewer: espindola.

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.


https://reviews.llvm.org/D49716

Files:
  lld/ELF/ICF.cpp
  lld/test/ELF/icf-link-order.s


Index: lld/test/ELF/icf-link-order.s
===================================================================
--- /dev/null
+++ lld/test/ELF/icf-link-order.s
@@ -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
Index: lld/ELF/ICF.cpp
===================================================================
--- lld/ELF/ICF.cpp
+++ lld/ELF/ICF.cpp
@@ -172,6 +172,11 @@
       !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.


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D49716.156963.patch
Type: text/x-patch
Size: 1155 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180724/3c6e06c0/attachment.bin>


More information about the llvm-commits mailing list