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

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

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

541–542

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

579–580
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

Done.

541–542

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

Done.

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

LGTM with nits.

ELF/Writer.cpp
539

Let's invert this condition to return early.

if (!Config->PrintGcSections || !IS || Is->isLive())
  return;
540–542
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
539

Done.

540–542

Done.

This revision was automatically updated to reflect the committed changes.