From c19315ef60828b96ce77ab8adca58b3c529c8b70 Mon Sep 17 00:00:00 2001 From: Nico Weber Date: Tue, 28 Sep 2021 20:57:40 -0400 Subject: [PATCH] [lld/mac] Don't warn on both --icf=all and -no_deduplicate Instead, just make the later flag win, like usual. Implement this by making -no_deduplicate an actual alias for --icf=none at the Options.td level. Differential Revision: https://reviews.llvm.org/D110672 --- lld/MachO/Driver.cpp | 5 ----- lld/MachO/Options.td | 1 + lld/test/MachO/icf-options.s | 9 ++++++--- 3 files changed, 7 insertions(+), 8 deletions(-) diff --git a/lld/MachO/Driver.cpp b/lld/MachO/Driver.cpp index 2780d2b9d596..449eb745aeb5 100644 --- a/lld/MachO/Driver.cpp +++ b/lld/MachO/Driver.cpp @@ -705,7 +705,6 @@ getUndefinedSymbolTreatment(const ArgList &args) { } static ICFLevel getICFLevel(const ArgList &args) { - bool noDeduplicate = args.hasArg(OPT_no_deduplicate); StringRef icfLevelStr = args.getLastArgValue(OPT_icf_eq); auto icfLevel = StringSwitch(icfLevelStr) .Cases("none", "", ICFLevel::none) @@ -716,10 +715,6 @@ static ICFLevel getICFLevel(const ArgList &args) { 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; diff --git a/lld/MachO/Options.td b/lld/MachO/Options.td index cda857d605bd..a51cd8474c82 100644 --- a/lld/MachO/Options.td +++ b/lld/MachO/Options.td @@ -290,6 +290,7 @@ def no_branch_islands : Flag<["-"], "no_branch_islands">, Group; def no_deduplicate : Flag<["-"], "no_deduplicate">, HelpText<"Disable code deduplicaiton (synonym for `--icf=none')">, + Alias, AliasArgs<["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 index 0be44c9c07c1..3a6eddb80361 100644 --- a/lld/test/MachO/icf-options.s +++ b/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: