[Cygwin] Use -femulated-tls by default since r257718 introduced the new pass.

FIXME: Add more targets to use emutls into clang/test/Driver/emulated-tls.cpp.
FIXME: Add cygwin tests into llvm/test/CodeGen/X86. Working in progress.
llvm-svn: 257984
This commit is contained in:
NAKAMURA Takumi 2016-01-16 03:44:52 +00:00
parent 55c83325ae
commit 33ff1dda6a
4 changed files with 9 additions and 6 deletions

View File

@ -74,6 +74,8 @@ Windows Support
Clang's support for building native Windows programs ...
TLS is enabled for Cygwin defaults to -femulated-tls.
C Language Changes in Clang
---------------------------

View File

@ -4597,7 +4597,7 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA,
Args.AddLastArg(CmdArgs, options::OPT_fno_operator_names);
// Emulated TLS is enabled by default on Android, and can be enabled manually
// with -femulated-tls.
bool EmulatedTLSDefault = Triple.isAndroid();
bool EmulatedTLSDefault = Triple.isAndroid() || Triple.isWindowsCygwinEnvironment();
if (Args.hasFlag(options::OPT_femulated_tls, options::OPT_fno_emulated_tls,
EmulatedTLSDefault))
CmdArgs.push_back("-femulated-tls");

View File

@ -0,0 +1,5 @@
// Cygwin uses emutls. Clang should pass -femulated-tls to cc1 and cc1 should pass EmulatedTLS to LLVM CodeGen.
// FIXME: Add more targets here to use emutls.
// RUN: %clang -### -std=c++11 -target i686-pc-cygwin %s 2>&1 | FileCheck %s
// CHECK: "-cc1" {{.*}}"-femulated-tls"

View File

@ -12477,17 +12477,13 @@ X86TargetLowering::LowerGlobalTLSAddress(SDValue Op, SelectionDAG &DAG) const {
GlobalAddressSDNode *GA = cast<GlobalAddressSDNode>(Op);
// Cygwin uses emutls.
// FIXME: It may be EmulatedTLS-generic also for X86-Android.
if (Subtarget->isTargetWindowsCygwin())
if (DAG.getTarget().Options.EmulatedTLS)
return LowerToTLSEmulatedModel(GA, DAG);
const GlobalValue *GV = GA->getGlobal();
auto PtrVT = getPointerTy(DAG.getDataLayout());
if (Subtarget->isTargetELF()) {
if (DAG.getTarget().Options.EmulatedTLS)
return LowerToTLSEmulatedModel(GA, DAG);
TLSModel::Model model = DAG.getTarget().getTLSModel(GV);
switch (model) {
case TLSModel::GeneralDynamic: