diff options
author | Chris Lattner <sabre@nondot.org> | 2006-05-02 21:57:51 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2006-05-02 21:57:51 +0000 |
commit | 23621fe8f4a0c29db9f4d4937a40e28e6b11279e (patch) | |
tree | 1188886719b46ad7fb16d8c83749e4a1de686d9e /llvm/lib/ExecutionEngine/JIT/JIT.cpp | |
parent | 25b95ed8680fe742abf027bd878ffdfd3a721355 (diff) | |
download | bcm5719-llvm-23621fe8f4a0c29db9f4d4937a40e28e6b11279e.tar.gz bcm5719-llvm-23621fe8f4a0c29db9f4d4937a40e28e6b11279e.zip |
Do not make the JIT memory manager manage the memory for globals. Instead
just have the JIT malloc them.
llvm-svn: 28062
Diffstat (limited to 'llvm/lib/ExecutionEngine/JIT/JIT.cpp')
-rw-r--r-- | llvm/lib/ExecutionEngine/JIT/JIT.cpp | 20 |
1 files changed, 16 insertions, 4 deletions
diff --git a/llvm/lib/ExecutionEngine/JIT/JIT.cpp b/llvm/lib/ExecutionEngine/JIT/JIT.cpp index 5f426b877ef..4d3b5a349f7 100644 --- a/llvm/lib/ExecutionEngine/JIT/JIT.cpp +++ b/llvm/lib/ExecutionEngine/JIT/JIT.cpp @@ -301,10 +301,22 @@ void *JIT::getOrEmitGlobalVariable(const GlobalVariable *GV) { // If the global hasn't been emitted to memory yet, allocate space. We will // actually initialize the global after current function has finished // compilation. - uint64_t S = getTargetData().getTypeSize(GV->getType()->getElementType()); - unsigned char A = - getTargetData().getTypeAlignment(GV->getType()->getElementType()); - Ptr = MCE->allocateGlobal(S, A); + const Type *GlobalType = GV->getType()->getElementType(); + size_t S = getTargetData().getTypeSize(GlobalType); + size_t A = getTargetData().getTypeAlignment(GlobalType); + if (A <= 8) { + Ptr = malloc(S); + } else { + // Allocate S+A bytes of memory, then use an aligned pointer within that + // space. + Ptr = malloc(S+A); + unsigned MisAligned = ((intptr_t)Ptr & (A-1)); + unsigned Offset = MisAligned ? (A-MisAligned) : 0; + + // Trim the tail off the memory block. + realloc(Ptr, S+Offset); + Ptr = (char*)Ptr + Offset; + } state.getPendingGlobals(locked).push_back(GV); } addGlobalMapping(GV, Ptr); |