2121#include < llvm/IR/LLVMContext.h>
2222#include < llvm/IR/MDBuilder.h>
2323
24- #if defined(JULIA_ENABLE_THREADING)
25- # include < llvm/IR/InlineAsm.h>
26- # include < llvm/Transforms/Utils/BasicBlockUtils.h>
27- #endif
24+ #include < llvm/IR/InlineAsm.h>
25+ #include < llvm/Transforms/Utils/BasicBlockUtils.h>
2826
2927#include " julia.h"
3028#include " julia_internal.h"
@@ -61,21 +59,16 @@ struct LowerPTLS: public ModulePass {
6159 Type *T_int8;
6260 Type *T_size;
6361 PointerType *T_pint8;
64- #ifdef JULIA_ENABLE_THREADING
6562 GlobalVariable *ptls_slot{nullptr };
6663 GlobalVariable *ptls_offset{nullptr };
6764 void set_ptls_attrs (CallInst *ptlsStates) const ;
6865 Instruction *emit_ptls_tp (Value *offset, Instruction *insertBefore) const ;
6966 template <typename T> T *add_comdat (T *G) const ;
7067 GlobalVariable *create_aliased_global (Type *T, StringRef name) const ;
71- #else
72- GlobalVariable *static_tls;
73- #endif
7468 void fix_ptls_use (CallInst *ptlsStates);
7569 bool runOnModule (Module &M) override ;
7670};
7771
78- #ifdef JULIA_ENABLE_THREADING
7972void LowerPTLS::set_ptls_attrs (CallInst *ptlsStates) const
8073{
8174 ptlsStates->addAttribute (AttributeList::FunctionIndex, Attribute::ReadNone);
@@ -182,7 +175,6 @@ inline T *LowerPTLS::add_comdat(T *G) const
182175#endif
183176 return G;
184177}
185- #endif
186178
187179void LowerPTLS::fix_ptls_use (CallInst *ptlsStates)
188180{
@@ -191,7 +183,6 @@ void LowerPTLS::fix_ptls_use(CallInst *ptlsStates)
191183 return ;
192184 }
193185
194- #ifdef JULIA_ENABLE_THREADING
195186 if (imaging_mode) {
196187 if (jl_tls_elf_support) {
197188 // if (offset != 0)
@@ -245,10 +236,6 @@ void LowerPTLS::fix_ptls_use(CallInst *ptlsStates)
245236 ptlsStates->setCalledFunction (ptlsStates->getFunctionType (), ConstantExpr::getIntToPtr (val, T_ptls_getter));
246237 set_ptls_attrs (ptlsStates);
247238 }
248- #else
249- ptlsStates->replaceAllUsesWith (static_tls);
250- ptlsStates->eraseFromParent ();
251- #endif
252239}
253240
254241bool LowerPTLS::runOnModule (Module &_M)
@@ -268,15 +255,10 @@ bool LowerPTLS::runOnModule(Module &_M)
268255 T_int8 = Type::getInt8Ty (*ctx);
269256 T_size = sizeof (size_t ) == 8 ? Type::getInt64Ty (*ctx) : Type::getInt32Ty (*ctx);
270257 T_pint8 = T_int8->getPointerTo ();
271- #ifdef JULIA_ENABLE_THREADING
272258 if (imaging_mode) {
273259 ptls_slot = create_aliased_global (T_ptls_getter, " jl_get_ptls_states_slot" );
274260 ptls_offset = create_aliased_global (T_size, " jl_tls_offset" );
275261 }
276- #else
277- static_tls = new GlobalVariable (*M, T_ppjlvalue, false , GlobalVariable::ExternalLinkage,
278- NULL , " jl_tls_states" );
279- #endif
280262
281263 for (auto it = ptls_getter->user_begin (); it != ptls_getter->user_end ();) {
282264 auto call = cast<CallInst>(*it);
0 commit comments