[clang] 688b917 - Revert "[Driver] Delete -mimplicit-it="
Martin Storsjö via cfe-commits
cfe-commits at lists.llvm.org
Wed May 19 14:18:24 PDT 2021
Author: Martin Storsjö
Date: 2021-05-20T00:17:50+03:00
New Revision: 688b917b4b3cbe09bf4954b2c10b01ef57386c0a
URL: https://github.com/llvm/llvm-project/commit/688b917b4b3cbe09bf4954b2c10b01ef57386c0a
DIFF: https://github.com/llvm/llvm-project/commit/688b917b4b3cbe09bf4954b2c10b01ef57386c0a.diff
LOG: Revert "[Driver] Delete -mimplicit-it="
This reverts commit 2919222d8017f2425a85765b95e4b7c6f8e70ca4.
That commit broke backwards compatibility. Additionally, the
replacement, -Wa,-mimplicit-it, isn't yet supported by any stable
release of Clang.
See D102812 for a fix for the error cases when callers specify both
-mimplicit-it and -Wa,-mimplicit-it.
Added:
clang/test/Driver/arm-implicit-it.s
Modified:
clang/include/clang/Driver/Options.td
clang/lib/Driver/ToolChains/Clang.cpp
clang/test/Driver/arm-target-as-mimplicit-it.s
clang/test/Driver/as-options.s
Removed:
################################################################################
diff --git a/clang/include/clang/Driver/Options.td b/clang/include/clang/Driver/Options.td
index 1b78810bf352..1274f7a0af2e 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -3017,6 +3017,7 @@ def mtls_size_EQ : Joined<["-"], "mtls-size=">, Group<m_Group>, Flags<[NoXarchOp
HelpText<"Specify bit size of immediate TLS offsets (AArch64 ELF only): "
"12 (for 4KB) | 24 (for 16MB, default) | 32 (for 4GB) | 48 (for 256TB, needs -mcmodel=large)">,
MarshallingInfoInt<CodeGenOpts<"TLSSize">>;
+def mimplicit_it_EQ : Joined<["-"], "mimplicit-it=">, Group<m_Group>;
def mdefault_build_attributes : Joined<["-"], "mdefault-build-attributes">, Group<m_Group>;
def mno_default_build_attributes : Joined<["-"], "mno-default-build-attributes">, Group<m_Group>;
def mconstant_cfstrings : Flag<["-"], "mconstant-cfstrings">, Group<clang_ignored_m_Group>;
diff --git a/clang/lib/Driver/ToolChains/Clang.cpp b/clang/lib/Driver/ToolChains/Clang.cpp
index add62e3ab4ab..2ef635469df0 100644
--- a/clang/lib/Driver/ToolChains/Clang.cpp
+++ b/clang/lib/Driver/ToolChains/Clang.cpp
@@ -2393,6 +2393,22 @@ static void CollectArgsForIntegratedAssembler(Compilation &C,
DefaultIncrementalLinkerCompatible))
CmdArgs.push_back("-mincremental-linker-compatible");
+ switch (C.getDefaultToolChain().getArch()) {
+ case llvm::Triple::arm:
+ case llvm::Triple::armeb:
+ case llvm::Triple::thumb:
+ case llvm::Triple::thumbeb:
+ if (Arg *A = Args.getLastArg(options::OPT_mimplicit_it_EQ)) {
+ StringRef Value = A->getValue();
+ if (!AddARMImplicitITArgs(Args, CmdArgs, Value))
+ D.Diag(diag::err_drv_unsupported_option_argument)
+ << A->getOption().getName() << Value;
+ }
+ break;
+ default:
+ break;
+ }
+
// If you add more args here, also add them to the block below that
// starts with "// If CollectArgsForIntegratedAssembler() isn't called below".
@@ -4337,6 +4353,16 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA,
Args.ClaimAllArgs(options::OPT_mno_relax_all);
Args.ClaimAllArgs(options::OPT_mincremental_linker_compatible);
Args.ClaimAllArgs(options::OPT_mno_incremental_linker_compatible);
+ switch (C.getDefaultToolChain().getArch()) {
+ case llvm::Triple::arm:
+ case llvm::Triple::armeb:
+ case llvm::Triple::thumb:
+ case llvm::Triple::thumbeb:
+ Args.ClaimAllArgs(options::OPT_mimplicit_it_EQ);
+ break;
+ default:
+ break;
+ }
}
Args.ClaimAllArgs(options::OPT_Wa_COMMA);
Args.ClaimAllArgs(options::OPT_Xassembler);
diff --git a/clang/test/Driver/arm-implicit-it.s b/clang/test/Driver/arm-implicit-it.s
new file mode 100644
index 000000000000..48e4bdbe8c95
--- /dev/null
+++ b/clang/test/Driver/arm-implicit-it.s
@@ -0,0 +1,24 @@
+// RUN: %clang -target armv7--none-eabi -### %s 2>&1 \
+// RUN: | FileCheck %s -check-prefix CHECK-DEFAULT
+
+// RUN: %clang -target armv7--none-eabi -mimplicit-it=arm -### %s 2>&1 \
+// RUN: | FileCheck %s -check-prefix CHECK-ARM
+
+// RUN: %clang -target armv7--none-eabi -mimplicit-it=thumb -### %s 2>&1 \
+// RUN: | FileCheck %s -check-prefix CHECK-THUMB
+
+// RUN: %clang -target armv7--none-eabi -mimplicit-it=never -### %s 2>&1 \
+// RUN: | FileCheck %s -check-prefix CHECK-NEVER
+
+// RUN: %clang -target armv7--none-eabi -mimplicit-it=always -### %s 2>&1 \
+// RUN: | FileCheck %s -check-prefix CHECK-ALWAYS
+
+// RUN: %clang -target armv7--none-eabi -mimplicit-it=thisisnotavalidoption -### %s 2>&1 \
+// RUN: | FileCheck %s -check-prefix CHECK-INVALID
+
+// CHECK-DEFAULT-NOT: "-arm-implicit-it
+// CHECK-ARM: "-arm-implicit-it=arm"
+// CHECK-THUMB: "-arm-implicit-it=thumb"
+// CHECK-NEVER: "-arm-implicit-it=never"
+// CHECK-ALWAYS: "-arm-implicit-it=always"
+// CHECK-INVALID: error: unsupported argument 'thisisnotavalidoption' to option 'mimplicit-it='
diff --git a/clang/test/Driver/arm-target-as-mimplicit-it.s b/clang/test/Driver/arm-target-as-mimplicit-it.s
index e7da7cf691d6..b13b4918780c 100644
--- a/clang/test/Driver/arm-target-as-mimplicit-it.s
+++ b/clang/test/Driver/arm-target-as-mimplicit-it.s
@@ -20,6 +20,13 @@
// RUN: %clang -target arm-linux-gnueabi -### -Wa,-mimplicit-it=always,-mimplicit-it=arm %s 2>&1 | FileCheck %s --check-prefix=ARM
// RUN: %clang -target arm-linux-gnueabi -### -Wa,-mimplicit-it=always,-mimplicit-it=thumb %s 2>&1 | FileCheck %s --check-prefix=THUMB
+/// Mix -implicit-it= (compiler) with -Wa,-mimplicit-it= (assembler), assembler
+/// takes priority. -mllvm -arm-implicit-it= will be repeated, with the
+/// assembler flag appearing last (latter wins).
+// RUN: %clang -target arm-linux-gnueabi -### -mimplicit-it=never -Wa,-mimplicit-it=always %S/Inputs/wildcard1.c 2>&1 | FileCheck %s --check-prefix=NEVER_ALWAYS
+// RUN: %clang -target arm-linux-gnueabi -### -mimplicit-it=always -Wa,-mimplicit-it=never %S/Inputs/wildcard1.c 2>&1 | FileCheck %s --check-prefix=ALWAYS_NEVER
+// RUN: %clang -target arm-linux-gnueabi -### -Wa,-mimplicit-it=never -mimplicit-it=always %S/Inputs/wildcard1.c 2>&1 | FileCheck %s --check-prefix=ALWAYS_NEVER
+
/// Test invalid input.
// RUN: %clang -target arm-linux-gnueabi -### -Wa,-mimplicit-it=foo %s 2>&1 | FileCheck %s --check-prefix=INVALID
// RUN: %clang -target arm-linux-gnueabi -### -Xassembler -mimplicit-it=foo %s 2>&1 | FileCheck %s --check-prefix=XINVALID
@@ -31,5 +38,7 @@
// NEVER: "-mllvm" "-arm-implicit-it=never"
// ARM: "-mllvm" "-arm-implicit-it=arm"
// THUMB: "-mllvm" "-arm-implicit-it=thumb"
+// NEVER_ALWAYS: "-mllvm" "-arm-implicit-it=never" "-mllvm" "-arm-implicit-it=always"
+// ALWAYS_NEVER: "-mllvm" "-arm-implicit-it=always" "-mllvm" "-arm-implicit-it=never"
// INVALID: error: unsupported argument '-mimplicit-it=foo' to option 'Wa,'
// XINVALID: error: unsupported argument '-mimplicit-it=foo' to option 'Xassembler'
diff --git a/clang/test/Driver/as-options.s b/clang/test/Driver/as-options.s
index 3d35c6a99928..64269683ec34 100644
--- a/clang/test/Driver/as-options.s
+++ b/clang/test/Driver/as-options.s
@@ -53,6 +53,20 @@
// RUN: -o /dev/null -x assembler-with-cpp %s 2>&1 \
// RUN: | FileCheck --check-prefix=WARN --allow-empty %s
+// RUN: %clang -mimplicit-it=always -target armv7-linux-gnueabi -E \
+// RUN: -fintegrated-as -o /dev/null -x c++ %s 2>&1 \
+// RUN: | FileCheck --check-prefix=NOWARN --allow-empty %s
+// RUN: %clang -mimplicit-it=always -target armv7-linux-gnueabi -E \
+// RUN: -fno-integrated-as -o /dev/null -x c++ %s 2>&1 \
+// RUN: | FileCheck --check-prefix=WARN --allow-empty %s
+
+// RUN: %clang -mimplicit-it=always -target armv7-linux-gnueabi -E \
+// RUN: -fintegrated-as -o /dev/null -x assembler-with-cpp %s 2>&1 \
+// RUN: | FileCheck --check-prefix=NOWARN --allow-empty %s
+// RUN: %clang -mimplicit-it=always -target armv7-linux-gnueabi -E \
+// RUN: -fno-integrated-as -o /dev/null -x assembler-with-cpp %s 2>&1 \
+// RUN: | FileCheck --check-prefix=WARN --allow-empty %s
+
// RUN: %clang -Wa,-mbig-obj -target i386-pc-windows -E -fintegrated-as \
// RUN: -o /dev/null -x c++ %s 2>&1 \
// RUN: | FileCheck --check-prefix=NOWARN --allow-empty %s
More information about the cfe-commits
mailing list