Commit Graph

7 Commits

Author SHA1 Message Date
Fangrui Song 40a9f2251b [ELF] Replace unused output filenames with /dev/null in tests
Post commit review at rLLD335992

llvm-svn: 336129
2018-07-02 17:48:23 +00:00
Rui Ueyama 2d9e7a8956 Use toString to stringize sections and files.
Differential Revision: https://reviews.llvm.org/D43251

llvm-svn: 325065
2018-02-13 22:56:49 +00:00
Rui Ueyama 7b90efbece Do not print out removed ICF sections for -verbose.
GNU gold doesn't print out ICF sections for -verbose. It only shows
them for -print-icf-sections. We printed out them for -verbose because
we didn't have -print-icf-sections. Now that we have the option, there's
no reason to print out for -verbose.

Differential Revision: https://reviews.llvm.org/D43100

llvm-svn: 324755
2018-02-09 17:55:09 +00:00
James Henderson 9c6e2fd5a4 [ELF] Add --print-icf-sections flag
Currently ICF information is output through stderr if the "--verbose"
flag is used. This differs to Gold for example, which uses an explicit
flag to output this to stdout. This commit adds the
"--print-icf-sections" and "--no-print-icf-sections" flags and changes
the output message format for clarity and consistency with
"--print-gc-sections". These messages are still output to stderr if
using the verbose flag. However to avoid intermingled message output to
console, this will not occur when the "--print-icf-sections" flag is
used.

Existing tests have been modified to expect the new message format from
stderr.

Patch by Owen Reynolds.

Differential Revision: https://reviews.llvm.org/D42375

Reviewers: ruiu, rafael

Reviewed by: 

llvm-svn: 323976
2018-02-01 16:00:46 +00:00
Sam Clegg 77c1def71a Use ErrorOS for log messages as well as error
log are also diagnostics so it seems like they should to
the same place as errors and debug messages.

Without this change when I enable --verbose those messages
go to stdout, but when I enable "-mllvm -debug" those messages
go to stderr (because dbgs() goes to stderr by default).

So I end up having to do this a lot:
 lld <args> > output_message 2>&1

Differential Revision: https://reviews.llvm.org/D41033

llvm-svn: 320427
2017-12-11 21:57:31 +00:00
George Rimar ca1d1fb2d6 Error/warning/log messages should start with lowercase letters.
llvm-svn: 263549
2016-03-15 14:00:22 +00:00
Rui Ueyama 0b28952993 ELF: Implement ICF.
This patch implements the same algorithm as LLD/COFF's ICF. I'm
not going to repeat the same description about how it works, so you
want to read the comment in ICF.cpp in this patch if you want to know
the details. This algorithm should be more powerful than the ICF
algorithm implemented in GNU gold. It can even merge mutually-recursive
functions (which is harder than one might think).

ICF is a fairly effective size optimization. Here are some examples.

 LLD:   37.14 MB -> 35.80 MB (-3.6%)
 Clang: 59.41 MB -> 57.80 MB (-2.7%)

The lacking feature is "safe" version of ICF. This merges all
identical sections. That is not compatible with a C/C++ language
requirement that two distinct functions must have distinct addresses.

But as long as your program do not rely on the pointer equality
(which is in many cases true), your program should work with the
feature. LLD works fine for example.

GNU gold implements so-called "safe ICF" that identifies functions
that are safe to merge by heuristics -- for example, gold thinks
that constructors are safe to merge because there is no way to
take an address of a constructor in C++. We have a different idea
which David Majnemer suggested that we add NOPs at beginning of
merged functions so that two or more pointers can have distinct
values. We can do whichever we want, but this patch does not
include neither.

http://reviews.llvm.org/D17529

llvm-svn: 261912
2016-02-25 18:43:51 +00:00