From 1d2150fbc9f6339f7b77c81e19a9bc5c878fcc16 Mon Sep 17 00:00:00 2001 From: Lang Hames Date: Fri, 20 Oct 2017 00:53:16 +0000 Subject: [PATCH] [ExecutionEngine] After a heroic dev-meeting hack session, the JIT supports TLS. Turns on EmulatedTLS support by default in EngineBuilder. ;) llvm-svn: 316200 --- include/llvm/ExecutionEngine/ExecutionEngine.h | 5 +++++ lib/ExecutionEngine/TargetSelect.cpp | 3 ++- test/ExecutionEngine/MCJIT/tlvtest.ll | 10 ++++++++++ test/ExecutionEngine/OrcMCJIT/tlvtest.ll | 10 ++++++++++ 4 files changed, 27 insertions(+), 1 deletion(-) create mode 100644 test/ExecutionEngine/MCJIT/tlvtest.ll create mode 100644 test/ExecutionEngine/OrcMCJIT/tlvtest.ll diff --git a/include/llvm/ExecutionEngine/ExecutionEngine.h b/include/llvm/ExecutionEngine/ExecutionEngine.h index 70ee843095f..77c23b46d32 100644 --- a/include/llvm/ExecutionEngine/ExecutionEngine.h +++ b/include/llvm/ExecutionEngine/ExecutionEngine.h @@ -541,6 +541,7 @@ private: SmallVector MAttrs; bool VerifyModules; bool UseOrcMCJITReplacement; + bool EmulatedTLS = true; public: /// Default constructor for EngineBuilder. @@ -641,6 +642,10 @@ public: this->UseOrcMCJITReplacement = UseOrcMCJITReplacement; } + void setEmulatedTLS(bool EmulatedTLS) { + this->EmulatedTLS = EmulatedTLS; + } + TargetMachine *selectTarget(); /// selectTarget - Pick a target either via -march or by guessing the native diff --git a/lib/ExecutionEngine/TargetSelect.cpp b/lib/ExecutionEngine/TargetSelect.cpp index 5df5e1eabec..18dfa4e3c31 100644 --- a/lib/ExecutionEngine/TargetSelect.cpp +++ b/lib/ExecutionEngine/TargetSelect.cpp @@ -95,7 +95,8 @@ TargetMachine *EngineBuilder::selectTarget(const Triple &TargetTriple, TargetMachine *Target = TheTarget->createTargetMachine(TheTriple.getTriple(), MCPU, FeaturesStr, Options, RelocModel, CMModel, OptLevel, - /*JIT*/ true); + /*JIT*/ true); + Target->Options.EmulatedTLS = EmulatedTLS; assert(Target && "Could not allocate target machine!"); return Target; } diff --git a/test/ExecutionEngine/MCJIT/tlvtest.ll b/test/ExecutionEngine/MCJIT/tlvtest.ll new file mode 100644 index 00000000000..2596dabb63f --- /dev/null +++ b/test/ExecutionEngine/MCJIT/tlvtest.ll @@ -0,0 +1,10 @@ +; RUN: %lli %s > /dev/null + +@x = thread_local local_unnamed_addr global i32 0 + +define i32 @main() { +entry: + store i32 42, i32* @x + ret i32 0 +} + diff --git a/test/ExecutionEngine/OrcMCJIT/tlvtest.ll b/test/ExecutionEngine/OrcMCJIT/tlvtest.ll new file mode 100644 index 00000000000..2596dabb63f --- /dev/null +++ b/test/ExecutionEngine/OrcMCJIT/tlvtest.ll @@ -0,0 +1,10 @@ +; RUN: %lli %s > /dev/null + +@x = thread_local local_unnamed_addr global i32 0 + +define i32 @main() { +entry: + store i32 42, i32* @x + ret i32 0 +} +