[PATCH] D40019: [LLD] [MinGW] Implement the --[no-]gc-sections and --icf options
Reid Kleckner via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Nov 14 09:22:18 PST 2017
rnk added inline comments.
================
Comment at: MinGW/Driver.cpp:173-175
+ if (auto *A = Args.getLastArg(OPT_gc_sections, OPT_no_gc_sections))
+ Add(A->getOption().getID() == OPT_gc_sections ? "-opt:ref" : "-opt:noref");
+ else
----------------
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");
================
Comment at: MinGW/Driver.cpp:180
+ StringRef S = A->getValue();
+ if (S == "none")
+ Add("-opt:noicf");
----------------
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".
https://reviews.llvm.org/D40019
More information about the llvm-commits
mailing list