[PATCH] D143692: [clang][driver] Emit error when enabling emulated tls on unsupported architectures
Paul Kirth via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Thu Feb 9 16:29:15 PST 2023
paulkirth created this revision.
paulkirth added reviewers: arichardson, hiraditya, jrtc27, phosek.
Herald added subscribers: luismarques, s.egerton, PkmX, simoncook.
Herald added a project: All.
paulkirth requested review of this revision.
Herald added subscribers: cfe-commits, pcwang-thead, MaskRay.
Herald added a project: clang.
LLVM does not support Emulated TLS for some architectures, like RISCV.
This patch issues an error during options parsing to avoid potential
problems during codegen.
Bug: https://github.com/llvm/llvm-project/issues/59500
Depends on D143619 <https://reviews.llvm.org/D143619>
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D143692
Files:
clang/lib/Driver/ToolChains/Clang.cpp
clang/test/Driver/emulated-tls.cpp
Index: clang/test/Driver/emulated-tls.cpp
===================================================================
--- clang/test/Driver/emulated-tls.cpp
+++ clang/test/Driver/emulated-tls.cpp
@@ -28,6 +28,9 @@
// RUN: | FileCheck -check-prefix=NOEMU %s
// RUN: %clang -### -target i686-pc-openbsd %s -femulated-tls -fno-emulated-tls 2>&1 \
// RUN: | FileCheck -check-prefix=NOEMU %s
+//
+// RUN: %clang -### -target riscv64-linux-android %s -fno-emulated-tls -femulated-tls 2>&1 \
+// RUN: | FileCheck -check-prefix=RISCV-ERROR %s
// Default without -f[no-]emulated-tls, will be decided by the target triple.
@@ -40,3 +43,6 @@
// NOEMU: "-cc1" {{.*}}"-fno-emulated-tls"
// NOEMU-NOT: "-cc1" {{.*}}"-femulated-tls"
+
+// RISCV-ERROR: unsupported option '-femulated-tls' for target 'riscv64-unknown-linux-android'
+
Index: clang/lib/Driver/ToolChains/Clang.cpp
===================================================================
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -6166,6 +6166,17 @@
Args.AddLastArg(CmdArgs, options::OPT_fdigraphs, options::OPT_fno_digraphs);
Args.AddLastArg(CmdArgs, options::OPT_femulated_tls,
options::OPT_fno_emulated_tls);
+
+ if (Arg *A = Args.getLastArg(options::OPT_femulated_tls)) {
+ // LLVM does not support Emulated TLS for some architectures, like RISCV
+ // So issue an error to avoid subtle problems in codegen.
+ // https://github.com/llvm/llvm-project/issues/59500
+ if (!Triple.supportsEmulatedTLS()) {
+ D.Diag(diag::err_drv_unsupported_opt_for_target)
+ << A->getAsString(Args) << TripleStr;
+ }
+ }
+
Args.AddLastArg(CmdArgs, options::OPT_fzero_call_used_regs_EQ);
if (Arg *A = Args.getLastArg(options::OPT_fzero_call_used_regs_EQ)) {
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D143692.496278.patch
Type: text/x-patch
Size: 1797 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20230210/24ea1d13/attachment.bin>
More information about the cfe-commits
mailing list