diff --git a/lld/MachO/Driver.cpp b/lld/MachO/Driver.cpp --- a/lld/MachO/Driver.cpp +++ b/lld/MachO/Driver.cpp @@ -700,22 +700,22 @@ 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(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 --- a/lld/MachO/Options.td +++ b/lld/MachO/Options.td @@ -60,6 +60,10 @@ def print_dylib_search: Flag<["--"], "print-dylib-search">, HelpText<"Print which paths lld searched when trying to find dylibs">, Group; +def icf_eq: Joined<["--"], "icf=">, + HelpText<"Set level for identical code folding (default: none)">, + MetaVarName<"[none,safe,all]">, + Group; // 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 @@ HelpText<"Disable infra for branches beyond the maximum branch distance.">, Flags<[HelpHidden]>, Group; -def icf: Separate<["-"], "icf">, - HelpText<"Set level for identical code folding (default: none)">, - MetaVarName<"[none,safe,all]">, - Group; def no_deduplicate : Flag<["-"], "no_deduplicate">, - HelpText<"Disable code deduplicaiton (synonym for `-icf none')">, + HelpText<"Disable code deduplicaiton (synonym for `--icf=none')">, Group; def grp_version : OptionGroup<"version">, HelpText<"VERSION TARGETING">; diff --git a/lld/test/MachO/icf-options.s b/lld/test/MachO/icf-options.s --- 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 --- 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 --- 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: