[PATCH] D110672: [lld/mac] Don't warn on both --icf=all and -no_deduplicate

Nico Weber via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Sep 28 17:59:34 PDT 2021


thakis created this revision.
thakis added a reviewer: lld-macho.
thakis added a project: lld.
Herald added a subscriber: dang.
Herald added a reviewer: gkm.
Herald added a project: lld-macho.
thakis requested review of this revision.

Instead, just make the later flag win, like usual.
Implement this by making -no_deduplicate an actual alias for --icf=all
at the Options.td level.


https://reviews.llvm.org/D110672

Files:
  lld/MachO/Driver.cpp
  lld/MachO/Options.td
  lld/test/MachO/icf-options.s


Index: lld/test/MachO/icf-options.s
===================================================================
--- lld/test/MachO/icf-options.s
+++ lld/test/MachO/icf-options.s
@@ -12,16 +12,19 @@
 # RUN:     | FileCheck %s --check-prefix=DIAG-SAFE
 # RUN: not %lld -lSystem --icf=junk -o %t/junk %t/main.o 2>&1 \
 # RUN:     | FileCheck %s --check-prefix=DIAG-JUNK
-# RUN: not %lld -lSystem --icf=all -no_deduplicate -o %t/clash %t/main.o 2>&1 \
-# RUN:     | FileCheck %s --check-prefix=DIAG-CLASH
+# RUN: %lld -lSystem --icf=all -no_deduplicate -o %t/none2 %t/main.o 2>&1 \
+# RUN:     | FileCheck %s --check-prefix=DIAG-EMPTY --allow-empty
+# RUN: %lld -lSystem -no_deduplicate --icf=all -o %t/all2 %t/main.o 2>&1 \
+# RUN:     | FileCheck %s --check-prefix=DIAG-EMPTY --allow-empty
 
 # DIAG-EMPTY-NOT: {{.}}
 # DIAG-SAFE: `--icf=safe' is not yet implemented, reverting to `none'
 # DIAG-JUNK: unknown --icf=OPTION `junk', defaulting to `none'
-# DIAG-CLASH: `--icf=all' conflicts with -no_deduplicate, setting to `none'
 
 # RUN: llvm-objdump -d --syms %t/all | FileCheck %s --check-prefix=FOLD
+# RUN: llvm-objdump -d --syms %t/all2 | FileCheck %s --check-prefix=FOLD
 # RUN: llvm-objdump -d --syms %t/none | FileCheck %s --check-prefix=NOOP
+# RUN: llvm-objdump -d --syms %t/none2 | FileCheck %s --check-prefix=NOOP
 # RUN: llvm-objdump -d --syms %t/no_dedup | FileCheck %s --check-prefix=NOOP
 
 # FOLD-LABEL: SYMBOL TABLE:
Index: lld/MachO/Options.td
===================================================================
--- lld/MachO/Options.td
+++ lld/MachO/Options.td
@@ -290,6 +290,7 @@
     Group<grp_opts>;
 def no_deduplicate : Flag<["-"], "no_deduplicate">,
     HelpText<"Disable code deduplicaiton (synonym for `--icf=none')">,
+    Alias<icf_eq>, AliasArgs<["none"]>,
     Group<grp_opts>;
 
 def grp_version : OptionGroup<"version">, HelpText<"VERSION TARGETING">;
Index: lld/MachO/Driver.cpp
===================================================================
--- lld/MachO/Driver.cpp
+++ lld/MachO/Driver.cpp
@@ -705,7 +705,6 @@
 }
 
 static ICFLevel getICFLevel(const ArgList &args) {
-  bool noDeduplicate = args.hasArg(OPT_no_deduplicate);
   StringRef icfLevelStr = args.getLastArgValue(OPT_icf_eq);
   auto icfLevel = StringSwitch<ICFLevel>(icfLevelStr)
                       .Cases("none", "", ICFLevel::none)
@@ -716,10 +715,6 @@
     warn(Twine("unknown --icf=OPTION `") + icfLevelStr +
          "', defaulting to `none'");
     icfLevel = ICFLevel::none;
-  } else if (icfLevel != ICFLevel::none && noDeduplicate) {
-    warn(Twine("`--icf=" + icfLevelStr +
-               "' conflicts with -no_deduplicate, setting to `none'"));
-    icfLevel = ICFLevel::none;
   } else if (icfLevel == ICFLevel::safe) {
     warn(Twine("`--icf=safe' is not yet implemented, reverting to `none'"));
     icfLevel = ICFLevel::none;


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D110672.375756.patch
Type: text/x-patch
Size: 2843 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210929/81d1017c/attachment.bin>


More information about the llvm-commits mailing list