Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
[cling] Fix thread local storage in the cling JIT
TLS is currently not suppored in the JIT on some platforms.

However, it's possible to enable emulated TLS support in LLVM
which means that we now support TLS across many architectures.
The performance downsides of this are the overhead of accessing
the variable due to the additional indirection by the emulation.

However, this overhead is minimal and shouldn't affect most
programs. It also can be easily worked around from the user side.
This can be donefFor example by wrapping TLS variables into a single
TLS struct variable that then contains the other variables. Or just
minimizing referencing the TLS variable and use a normal copy of
the variable instead and write it back later.

Patch created with a lot of help from Lang Hames and Pavel Labath!
  • Loading branch information
Teemperor committed Nov 6, 2017
commit ad2b6ebc88c9b9079358e2f45fc702a6585154d2
4 changes: 3 additions & 1 deletion interpreter/cling/lib/Interpreter/IncrementalExecutor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,11 +72,13 @@ CreateHostTargetMachine(const clang::CompilerInstance& CI) {
std::string MCPU;
std::string FeaturesStr;

return std::unique_ptr<TargetMachine>(TheTarget->createTargetMachine(Triple,
auto TM = std::unique_ptr<TargetMachine>(TheTarget->createTargetMachine(Triple,
MCPU, FeaturesStr,
llvm::TargetOptions(),
Optional<Reloc::Model>(), CMModel,
OptLevel));
TM->Options.EmulatedTLS = true;
return TM;
}

} // anonymous namespace
Expand Down