[llvm] r326341 - [TLS] use emulated TLS if the target supports only this mode

Chih-Hung Hsieh via llvm-commits llvm-commits at lists.llvm.org
Wed Feb 28 09:48:55 PST 2018


Author: chh
Date: Wed Feb 28 09:48:55 2018
New Revision: 326341

URL: http://llvm.org/viewvc/llvm-project?rev=326341&view=rev
Log:
[TLS] use emulated TLS if the target supports only this mode

Emulated TLS is enabled by llc flag -emulated-tls,
which is passed by clang driver.
When llc is called explicitly or from other drivers like LTO,
missing -emulated-tls flag would generate wrong TLS code for targets
that supports only this mode.
Now use useEmulatedTLS() instead of Options.EmulatedTLS to decide whether
emulated TLS code should be generated.
Unit tests are modified to run with and without the -emulated-tls flag.

Differential Revision: https://reviews.llvm.org/D42999


Modified:
    llvm/trunk/include/llvm/ADT/Triple.h
    llvm/trunk/include/llvm/CodeGen/CommandFlags.def
    llvm/trunk/include/llvm/Target/TargetMachine.h
    llvm/trunk/include/llvm/Target/TargetOptions.h
    llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
    llvm/trunk/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp
    llvm/trunk/lib/CodeGen/LowerEmuTLS.cpp
    llvm/trunk/lib/CodeGen/TargetPassConfig.cpp
    llvm/trunk/lib/ExecutionEngine/TargetSelect.cpp
    llvm/trunk/lib/Target/AArch64/AArch64ISelLowering.cpp
    llvm/trunk/lib/Target/ARM/ARMISelLowering.cpp
    llvm/trunk/lib/Target/Mips/MipsISelLowering.cpp
    llvm/trunk/lib/Target/PowerPC/PPCISelLowering.cpp
    llvm/trunk/lib/Target/Sparc/SparcISelLowering.cpp
    llvm/trunk/lib/Target/SystemZ/SystemZISelLowering.cpp
    llvm/trunk/lib/Target/TargetMachine.cpp
    llvm/trunk/lib/Target/X86/X86ISelLowering.cpp
    llvm/trunk/test/CodeGen/AArch64/emutls.ll
    llvm/trunk/test/CodeGen/AArch64/emutls_generic.ll
    llvm/trunk/test/CodeGen/ARM/emutls.ll
    llvm/trunk/test/CodeGen/ARM/emutls_generic.ll
    llvm/trunk/test/CodeGen/Mips/emutls_generic.ll
    llvm/trunk/test/CodeGen/PowerPC/emutls_generic.ll
    llvm/trunk/test/CodeGen/X86/emutls-pic.ll
    llvm/trunk/test/CodeGen/X86/emutls-pie.ll
    llvm/trunk/test/CodeGen/X86/emutls.ll
    llvm/trunk/test/CodeGen/X86/emutls_generic.ll
    llvm/trunk/test/CodeGen/X86/fast-isel-emutls.ll
    llvm/trunk/test/CodeGen/X86/global-access-pie-copyrelocs.ll
    llvm/trunk/test/CodeGen/X86/global-access-pie.ll
    llvm/trunk/test/CodeGen/X86/tls-android-negative.ll
    llvm/trunk/test/CodeGen/X86/tls-android.ll

Modified: llvm/trunk/include/llvm/ADT/Triple.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/ADT/Triple.h?rev=326341&r1=326340&r2=326341&view=diff
==============================================================================
--- llvm/trunk/include/llvm/ADT/Triple.h (original)
+++ llvm/trunk/include/llvm/ADT/Triple.h Wed Feb 28 09:48:55 2018
@@ -665,6 +665,11 @@ public:
     return !isOSBinFormatMachO();
   }
 
+  /// Tests whether the target uses emulated TLS as default.
+  bool hasDefaultEmulatedTLS() const {
+    return isAndroid() || isOSOpenBSD() || isWindowsCygwinEnvironment();
+  }
+
   /// @}
   /// @name Mutators
   /// @{

Modified: llvm/trunk/include/llvm/CodeGen/CommandFlags.def
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/CommandFlags.def?rev=326341&r1=326340&r2=326341&view=diff
==============================================================================
--- llvm/trunk/include/llvm/CodeGen/CommandFlags.def (original)
+++ llvm/trunk/include/llvm/CodeGen/CommandFlags.def Wed Feb 28 09:48:55 2018
@@ -286,6 +286,7 @@ static TargetOptions InitTargetOptionsFr
   Options.FunctionSections = FunctionSections;
   Options.UniqueSectionNames = UniqueSectionNames;
   Options.EmulatedTLS = EmulatedTLS;
