Page MenuHomePhabricator

[lld][ELF] remove empty SyntheticSections from inputSections

Authored by amilendra on Jul 21 2021, 2:08 AM.



Change removeUnusedSyntheticSections() to actually remove empty
SyntheticSections in inputSections.

In addition to doing what removeUnusedSyntheticSections() was meant
to do, this will also make the shuffle-sections tests, which shuffles
inputSections, less sensitive to empty Synthetic Sections that
will not appear in the final image.

Diff Detail

Event Timeline

amilendra created this revision.Jul 21 2021, 2:08 AM
amilendra requested review of this revision.Jul 21 2021, 2:08 AM
Herald added a project: Restricted Project. · View Herald TranscriptJul 21 2021, 2:08 AM
MaskRay added inline comments.Jul 21 2021, 1:05 PM

Use isa


Delete. The code below can handle the case.


The right hand side of auto end is now complex.

While here, you can refactor the code to do one batch llvm::erase_if for isd->sections instead of N llvm::erase_if.

You may need a DenseSet

MaskRay requested changes to this revision.Jul 24 2021, 2:23 PM
This revision now requires changes to proceed.Jul 24 2021, 2:23 PM
amilendra updated this revision to Diff 361593.Jul 26 2021, 1:42 AM

Address review comments

  • Use isa instead of dyncast.
  • Delete unnecessary check for vector end.
  • Refactor erasing of unused synthetic sections from corresponding input section descriptions
amilendra marked 2 inline comments as done.Jul 26 2021, 1:52 AM
amilendra added inline comments.

I hope this is what you had in mind.

amilendra marked an inline comment as done.Jul 26 2021, 5:44 AM
MaskRay accepted this revision.Jul 26 2021, 11:45 AM
This revision is now accepted and ready to land.Jul 26 2021, 11:45 AM
amilendra updated this revision to Diff 361828.Jul 26 2021, 3:26 PM

Rebase attempt 2

amilendra updated this revision to Diff 361995.Jul 27 2021, 5:37 AM

Fix clang-tidy errors

[lld][ELF] remove empty SyntheticSections from inputSections

The clang-tidy warnings I got locally were different from upstream.
Fix upstream warnings only.