[PATCH] D10524: Clang/driver: emulated TLS mode.
Reid Kleckner
rnk at google.com
Wed Jul 22 16:13:30 PDT 2015
rnk added inline comments.
================
Comment at: include/clang/Driver/Options.td:515
@@ -513,1 +514,3 @@
+ HelpText<"Use emutls functions to access thread_local variables">;
+def fno_emulated_tls : Flag<["-"], "fno-emulated-tls">, Group<f_Group>, Flags<[CC1Option]>;
def fencoding_EQ : Joined<["-"], "fencoding=">, Group<f_Group>;
----------------
This doesn't need to be a cc1 option, we can have just -femulated-tls for cc1 and remove the negative one in the driver.
================
Comment at: lib/Driver/Tools.cpp:3955-3956
@@ -3954,2 +3954,4 @@
Args.AddLastArg(CmdArgs, options::OPT_fno_operator_names);
+ Args.AddLastArg(CmdArgs, options::OPT_femulated_tls);
+ Args.AddLastArg(CmdArgs, options::OPT_fno_emulated_tls);
// AltiVec language extensions aren't relevant for assembling.
----------------
Generally we try to canonicalize flags in the driver rather than in cc1. Rather than doing this, how about something like the following:
// Emulated TLS is enabled by default on Android, and can be enabled manually with -femulated-tls.
bool EmulatedTLSDefault = Triple.getEnvironment() == llvm::Triple::Android;
if (Args.hasFlag(options::OPT_femulated_tls, options::OPT_fno_emulated_tls, EmulatedTLSDefault))
CmdArgs.push_back("-femulated-tls");
================
Comment at: test/CodeGen/tls-model.c:7
@@ +6,3 @@
+//
+// RUN: %clang %s -target x86_64-pc-linux-gnu -v -femulated-tls -S -emit-llvm -o - 2>&1 | \
+// RUN: FileCheck %s -check-prefix=EMU -check-prefix=CHECK-GD
----------------
We try to use %clang_cc1 outside of driver tests. We can check for the -femulated-tls flag easily in the driver, and then use the cc1 interface directly.
================
Comment at: test/CodeGen/tls-model.c:8-17
@@ -6,1 +7,12 @@
+// RUN: %clang %s -target x86_64-pc-linux-gnu -v -femulated-tls -S -emit-llvm -o - 2>&1 | \
+// RUN: FileCheck %s -check-prefix=EMU -check-prefix=CHECK-GD
+// RUN: %clang %s -target x86_64-pc-linux-gnu -v -fno-emulated-tls -S -emit-llvm -o - 2>&1 | \
+// RUN: FileCheck %s -check-prefix=NOEMU -check-prefix=CHECK-GD
+// RUN: %clang %s -target x86_64-linux-android -v -S -emit-llvm -o - 2>&1 | \
+// RUN: FileCheck %s -check-prefix=DEFAULT -check-prefix=CHECK-GD
+// EMU: -cc1 {{.*}} -femulated-tls
+// NOEMU: -cc1 {{.*}} -fno-emulated-tls
+// DEFAULT-NOT: -cc1 {{.*}} -femulated-tls
+// DEFAULT-NOT: -cc1 {{.*}} -fno-emulated-tls
+
----------------
We only need the first test for CodeGen.
http://reviews.llvm.org/D10524
More information about the llvm-commits
mailing list