diff options
| author | Evan Cheng <evan.cheng@apple.com> | 2008-11-04 09:30:48 +0000 |
|---|---|---|
| committer | Evan Cheng <evan.cheng@apple.com> | 2008-11-04 09:30:48 +0000 |
| commit | 4a8e3b4f4e6efae315b04d6930e82baa84e746ab (patch) | |
| tree | 7a39d3291145c5b0cbe3a9cb996fff3d711d9403 /lib/ExecutionEngine | |
| parent | 8accc3aeef113589eab24aeebc2845a39ace4264 (diff) | |
| download | external_llvm-4a8e3b4f4e6efae315b04d6930e82baa84e746ab.zip external_llvm-4a8e3b4f4e6efae315b04d6930e82baa84e746ab.tar.gz external_llvm-4a8e3b4f4e6efae315b04d6930e82baa84e746ab.tar.bz2 | |
For some targets, it's not possible to place GVs in the same memory buffer as the MachineCodeEmitter allocated memory. Code and data has different read / write / execution privilege requirements.
This is a short term workaround. The current solution is for the JIT memory manager to manage code and data memory separately.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@58688 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/ExecutionEngine')
| -rw-r--r-- | lib/ExecutionEngine/JIT/JIT.cpp | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/lib/ExecutionEngine/JIT/JIT.cpp b/lib/ExecutionEngine/JIT/JIT.cpp index b768f4d..83923a2 100644 --- a/lib/ExecutionEngine/JIT/JIT.cpp +++ b/lib/ExecutionEngine/JIT/JIT.cpp @@ -565,6 +565,16 @@ void *JIT::getOrEmitGlobalVariable(const GlobalVariable *GV) { if (GV->isThreadLocal()) { MutexGuard locked(lock); Ptr = TJI.allocateThreadLocalMemory(S); + } else if (TJI.allocateSeparateGVMemory()) { + 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)); + Ptr = (char*)Ptr + (MisAligned ? (A-MisAligned) : 0); + } } else { Ptr = MCE->allocateSpace(S, A); } |
