This is an archive of the discontinued LLVM Phabricator instance.

[ELF] - Implemented --print-gc-sections command line argument.
ClosedPublic

Authored by grimar on Dec 8 2015, 2:16 AM.

Details

Summary

List all sections removed by garbage collection. This option is only effective if garbage collection has been enabled via the `--gc-sections' option.

Diff Detail

Repository
rL LLVM

Event Timeline

grimar updated this revision to Diff 42148.Dec 8 2015, 2:16 AM
grimar retitled this revision from to [ELF] - Implemented --print-gc-sections command line argument..
grimar updated this object.
grimar added reviewers: ruiu, rafael.
grimar added subscribers: llvm-commits, grimar.
ruiu added inline comments.Dec 8 2015, 9:42 AM
ELF/Writer.cpp
537 ↗(On Diff #42148)

If a function does not refer any member variable of a class, non-member function is preferred over member function.

541–542 ↗(On Diff #42148)

Since this is not a warning, don't use warning(). Instead, write the message out to llvm::errs().

579–580 ↗(On Diff #42148)
if (isDiscarded(C)) {
  reportDiscarded(C, F);
  continue;
}
grimar updated this revision to Diff 42280.Dec 9 2015, 2:47 AM

Addressed review comments.

ELF/Writer.cpp
537 ↗(On Diff #42148)

Done.

541–542 ↗(On Diff #42148)

Done.
I thought about adding message() method to error.h/cpp for such cases.
But then file name would not be consistent with content, since message is not an error.

579–580 ↗(On Diff #42148)

Done.

ruiu accepted this revision.Dec 9 2015, 10:07 AM
ruiu edited edge metadata.

LGTM with nits.

ELF/Writer.cpp
538 ↗(On Diff #42280)

Let's invert this condition to return early.

if (!Config->PrintGcSections || !IS || Is->isLive())
  return;
539–541 ↗(On Diff #42280)
llvm::errs() << "removing unused section from '" << IS->getSectionName()
             << "' in file '" << File->getName() << "'\n";
This revision is now accepted and ready to land.Dec 9 2015, 10:07 AM
grimar added inline comments.Dec 10 2015, 1:15 AM
ELF/Writer.cpp
538 ↗(On Diff #42280)

Done.

539–541 ↗(On Diff #42280)

Done.

This revision was automatically updated to reflect the committed changes.