llvm: Use emulated TLS when appropriate for the target

Closes #24236.
This commit is contained in:
Alex Rønne Petersen
2025-07-06 22:19:08 +02:00
parent c96c913bab
commit b5cc658ab4
6 changed files with 22 additions and 3 deletions

View File

@@ -83,7 +83,7 @@ static const bool assertions_on = false;
LLVMTargetMachineRef ZigLLVMCreateTargetMachine(LLVMTargetRef T, const char *Triple,
const char *CPU, const char *Features, LLVMCodeGenOptLevel Level, LLVMRelocMode Reloc,
LLVMCodeModel CodeModel, bool function_sections, bool data_sections, ZigLLVMFloatABI float_abi,
const char *abi_name)
const char *abi_name, bool emulated_tls)
{
std::optional<Reloc::Model> RM;
switch (Reloc){
@@ -149,6 +149,10 @@ LLVMTargetMachineRef ZigLLVMCreateTargetMachine(LLVMTargetRef T, const char *Tri
opt.MCOptions.ABIName = abi_name;
}
if (emulated_tls) {
opt.EmulatedTLS = true;
}
TargetMachine *TM = reinterpret_cast<Target*>(T)->createTargetMachine(Triple, CPU, Features, opt, RM, CM,
OL, JIT);
return reinterpret_cast<LLVMTargetMachineRef>(TM);