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!
This commit is contained in:
Raphael Isemann 2017-11-06 16:19:02 +01:00 committed by sftnight
parent 3bf7bc1a48
commit 89c6351e3a

View File

@ -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