Rename option -icf MODE to --icf=MODE
authorGreg McGary <gkm@fb.com>
Fri, 18 Jun 2021 16:38:50 +0000 (09:38 -0700)
committerGreg McGary <gkm@fb.com>
Fri, 18 Jun 2021 16:52:15 +0000 (09:52 -0700)
The `icf` command-line option is not present in ld64, so it should use the LLD option syntax, which begins with double dashes and separates primary option from any suboption with the equal sign.

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

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

index d2d2712..81c9c74 100644 (file)
@@ -700,22 +700,22 @@ getUndefinedSymbolTreatment(const ArgList &args) {
 
 static ICFLevel getICFLevel(const ArgList &args) {
   bool noDeduplicate = args.hasArg(OPT_no_deduplicate);
-  StringRef icfLevelStr = args.getLastArgValue(OPT_icf);
+  StringRef icfLevelStr = args.getLastArgValue(OPT_icf_eq);
   auto icfLevel = StringSwitch<ICFLevel>(icfLevelStr)
                       .Cases("none", "", ICFLevel::none)
                       .Case("safe", ICFLevel::safe)
                       .Case("all", ICFLevel::all)
                       .Default(ICFLevel::unknown);
   if (icfLevel == ICFLevel::unknown) {
-    warn(Twine("unknown -icf OPTION `") + icfLevelStr +
+    warn(Twine("unknown --icf=OPTION `") + icfLevelStr +
          "', defaulting to `none'");
     icfLevel = ICFLevel::none;
   } else if (icfLevel != ICFLevel::none && noDeduplicate) {
-    warn(Twine("`-icf " + icfLevelStr +
+    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'"));
+    warn(Twine("`--icf=safe' is not yet implemented, reverting to `none'"));
     icfLevel = ICFLevel::none;
   }
   return icfLevel;
index 9f9b8d3..60d9add 100644 (file)
@@ -60,6 +60,10 @@ def deduplicate_literals: Flag<["--"], "deduplicate-literals">,
 def print_dylib_search: Flag<["--"], "print-dylib-search">,
     HelpText<"Print which paths lld searched when trying to find dylibs">,
     Group<grp_lld>;
+def icf_eq: Joined<["--"], "icf=">,
+    HelpText<"Set level for identical code folding (default: none)">,
+    MetaVarName<"[none,safe,all]">,
+    Group<grp_lld>;
 
 // This is a complete Options.td compiled from Apple's ld(1) manpage
 // dated 2018-03-07 and cross checked with ld64 source code in repo
@@ -275,12 +279,8 @@ def no_branch_islands : Flag<["-"], "no_branch_islands">,
     HelpText<"Disable infra for branches beyond the maximum branch distance.">,
     Flags<[HelpHidden]>,
     Group<grp_opts>;
-def icf: Separate<["-"], "icf">,
-    HelpText<"Set level for identical code folding (default: none)">,
-    MetaVarName<"[none,safe,all]">,
-    Group<grp_opts>;
 def no_deduplicate : Flag<["-"], "no_deduplicate">,
-    HelpText<"Disable code deduplicaiton (synonym for `-icf none')">,
+    HelpText<"Disable code deduplicaiton (synonym for `--icf=none')">,
     Group<grp_opts>;
 
 def grp_version : OptionGroup<"version">, HelpText<"VERSION TARGETING">;
index 4aca312..0be44c9 100644 (file)
@@ -2,23 +2,23 @@
 # RUN: rm -rf %t; mkdir %t
 
 # RUN: llvm-mc -filetype=obj -triple=x86_64-apple-darwin %s -o %t/main.o
-# RUN: %lld -lSystem -icf all -o %t/all %t/main.o 2>&1 \
+# RUN: %lld -lSystem --icf=all -o %t/all %t/main.o 2>&1 \
 # RUN:     | FileCheck %s --check-prefix=DIAG-EMPTY --allow-empty
-# RUN: %lld -lSystem -icf none -o %t/none %t/main.o 2>&1 \
+# RUN: %lld -lSystem --icf=none -o %t/none %t/main.o 2>&1 \
 # RUN:     | FileCheck %s --check-prefix=DIAG-EMPTY --allow-empty
 # RUN: %lld -lSystem -no_deduplicate -o %t/no_dedup %t/main.o 2>&1 \
 # RUN:     | FileCheck %s --check-prefix=DIAG-EMPTY --allow-empty
-# RUN: not %lld -lSystem -icf safe -o %t/safe %t/main.o 2>&1 \
+# RUN: not %lld -lSystem --icf=safe -o %t/safe %t/main.o 2>&1 \
 # RUN:     | FileCheck %s --check-prefix=DIAG-SAFE
-# RUN: not %lld -lSystem -icf junk -o %t/junk %t/main.o 2>&1 \
+# 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: not %lld -lSystem --icf=all -no_deduplicate -o %t/clash %t/main.o 2>&1 \
 # RUN:     | FileCheck %s --check-prefix=DIAG-CLASH
 
 # 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'
+# 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/none | FileCheck %s --check-prefix=NOOP
index 211ea94..28c4ea7 100644 (file)
@@ -2,7 +2,7 @@
 # RUN: rm -rf %t*
 
 # RUN: llvm-mc -filetype=obj -triple=x86_64-apple-darwin %s -o %t.o
-# RUN: %lld -lSystem -icf all -o %t %t.o
+# RUN: %lld -lSystem --icf=all -o %t %t.o
 # RUN: llvm-objdump -d --syms %t | FileCheck %s
 
 ## When ICF has fewer than 1 Ki functions to segregate into equivalence classes,
index 3fbfcae..724c17c 100644 (file)
@@ -2,7 +2,7 @@
 # RUN: rm -rf %t; mkdir %t
 
 # RUN: llvm-mc -filetype=obj -triple=x86_64-apple-darwin %s -o %t/main.o
-# RUN: %lld -lSystem -icf all -o %t/main %t/main.o
+# RUN: %lld -lSystem --icf=all -o %t/main %t/main.o
 # RUN: llvm-objdump -d --syms %t/main | FileCheck %s
 
 # CHECK-LABEL: SYMBOL TABLE: