summaryrefslogtreecommitdiffstats
path: root/llvm/lib/ExecutionEngine/JIT/JIT.cpp
diff options
context:
space:
mode:
authorEvan Cheng <evan.cheng@apple.com>2008-11-04 09:30:48 +0000
committerEvan Cheng <evan.cheng@apple.com>2008-11-04 09:30:48 +0000
commit9340be464163a778890c5f4187e0d313736454de (patch)
tree8e35e0517ece085aa70fff0903a5e440d56aea74 /llvm/lib/ExecutionEngine/JIT/JIT.cpp
parenta6dee4e28ff45576887d87221404446789a22c6b (diff)
downloadbcm5719-llvm-9340be464163a778890c5f4187e0d313736454de.tar.gz
bcm5719-llvm-9340be464163a778890c5f4187e0d313736454de.zip
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. llvm-svn: 58688
Diffstat (limited to 'llvm/lib/ExecutionEngine/JIT/JIT.cpp')
-rw-r--r--llvm/lib/ExecutionEngine/JIT/JIT.cpp10
1 files changed, 10 insertions, 0 deletions
diff --git a/llvm/lib/ExecutionEngine/JIT/JIT.cpp b/llvm/lib/ExecutionEngine/JIT/JIT.cpp
index b768f4d31c2..83923a2b8e3 100644
--- a/llvm/lib/ExecutionEngine/JIT/JIT.cpp
+++ b/llvm/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);
}
OpenPOWER on IntegriCloud