[lld] 8120c9e - Rename option -icf MODE to --icf=MODE

Greg McGary via llvm-commits llvm-commits at lists.llvm.org
Fri Jun 18 09:52:48 PDT 2021


Author: Greg McGary
Date: 2021-06-18T09:52:15-07:00
New Revision: 8120c9e379c7cc1c91a6cecdc42760b3aa562f78

URL: https://github.com/llvm/llvm-project/commit/8120c9e379c7cc1c91a6cecdc42760b3aa562f78
DIFF: https://github.com/llvm/llvm-project/commit/8120c9e379c7cc1c91a6cecdc42760b3aa562f78.diff

LOG: Rename option -icf MODE to --icf=MODE

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

Added: 
    

Modified: 
    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

Removed: 
    


################################################################################
diff  --git a/lld/MachO/Driver.cpp b/lld/MachO/Driver.cpp
index d2d271271349..81c9c7484ca4 100644
--- a/lld/MachO/Driver.cpp
+++ b/lld/MachO/Driver.cpp
@@ -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;

diff  --git a/lld/MachO/Options.td b/lld/MachO/Options.td
index 9f9b8d301528..60d9addc0360 100644
--- a/lld/MachO/Options.td
+++ b/lld/MachO/Options.td
@@ -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">;

diff  --git a/lld/test/MachO/icf-options.s b/lld/test/MachO/icf-options.s
index 4aca312ba81d..0be44c9c07c1 100644
--- a/lld/test/MachO/icf-options.s
+++ b/lld/test/MachO/icf-options.s
@@ -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

diff  --git a/lld/test/MachO/icf-scale.s b/lld/test/MachO/icf-scale.s
index 211ea945f4ca..28c4ea7f776f 100644
--- a/lld/test/MachO/icf-scale.s
+++ b/lld/test/MachO/icf-scale.s
@@ -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,

diff  --git a/lld/test/MachO/icf.s b/lld/test/MachO/icf.s
index 3fbfcaebffd4..724c17c6f51a 100644
--- a/lld/test/MachO/icf.s
+++ b/lld/test/MachO/icf.s
@@ -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:


        


More information about the llvm-commits mailing list