[PATCH] D33112: Optimize orphan plament in a general way

Rafael Ávila de Espíndola via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu May 11 17:18:26 PDT 2017


rafael created this revision.

We used to place orphans by just using compareSectionsNonScript.

Then we noticed that since linker scripts can use another order, we should first try match the section to a given PT_LOAD. But there is nothing special about PT_LOAD. The same issue can show up for PT_GNU_RELRO for example.

In general, we have to search for the most similar section and put the orphan next to it. Most similar being defined as how long they follow the same code path is compareSecitonsNonScript.

That is what this patch does. We now compute a rank for each output section, with a bit for each branch in what was compareSectionsNonScript.

With this findOrphanPos is now fully general and orphan placement can be optimized by placing every section with the same rank at once.

The included testcase is a variation of many-sections.s that uses allocatable sections to avoid the fast path in the existing code. Without threads it goes form 46 seconds to 0.9 seconds.


https://reviews.llvm.org/D33112

Files:
  ELF/OutputSections.h
  ELF/Writer.cpp
  test/ELF/linkerscript/sections-constraint.s
  test/ELF/linkerscript/sections.s
  test/ELF/many-alloc-sections.s

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D33112.98703.patch
Type: text/x-patch
Size: 17098 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170512/924e2ebf/attachment.bin>


More information about the llvm-commits mailing list