Support for allocation of TLS variables in the JIT. Allocation of a global

variable is moved to the execution engine. The JIT calls the TargetJITInfo
to allocate thread local storage. Currently, only linux/x86 knows how to
allocate thread local global variables.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@58142 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Nicolas Geoffray
2008-10-25 15:41:43 +00:00
parent b74f370e43
commit 46fa139e26
7 changed files with 72 additions and 14 deletions

View File

@@ -562,7 +562,12 @@ void *JIT::getOrEmitGlobalVariable(const GlobalVariable *GV) {
const Type *GlobalType = GV->getType()->getElementType();
size_t S = getTargetData()->getABITypeSize(GlobalType);
size_t A = getTargetData()->getPreferredAlignment(GV);
Ptr = MCE->allocateSpace(S, A);
if (GV->isThreadLocal()) {
MutexGuard locked(lock);
Ptr = TJI.allocateThreadLocalMemory(S);
} else {
Ptr = MCE->allocateSpace(S, A);
}
addGlobalMapping(GV, Ptr);
EmitGlobalVariable(GV);
}
@@ -594,3 +599,17 @@ void *JIT::recompileAndRelinkFunction(Function *F) {
return Addr;
}
/// getMemoryForGV - This method abstracts memory allocation of global
/// variable so that the JIT can allocate thread local variables depending
/// on the target.
///
char* JIT::getMemoryForGV(const GlobalVariable* GV) {
const Type *ElTy = GV->getType()->getElementType();
size_t GVSize = (size_t)getTargetData()->getABITypeSize(ElTy);
if (GV->isThreadLocal()) {
MutexGuard locked(lock);
return TJI.allocateThreadLocalMemory(GVSize);
} else {
return new char[GVSize];
}
}