This is an archive of the discontinued LLVM Phabricator instance.

ELF: Do not ICF SHF_LINK_ORDER sections.
ClosedPublic

Authored by pcc on Jul 23 2018, 7:50 PM.

Details

Summary

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.

Diff Detail

Repository
rL LLVM

Event Timeline

pcc created this revision.Jul 23 2018, 7:50 PM

I definitely think that it is the right thing to do to consider the section and the SHF_LINK_ORDER section as a unit. I'm assuming that no merging of the code sections is done if the SHF_LINK_ORDER sections are different.

lld/test/ELF/icf-link-order.s
3 ↗(On Diff #156963)

Some suggestions for additional cases:

  • Two identical executable sections but only one of the sections has a SHF_LINK_ORDER section, for example -fno-exceptions in a subset of the files.
  • Two identical executable sections but two different SHF_LINK_ORDER sections. I don't think that this is likely with Arm exception tables but it may be possible with other uses of SHF_LINK_ORDER.
ruiu accepted this revision.Jul 24 2018, 2:45 PM

LGTM

This revision is now accepted and ready to land.Jul 24 2018, 2:45 PM
pcc added a comment.Jul 25 2018, 2:16 PM

I'm assuming that no merging of the code sections is done if the SHF_LINK_ORDER sections are different.

That's something that I think we should do (we do something equivalent in the COFF linker for Windows EH sections) but don't currently do. I'll file a bug about that.

pcc added a comment.Jul 25 2018, 2:31 PM

Looks like we already have https://bugs.llvm.org/show_bug.cgi?id=36272 about this.

This revision was automatically updated to reflect the committed changes.