Add an option to allocate JITed global data separately from code. By
default, this option is not enabled to support clients who rely on
this behavior.
Fixes http://llvm.org/PR4483
A patch to allocate additional memory for globals after we run out is
forthcoming.
Patch by Reid Kleckner!
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@75059 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/ExecutionEngine/JIT/JIT.h b/lib/ExecutionEngine/JIT/JIT.h
index 66417a7..c992509 100644
--- a/lib/ExecutionEngine/JIT/JIT.h
+++ b/lib/ExecutionEngine/JIT/JIT.h
@@ -55,10 +55,16 @@
JITCodeEmitter *JCE; // JCE object
std::vector<JITEventListener*> EventListeners;
+ /// AllocateGVsWithCode - Some applications require that global variables and
+ /// code be allocated into the same region of memory, in which case this flag
+ /// should be set to true. Doing so breaks freeMachineCodeForFunction.
+ bool AllocateGVsWithCode;
+
JITState *jitstate;
- JIT(ModuleProvider *MP, TargetMachine &tm, TargetJITInfo &tji,
- JITMemoryManager *JMM, CodeGenOpt::Level OptLevel);
+ JIT(ModuleProvider *MP, TargetMachine &tm, TargetJITInfo &tji,
+ JITMemoryManager *JMM, CodeGenOpt::Level OptLevel,
+ bool AllocateGVsWithCode);
public:
~JIT();
@@ -75,8 +81,9 @@
///
static ExecutionEngine *create(ModuleProvider *MP, std::string *Err,
CodeGenOpt::Level OptLevel =
- CodeGenOpt::Default) {
- return createJIT(MP, Err, 0, OptLevel);
+ CodeGenOpt::Default,
+ bool AllocateGVsWithCode = true) {
+ return createJIT(MP, Err, 0, OptLevel, AllocateGVsWithCode);
}
virtual void addModuleProvider(ModuleProvider *MP);
@@ -151,9 +158,11 @@
/// getCodeEmitter - Return the code emitter this JIT is emitting into.
JITCodeEmitter *getCodeEmitter() const { return JCE; }
- static ExecutionEngine *createJIT(ModuleProvider *MP, std::string *Err,
+ static ExecutionEngine *createJIT(ModuleProvider *MP,
+ std::string *Err,
JITMemoryManager *JMM,
- CodeGenOpt::Level OptLevel);
+ CodeGenOpt::Level OptLevel,
+ bool AllocateGVsWithCode);
// Run the JIT on F and return information about the generated code