This is an archive of the discontinued LLVM Phabricator instance.

[LLD] [MinGW] Implement the --[no-]gc-sections and --icf options
ClosedPublic

Authored by mstorsjo on Nov 14 2017, 3:40 AM.

Diff Detail

Event Timeline

mstorsjo created this revision.Nov 14 2017, 3:40 AM
rnk added inline comments.Nov 14 2017, 9:21 AM
MinGW/Driver.cpp
162–164

I think this might be a more idiomatic way to write this:

if (Args.hasFlag(OPT_gc_sections, OPT_no_gc_sections, false))
  Add("-opt:ref");
else
  Add("-opt:noref");
169

I don't think LLD has support for safe ICF. Safe ICF leveraged certain x86_32 ELF relocations that COFF lacks, and failing that, relies on knowledge about the Itanium C++ name mangling rules. LLD doesn't implement anything like that. LLD's ICF totally breaks function pointer identity. I would make --icf=all imply -opt:icf, otherwise -opt:noicf.

Also, this is likely to need changes in the near future if we make -opt:icf fold identical comdats of readonly data again. We'll need a way to say "only fold identical code".

mstorsjo updated this revision to Diff 122898.Nov 14 2017, 12:34 PM

Map --icf=safe to -opt:noicf, use Args.hasFlag.

mstorsjo marked 2 inline comments as done.Nov 14 2017, 12:34 PM
rnk accepted this revision.Nov 14 2017, 12:51 PM

lgtm

This revision is now accepted and ready to land.Nov 14 2017, 12:51 PM
ruiu added inline comments.Nov 14 2017, 11:26 PM
MinGW/Driver.cpp
160–161

Please add a blank line before a new if ~ else if ~ else block.

174

Don't you want to report an error for an unknown argument?

mstorsjo added inline comments.Nov 14 2017, 11:35 PM
MinGW/Driver.cpp
160–161

This is context from another one of the diffs that later was revised - I think it looks better now.

174

I guess that could be good as well, will update the diff.

mstorsjo updated this revision to Diff 122970.Nov 14 2017, 11:36 PM

Error out on unknown --icf parameters.

ruiu accepted this revision.Nov 14 2017, 11:42 PM

LGTM

This revision was automatically updated to reflect the committed changes.