[PATCH] D46755: [LLD][ELF] Implement --keep-unique option

Rui Ueyama via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon May 14 15:50:22 PDT 2018


ruiu accepted this revision.
ruiu added a comment.
This revision is now accepted and ready to land.

LGTM with these changes.



================
Comment at: ELF/Driver.cpp:1169-1170
+// these sections are inelligible for ICF.
+static void findKeepUniqueSections() {
+  for (llvm::StringRef Name : Config->KeepUnique) {
+    if (Symbol *Sym = Symtab->find(Name)) {
----------------
I'd think you don't need Config->KeepUnique if you pass Args to this function. If you do that, you can directly consume --keep-unique arguments like this

  for (auto *Arg : Args.filtered(OPT_keep_unique)) {
    StringRef Name = Arg->getValue();
    ...


================
Comment at: ELF/Driver.cpp:1171-1172
+  for (llvm::StringRef Name : Config->KeepUnique) {
+    if (Symbol *Sym = Symtab->find(Name)) {
+      if (auto *DefSym = dyn_cast<Defined>(Sym))
+        DefSym->Section->KeepUnique = true;
----------------
nit: you could do this

  if (auto *Sym = dyn_cast_or_null<Defined>(Symtab->Find(Name))


https://reviews.llvm.org/D46755





More information about the llvm-commits mailing list