+  Options.ExplicitEmulatedTLS = EmulatedTLS.getNumOccurrences() > 0;
   Options.ExceptionModel = ExceptionModel;
   Options.EmitStackSizeSection = EnableStackSizeSection;
 

Modified: llvm/trunk/include/llvm/Target/TargetMachine.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Target/TargetMachine.h?rev=326341&r1=326340&r2=326341&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Target/TargetMachine.h (original)
+++ llvm/trunk/include/llvm/Target/TargetMachine.h Wed Feb 28 09:48:55 2018
@@ -172,6 +172,9 @@ public:
 
   bool shouldAssumeDSOLocal(const Module &M, const GlobalValue *GV) const;
 
+  /// Returns true if this target uses emulated TLS.
+  bool useEmulatedTLS() const;
+
   /// Returns the TLS model which should be used for the given global variable.
   TLSModel::Model getTLSModel(const GlobalValue *GV) const;
 

Modified: llvm/trunk/include/llvm/Target/TargetOptions.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Target/TargetOptions.h?rev=326341&r1=326340&r2=326341&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Target/TargetOptions.h (original)
+++ llvm/trunk/include/llvm/Target/TargetOptions.h Wed Feb 28 09:48:55 2018
@@ -107,7 +107,8 @@ namespace llvm {
           EnableFastISel(false), EnableGlobalISel(false), UseInitArray(false),
           DisableIntegratedAS(false), RelaxELFRelocations(false),
           FunctionSections(false), DataSections(false),
-          UniqueSectionNames(true), TrapUnreachable(false), EmulatedTLS(false),
+          UniqueSectionNames(true), TrapUnreachable(false),
+          EmulatedTLS(false), ExplicitEmulatedTLS(false),
           EnableIPRA(false), EmitStackSizeSection(false) {}
 
     /// PrintMachineCode - This flag is enabled when the -print-machineinstrs
@@ -216,6 +217,9 @@ namespace llvm {
     /// function in the runtime library..
     unsigned EmulatedTLS : 1;
 
+    /// Whether -emulated-tls or -no-emulated-tls is set.
+    unsigned ExplicitEmulatedTLS : 1;
+
     /// This flag enables InterProcedural Register Allocation (IPRA).
     unsigned EnableIPRA : 1;
 

Modified: llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp?rev=326341&r1=326340&r2=326341&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp (original)
+++ llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp Wed Feb 28 09:48:55 2018
@@ -429,7 +429,7 @@ MCSymbol *AsmPrinter::getSymbol(const Gl
 
 /// EmitGlobalVariable - Emit the specified global variable to the .s file.
 void AsmPrinter::EmitGlobalVariable(const GlobalVariable *GV) {
-  bool IsEmuTLSVar = TM.Options.EmulatedTLS && GV->isThreadLocal();
+  bool IsEmuTLSVar = TM.useEmulatedTLS() && GV->isThreadLocal();
   assert(!(IsEmuTLSVar && GV->hasCommonLinkage()) &&
          "No emulated TLS variables in the common section");
 

Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp?rev=326341&r1=326340&r2=326341&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp (original)
+++ llvm/trunk/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp Wed Feb 28 09:48:55 2018
@@ -198,7 +198,7 @@ DIE *DwarfCompileUnit::getOrCreateGlobal
     if (Global) {
       const MCSymbol *Sym = Asm->getSymbol(Global);
       if (Global->isThreadLocal()) {
-        if (Asm->TM.Options.EmulatedTLS) {
+        if (Asm->TM.useEmulatedTLS()) {
           // TODO: add debug info for emulated thread local mode.
         } else {
           // FIXME: Make this work with -gsplit-dwarf.

Modified: llvm/trunk/lib/CodeGen/LowerEmuTLS.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/LowerEmuTLS.cpp?rev=326341&r1=326340&r2=326341&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/LowerEmuTLS.cpp (original)
+++ llvm/trunk/lib/CodeGen/LowerEmuTLS.cpp Wed Feb 28 09:48:55 2018
@@ -68,7 +68,7 @@ bool LowerEmuTLS::runOnModule(Module &M)
     return false;
 
   auto &TM = TPC->getTM<TargetMachine>();
-  if (!TM.Options.EmulatedTLS)
+  if (!TM.useEmulatedTLS())
     return false;
 
   bool Changed = false;

Modified: llvm/trunk/lib/CodeGen/TargetPassConfig.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/TargetPassConfig.cpp?rev=326341&r1=326340&r2=326341&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/TargetPassConfig.cpp (original)
+++ llvm/trunk/lib/CodeGen/TargetPassConfig.cpp Wed Feb 28 09:48:55 2018
@@ -748,7 +748,7 @@ bool TargetPassConfig::addCoreISelPasses
 }
 
 bool TargetPassConfig::addISelPasses() {
-  if (TM->Options.EmulatedTLS)
+  if (TM->useEmulatedTLS())
     addPass(createLowerEmuTLSPass());
 
   addPass(createPreISelIntrinsicLoweringPass());

Modified: llvm/trunk/lib/ExecutionEngine/TargetSelect.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/ExecutionEngine/TargetSelect.cpp?rev=326341&r1=326340&r2=326341&view=diff
==============================================================================
--- llvm/trunk/lib/ExecutionEngine/TargetSelect.cpp (original)
+++ llvm/trunk/lib/ExecutionEngine/TargetSelect.cpp Wed Feb 28 09:48:55 2018
@@ -97,6 +97,8 @@ TargetMachine *EngineBuilder::selectTarg
                                      Options, RelocModel, CMModel, OptLevel,
 				     /*JIT*/ true);
   Target->Options.EmulatedTLS = EmulatedTLS;
+  Target->Options.ExplicitEmulatedTLS = true;
+
   assert(Target && "Could not allocate target machine!");
   return Target;
 }

Modified: llvm/trunk/lib/Target/AArch64/AArch64ISelLowering.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/AArch64/AArch64ISelLowering.cpp?rev=326341&r1=326340&r2=326341&view=diff
==============================================================================
--- llvm/trunk/lib/Target/AArch64/AArch64ISelLowering.cpp (original)
+++ llvm/trunk/lib/Target/AArch64/AArch64ISelLowering.cpp Wed Feb 28 09:48:55 2018
@@ -3979,7 +3979,7 @@ AArch64TargetLowering::LowerELFGlobalTLS
 SDValue AArch64TargetLowering::LowerGlobalTLSAddress(SDValue Op,
                                                      SelectionDAG &DAG) const {
   const GlobalAddressSDNode *GA = cast<GlobalAddressSDNode>(Op);
-  if (DAG.getTarget().Options.EmulatedTLS)
+  if (DAG.getTarget().useEmulatedTLS())
     return LowerToTLSEmulatedModel(GA, DAG);
 
   if (Subtarget->isTargetDarwin())

Modified: llvm/trunk/lib/Target/ARM/ARMISelLowering.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMISelLowering.cpp?rev=326341&r1=326340&r2=326341&view=diff
==============================================================================
--- llvm/trunk/lib/Target/ARM/ARMISelLowering.cpp (original)
+++ llvm/trunk/lib/Target/ARM/ARMISelLowering.cpp Wed Feb 28 09:48:55 2018
@@ -3005,7 +3005,7 @@ ARMTargetLowering::LowerToTLSExecModels(
 SDValue
 ARMTargetLowering::LowerGlobalTLSAddress(SDValue Op, SelectionDAG &DAG) const {
   GlobalAddressSDNode *GA = cast<GlobalAddressSDNode>(Op);
-  if (DAG.getTarget().Options.EmulatedTLS)
+  if (DAG.getTarget().useEmulatedTLS())
     return LowerToTLSEmulatedModel(GA, DAG);
 
   if (Subtarget->isTargetDarwin())

Modified: llvm/trunk/lib/Target/Mips/MipsISelLowering.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/Mips/MipsISelLowering.cpp?rev=326341&r1=326340&r2=326341&view=diff
==============================================================================
--- llvm/trunk/lib/Target/Mips/MipsISelLowering.cpp (original)
+++ llvm/trunk/lib/Target/Mips/MipsISelLowering.cpp Wed Feb 28 09:48:55 2018
@@ -2069,7 +2069,7 @@ lowerGlobalTLSAddress(SDValue Op, Select
   // Local Exec TLS Model.
 
   GlobalAddressSDNode *GA = cast<GlobalAddressSDNode>(Op);
-  if (DAG.getTarget().Options.EmulatedTLS)
+  if (DAG.getTarget().useEmulatedTLS())
     return LowerToTLSEmulatedModel(GA, DAG);
 
   SDLoc DL(GA);

Modified: llvm/trunk/lib/Target/PowerPC/PPCISelLowering.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/PowerPC/PPCISelLowering.cpp?rev=326341&r1=326340&r2=326341&view=diff
==============================================================================
--- llvm/trunk/lib/Target/PowerPC/PPCISelLowering.cpp (original)
+++ llvm/trunk/lib/Target/PowerPC/PPCISelLowering.cpp Wed Feb 28 09:48:55 2018
@@ -2571,7 +2571,7 @@ SDValue PPCTargetLowering::LowerGlobalTL
   // large models could be added if users need it, at the cost of
   // additional complexity.
   GlobalAddressSDNode *GA = cast<GlobalAddressSDNode>(Op);
-  if (DAG.getTarget().Options.EmulatedTLS)
+  if (DAG.getTarget().useEmulatedTLS())
     return LowerToTLSEmulatedModel(GA, DAG);
 
   SDLoc dl(GA);

Modified: llvm/trunk/lib/Target/Sparc/SparcISelLowering.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/Sparc/SparcISelLowering.cpp?rev=326341&r1=326340&r2=326341&view=diff
==============================================================================
--- llvm/trunk/lib/Target/Sparc/SparcISelLowering.cpp (original)
+++ llvm/trunk/lib/Target/Sparc/SparcISelLowering.cpp Wed Feb 28 09:48:55 2018
@@ -2036,7 +2036,7 @@ SDValue SparcTargetLowering::LowerGlobal
                                                    SelectionDAG &DAG) const {
 
   GlobalAddressSDNode *GA = cast<GlobalAddressSDNode>(Op);
-  if (DAG.getTarget().Options.EmulatedTLS)
+  if (DAG.getTarget().useEmulatedTLS())
     return LowerToTLSEmulatedModel(GA, DAG);
 
   SDLoc DL(GA);

Modified: llvm/trunk/lib/Target/SystemZ/SystemZISelLowering.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/SystemZ/SystemZISelLowering.cpp?rev=326341&r1=326340&r2=326341&view=diff
==============================================================================
--- llvm/trunk/lib/Target/SystemZ/SystemZISelLowering.cpp (original)
+++ llvm/trunk/lib/Target/SystemZ/SystemZISelLowering.cpp Wed Feb 28 09:48:55 2018
@@ -2663,7 +2663,7 @@ SDValue SystemZTargetLowering::lowerThre
 
 SDValue SystemZTargetLowering::lowerGlobalTLSAddress(GlobalAddressSDNode *Node,
                                                      SelectionDAG &DAG) const {
-  if (DAG.getTarget().Options.EmulatedTLS)
+  if (DAG.getTarget().useEmulatedTLS())
     return LowerToTLSEmulatedModel(Node, DAG);
   SDLoc DL(Node);
   const GlobalValue *GV = Node->getGlobal();

Modified: llvm/trunk/lib/Target/TargetMachine.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/TargetMachine.cpp?rev=326341&r1=326340&r2=326341&view=diff
==============================================================================
--- llvm/trunk/lib/Target/TargetMachine.cpp (original)
+++ llvm/trunk/lib/Target/TargetMachine.cpp Wed Feb 28 09:48:55 2018
@@ -192,6 +192,14 @@ bool TargetMachine::shouldAssumeDSOLocal
   return false;
 }
 
+bool TargetMachine::useEmulatedTLS() const {
+  // Returns Options.EmulatedTLS if the -emulated-tls or -no-emulated-tls
+  // was specified explicitly; otherwise uses target triple to decide default.
+  if (Options.ExplicitEmulatedTLS)
+    return Options.EmulatedTLS;
+  return getTargetTriple().hasDefaultEmulatedTLS();
+}
+
 TLSModel::Model TargetMachine::getTLSModel(const GlobalValue *GV) const {
   bool IsPIE = GV->getParent()->getPIELevel() != PIELevel::Default;
   Reloc::Model RM = getRelocationModel();

Modified: llvm/trunk/lib/Target/X86/X86ISelLowering.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86ISelLowering.cpp?rev=326341&r1=326340&r2=326341&view=diff
==============================================================================
--- llvm/trunk/lib/Target/X86/X86ISelLowering.cpp (original)
+++ llvm/trunk/lib/Target/X86/X86ISelLowering.cpp Wed Feb 28 09:48:55 2018
@@ -15638,7 +15638,7 @@ X86TargetLowering::LowerGlobalTLSAddress
 
   GlobalAddressSDNode *GA = cast<GlobalAddressSDNode>(Op);
 
-  if (DAG.getTarget().Options.EmulatedTLS)
+  if (DAG.getTarget().useEmulatedTLS())
     return LowerToTLSEmulatedModel(GA, DAG);
 
   const GlobalValue *GV = GA->getGlobal();

Modified: llvm/trunk/test/CodeGen/AArch64/emutls.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/AArch64/emutls.ll?rev=326341&r1=326340&r2=326341&view=diff
==============================================================================
--- llvm/trunk/test/CodeGen/AArch64/emutls.ll (original)
+++ llvm/trunk/test/CodeGen/AArch64/emutls.ll Wed Feb 28 09:48:55 2018
@@ -1,5 +1,7 @@
 ; RUN: llc -emulated-tls -mtriple=aarch64-linux-android \
 ; RUN:     -relocation-model=pic -disable-fp-elim < %s | FileCheck -check-prefix=ARM64 %s
+; RUN: llc -mtriple=aarch64-linux-android \
+; RUN:     -relocation-model=pic -disable-fp-elim < %s | FileCheck -check-prefix=ARM64 %s
 
 ; Copied from X86/emutls.ll
 

Modified: llvm/trunk/test/CodeGen/AArch64/emutls_generic.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/AArch64/emutls_generic.ll?rev=326341&r1=326340&r2=326341&view=diff
==============================================================================
--- llvm/trunk/test/CodeGen/AArch64/emutls_generic.ll (original)
+++ llvm/trunk/test/CodeGen/AArch64/emutls_generic.ll Wed Feb 28 09:48:55 2018
@@ -9,6 +9,18 @@
 ; RUN: llc < %s -emulated-tls -mtriple=aarch64-apple-darwin -O3 \
 ; RUN:     | FileCheck -check-prefix=DARWIN %s
 
+; RUN: llc < %s -mtriple=aarch64-linux-android -relocation-model=pic \
+; RUN:     | FileCheck -check-prefix=ARM_64 %s
+; RUN: llc < %s -mtriple=aarch64-linux-android -relocation-model=pic -O3 \
+; RUN:     | FileCheck -check-prefix=ARM_64 %s
+; RUN: llc < %s -mtriple=aarch64-linux-android -O3 \
+; RUN:     | FileCheck -check-prefix=ARM_64 %s
+; aarch64-windows-gnu needs explicit -emulated-tls
+; RUN: llc < %s -mtriple=aarch64-apple-darwin -O3 \
+; RUN:     | FileCheck -check-prefix=NoEMU %s
+
+; NoEMU-NOT: __emutls
+
 ; Make sure that TLS symbols are emitted in expected order.
 
 @external_x = external thread_local global i32, align 8

Modified: llvm/trunk/test/CodeGen/ARM/emutls.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/ARM/emutls.ll?rev=326341&r1=326340&r2=326341&view=diff
==============================================================================
--- llvm/trunk/test/CodeGen/ARM/emutls.ll (original)
+++ llvm/trunk/test/CodeGen/ARM/emutls.ll Wed Feb 28 09:48:55 2018
@@ -1,5 +1,7 @@
 ; RUN: llc -emulated-tls -mtriple=arm-linux-android \
 ; RUN:     -relocation-model=pic < %s | FileCheck -check-prefix=ARM32 %s
+; RUN: llc -mtriple=arm-linux-android \
+; RUN:     -relocation-model=pic < %s | FileCheck -check-prefix=ARM32 %s
 
 ; Copied from X86/emutls.ll
 

Modified: llvm/trunk/test/CodeGen/ARM/emutls_generic.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/ARM/emutls_generic.ll?rev=326341&r1=326340&r2=326341&view=diff
==============================================================================
--- llvm/trunk/test/CodeGen/ARM/emutls_generic.ll (original)
+++ llvm/trunk/test/CodeGen/ARM/emutls_generic.ll Wed Feb 28 09:48:55 2018
@@ -11,6 +11,17 @@
 ; RUN: llc < %s -emulated-tls -mtriple=thumbv7-windows-gnu -O3 \
 ; RUN:     | FileCheck -check-prefix=WIN %s
 
+; RUN: llc < %s -mtriple=arm-linux-android -relocation-model=pic \
+; RUN:     | FileCheck -check-prefix=ARM_32 %s
+; RUN: llc < %s -mtriple=arm-linux-androidabi -relocation-model=pic \
+; RUN:     | FileCheck -check-prefix=ARM_32 %s
+; RUN: llc < %s -mtriple=arm-linux-androidabi -relocation-model=pic -O3 \
+; RUN:     | FileCheck -check-prefix=ARM_32 %s
+; RUN: llc < %s -mtriple=arm-linux-androidabi -O3 \
+; RUN:     | FileCheck -check-prefix=ARM_32 %s
+; arm-apple-darwin must use -emulated-tls
+; windows must use -emulated-tls
+
 ; Make sure that TLS symbols are emitted in expected order.
 
 @external_x = external thread_local global i32, align 8

Modified: llvm/trunk/test/CodeGen/Mips/emutls_generic.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/Mips/emutls_generic.ll?rev=326341&r1=326340&r2=326341&view=diff
==============================================================================
--- llvm/trunk/test/CodeGen/Mips/emutls_generic.ll (original)
+++ llvm/trunk/test/CodeGen/Mips/emutls_generic.ll Wed Feb 28 09:48:55 2018
@@ -3,6 +3,11 @@
 ; RUN: llc < %s -emulated-tls -mtriple=mips64el-linux-android -relocation-model=pic \
 ; RUN:     | FileCheck -check-prefix=MIPS_64 %s
 
+; RUN: llc < %s -mtriple=mipsel-linux-android -relocation-model=pic \
+; RUN:     | FileCheck -check-prefix=MIPS_32 %s
+; RUN: llc < %s -mtriple=mips64el-linux-android -relocation-model=pic \
+; RUN:     | FileCheck -check-prefix=MIPS_64 %s
+
 ; Make sure that TLS symbols are emitted in expected order.
 
 @external_x = external thread_local global i32, align 8

Modified: llvm/trunk/test/CodeGen/PowerPC/emutls_generic.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/PowerPC/emutls_generic.ll?rev=326341&r1=326340&r2=326341&view=diff
==============================================================================
--- llvm/trunk/test/CodeGen/PowerPC/emutls_generic.ll (original)
+++ llvm/trunk/test/CodeGen/PowerPC/emutls_generic.ll Wed Feb 28 09:48:55 2018
@@ -3,6 +3,13 @@
 ; RUN: llc < %s -emulated-tls -mtriple=powerpc-unknown-linux-gnu -relocation-model=pic \
 ; RUN:     | FileCheck %s
 
+; RUN: llc < %s -mtriple=powerpc64-unknown-linux-gnu -relocation-model=pic \
+; RUN:     | FileCheck -check-prefix=NoEMU %s
+; RUN: llc < %s -mtriple=powerpc-unknown-linux-gnu -relocation-model=pic \
+; RUN:     | FileCheck -check-prefix=NoEMU %s
+
+; NoEMU-NOT: __emutls
+
 ; Make sure that TLS symbols are emitted in expected order.
 
 @external_x = external thread_local global i32, align 8

Modified: llvm/trunk/test/CodeGen/X86/emutls-pic.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/emutls-pic.ll?rev=326341&r1=326340&r2=326341&view=diff
==============================================================================
--- llvm/trunk/test/CodeGen/X86/emutls-pic.ll (original)
+++ llvm/trunk/test/CodeGen/X86/emutls-pic.ll Wed Feb 28 09:48:55 2018
@@ -3,6 +3,13 @@
 ; RUN: llc < %s -emulated-tls -mtriple=i386-linux-android -relocation-model=pic | FileCheck -check-prefix=X32 %s
 ; RUN: llc < %s -emulated-tls -mtriple=x86_64-linux-android -relocation-model=pic | FileCheck -check-prefix=X64 %s
 
+; RUN: llc < %s -mtriple=i386-linux-gnu -relocation-model=pic | FileCheck -check-prefix=NoEMU %s
+; RUN: llc < %s -mtriple=x86_64-linux-gnu -relocation-model=pic | FileCheck -check-prefix=NoEMU %s
+; RUN: llc < %s -mtriple=i386-linux-android -relocation-model=pic | FileCheck -check-prefix=X32 %s
+; RUN: llc < %s -mtriple=x86_64-linux-android -relocation-model=pic | FileCheck -check-prefix=X64 %s
+
+; NoEMU-NOT: __emutls
+
 ; Use my_emutls_get_address like __emutls_get_address.
 @my_emutls_v_xyz = external global i8*, align 4
 declare i8* @my_emutls_get_address(i8*)

Modified: llvm/trunk/test/CodeGen/X86/emutls-pie.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/emutls-pie.ll?rev=326341&r1=326340&r2=326341&view=diff
==============================================================================
--- llvm/trunk/test/CodeGen/X86/emutls-pie.ll (original)
+++ llvm/trunk/test/CodeGen/X86/emutls-pie.ll Wed Feb 28 09:48:55 2018
@@ -7,6 +7,17 @@
 ; RUN: llc < %s -emulated-tls -mcpu=generic -mtriple=x86_64-linux-android -relocation-model=pic \
 ; RUN:   | FileCheck -check-prefix=X64 %s
 
+; RUN: llc < %s -mcpu=generic -mtriple=i386-linux-gnu -relocation-model=pic \
+; RUN:   | FileCheck -check-prefix=NoEMU %s
+; RUN: llc < %s -mcpu=generic -mtriple=x86_64-linux-gnu -relocation-model=pic \
+; RUN:   | FileCheck -check-prefix=NoEMU %s
+; RUN: llc < %s -mcpu=generic -mtriple=i386-linux-android -relocation-model=pic \
+; RUN:   | FileCheck -check-prefix=X32 %s
+; RUN: llc < %s -mcpu=generic -mtriple=x86_64-linux-android -relocation-model=pic \
+; RUN:   | FileCheck -check-prefix=X64 %s
+
+; NoEMU-NOT: __emutls
+
 ; Use my_emutls_get_address like __emutls_get_address.
 @my_emutls_v_xyz = external global i8*, align 4
 declare i8* @my_emutls_get_address(i8*)

Modified: llvm/trunk/test/CodeGen/X86/emutls.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/emutls.ll?rev=326341&r1=326340&r2=326341&view=diff
==============================================================================
--- llvm/trunk/test/CodeGen/X86/emutls.ll (original)
+++ llvm/trunk/test/CodeGen/X86/emutls.ll Wed Feb 28 09:48:55 2018
@@ -3,8 +3,15 @@
 ; RUN: llc < %s -emulated-tls -mtriple=i386-linux-android | FileCheck -check-prefix=X32 %s
 ; RUN: llc < %s -emulated-tls -mtriple=x86_64-linux-android | FileCheck -check-prefix=X64 %s
 
+; RUN: llc < %s -mtriple=i386-linux-gnu | FileCheck -check-prefix=NoEMU %s
+; RUN: llc < %s -mtriple=x86_64-linux-gnu | FileCheck -check-prefix=NoEMU %s
+; RUN: llc < %s -mtriple=i386-linux-android | FileCheck -check-prefix=X32 %s
+; RUN: llc < %s -mtriple=x86_64-linux-android | FileCheck -check-prefix=X64 %s
+
 ; Copied from tls.ll; emulated TLS model is not implemented
-; for *-pc-win32 and *-pc-winows targets yet.
+; for *-pc-win32 and *-pc-windows targets yet.
+
+; NoEMU-NOT: __emutls
 
 ; Use my_emutls_get_address like __emutls_get_address.
 @my_emutls_v_xyz = external global i8*, align 4

Modified: llvm/trunk/test/CodeGen/X86/emutls_generic.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/emutls_generic.ll?rev=326341&r1=326340&r2=326341&view=diff
==============================================================================
--- llvm/trunk/test/CodeGen/X86/emutls_generic.ll (original)
+++ llvm/trunk/test/CodeGen/X86/emutls_generic.ll Wed Feb 28 09:48:55 2018
@@ -7,6 +7,17 @@
 ; RUN: llc < %s -emulated-tls -mtriple=i386-linux-gnu -relocation-model=pic \
 ; RUN:     | FileCheck %s
 
+; RUN: llc < %s -mtriple=i686-linux-android -relocation-model=pic \
+; RUN:     | FileCheck -check-prefix=X86_32 %s
+; RUN: llc < %s -mtriple=i686-linux-android -relocation-model=pic \
+; RUN:     | FileCheck -check-prefix=X86_32 %s
+; RUN: llc < %s -mtriple=x86_64-linux-android -relocation-model=pic \
+; RUN:     | FileCheck -check-prefix=X86_64 %s
+; RUN: llc < %s -mtriple=i386-linux-gnu -relocation-model=pic \
+; RUN:     | FileCheck -check-prefix=NoEMU %s
+
+; NoEMU-NOT: __emutls
+
 ; Make sure that TLS symbols are emitted in expected order.
 
 @external_x = external thread_local global i32, align 8

Modified: llvm/trunk/test/CodeGen/X86/fast-isel-emutls.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/fast-isel-emutls.ll?rev=326341&r1=326340&r2=326341&view=diff
==============================================================================
--- llvm/trunk/test/CodeGen/X86/fast-isel-emutls.ll (original)
+++ llvm/trunk/test/CodeGen/X86/fast-isel-emutls.ll Wed Feb 28 09:48:55 2018
@@ -1,6 +1,10 @@
 ; RUN: llc < %s -emulated-tls -relocation-model=pic -mtriple=i686-unknown-linux-gnu -fast-isel | FileCheck %s
+; RUN: llc < %s -relocation-model=pic -mtriple=i686-unknown-linux-gnu -fast-isel \
+; RUN: | FileCheck -check-prefix=NoEMU %s
 ; PR3654
 
+; NoEMU-NOT: __emutls
+
 @v = thread_local global i32 0
 define i32 @f() nounwind {
 entry:

Modified: llvm/trunk/test/CodeGen/X86/global-access-pie-copyrelocs.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/global-access-pie-copyrelocs.ll?rev=326341&r1=326340&r2=326341&view=diff
==============================================================================
--- llvm/trunk/test/CodeGen/X86/global-access-pie-copyrelocs.ll (original)
+++ llvm/trunk/test/CodeGen/X86/global-access-pie-copyrelocs.ll Wed Feb 28 09:48:55 2018
@@ -1,8 +1,13 @@
-; RUN: llc < %s -mcpu=generic -mtriple=x86_64-linux-gnu -relocation-model=pic -pie-copy-relocations \
+; RUN: llc < %s -emulated-tls -mcpu=generic -mtriple=x86_64-linux-gnu -relocation-model=pic -pie-copy-relocations \
 ; RUN:   | FileCheck -check-prefix=X64 %s
 ; RUN: llc < %s -emulated-tls -mcpu=generic -mtriple=i386-linux-gnu -relocation-model=pic -pie-copy-relocations \
 ; RUN:   | FileCheck -check-prefix=X32 %s
 
+; RUN: llc < %s -mcpu=generic -mtriple=x86_64-linux-gnu -relocation-model=pic -pie-copy-relocations \
+; RUN:   | FileCheck -check-prefix=X64 %s
+; RUN: llc < %s -mcpu=generic -mtriple=i386-linux-gnu -relocation-model=pic -pie-copy-relocations \
+; RUN:   | FileCheck -check-prefix=X32 %s
+
 ; External Linkage
 @a = global i32 0, align 4
 

Modified: llvm/trunk/test/CodeGen/X86/global-access-pie.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/global-access-pie.ll?rev=326341&r1=326340&r2=326341&view=diff
==============================================================================
--- llvm/trunk/test/CodeGen/X86/global-access-pie.ll (original)
+++ llvm/trunk/test/CodeGen/X86/global-access-pie.ll Wed Feb 28 09:48:55 2018
@@ -1,8 +1,13 @@
-; RUN: llc < %s -mcpu=generic -mtriple=x86_64-linux-gnu -relocation-model=pic \
+; RUN: llc < %s -emulated-tls -mcpu=generic -mtriple=x86_64-linux-gnu -relocation-model=pic \
 ; RUN:   | FileCheck -check-prefix=X64 %s
 ; RUN: llc < %s -emulated-tls -mcpu=generic -mtriple=i386-linux-gnu -relocation-model=pic \
 ; RUN:   | FileCheck -check-prefix=X32 %s
 
+; RUN: llc < %s -mcpu=generic -mtriple=x86_64-linux-gnu -relocation-model=pic \
+; RUN:   | FileCheck -check-prefix=X64 %s
+; RUN: llc < %s -mcpu=generic -mtriple=i386-linux-gnu -relocation-model=pic \
+; RUN:   | FileCheck -check-prefix=X32 %s
+
 ; External Linkage
 @a = global i32 0, align 4
 

Modified: llvm/trunk/test/CodeGen/X86/tls-android-negative.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/tls-android-negative.ll?rev=326341&r1=326340&r2=326341&view=diff
==============================================================================
--- llvm/trunk/test/CodeGen/X86/tls-android-negative.ll (original)
+++ llvm/trunk/test/CodeGen/X86/tls-android-negative.ll Wed Feb 28 09:48:55 2018
@@ -1,6 +1,9 @@
 ; RUN: llc < %s -emulated-tls -mtriple=i686-linux-android -relocation-model=pic | FileCheck  %s
 ; RUN: llc < %s -emulated-tls -mtriple=x86_64-linux-android -relocation-model=pic | FileCheck  %s
 
+; RUN: llc < %s -mtriple=i686-linux-android -relocation-model=pic | FileCheck  %s
+; RUN: llc < %s -mtriple=x86_64-linux-android -relocation-model=pic | FileCheck  %s
+
 ; Make sure that some symboles are not emitted in emulated TLS model.
 
 @external_x = external thread_local global i32

Modified: llvm/trunk/test/CodeGen/X86/tls-android.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/tls-android.ll?rev=326341&r1=326340&r2=326341&view=diff
==============================================================================
--- llvm/trunk/test/CodeGen/X86/tls-android.ll (original)
+++ llvm/trunk/test/CodeGen/X86/tls-android.ll Wed Feb 28 09:48:55 2018
@@ -1,6 +1,9 @@
 ; RUN: llc < %s -emulated-tls -mtriple=i686-linux-android -relocation-model=pic | FileCheck  %s
 ; RUN: llc < %s -emulated-tls -mtriple=x86_64-linux-android -relocation-model=pic | FileCheck -check-prefix=X64 %s
 
+; RUN: llc < %s -mtriple=i686-linux-android -relocation-model=pic | FileCheck  %s
+; RUN: llc < %s -mtriple=x86_64-linux-android -relocation-model=pic | FileCheck -check-prefix=X64 %s
+
 ; Make sure that TLS symboles are emitted in expected order.
 
 @external_x = external thread_local global i32




More information about the llvm-commits mailing list