mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-07-24 22:24:54 +00:00
SectionMemoryManager shouldn't be a JITMemoryManager. Previously, the
EngineBuilder interface required a JITMemoryManager even if it was being used to construct an MCJIT. But the MCJIT actually wants a RTDyldMemoryManager. Consequently, the SectionMemoryManager, which is meant for MCJIT, derived from the JITMemoryManager and then stubbed out a bunch of JITMemoryManager methods that weren't relevant to the MCJIT. This patch fixes the situation: it teaches the EngineBuilder that RTDyldMemoryManager is a supertype of JITMemoryManager, and that it's appropriate to pass a RTDyldMemoryManager instead of a JITMemoryManager if we're using the MCJIT. This allows us to remove the stub methods from SectionMemoryManager, and make SectionMemoryManager a direct subtype of RTDyldMemoryManager. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@181820 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -14,6 +14,7 @@
|
||||
|
||||
#define DEBUG_TYPE "jit"
|
||||
#include "llvm/ExecutionEngine/ExecutionEngine.h"
|
||||
#include "llvm/ExecutionEngine/JITMemoryManager.h"
|
||||
#include "llvm/ADT/SmallString.h"
|
||||
#include "llvm/ADT/Statistic.h"
|
||||
#include "llvm/ExecutionEngine/GenericValue.h"
|
||||
@@ -47,7 +48,7 @@ ExecutionEngine *(*ExecutionEngine::JITCtor)(
|
||||
ExecutionEngine *(*ExecutionEngine::MCJITCtor)(
|
||||
Module *M,
|
||||
std::string *ErrorStr,
|
||||
JITMemoryManager *JMM,
|
||||
RTDyldMemoryManager *MCJMM,
|
||||
bool GVsWithCode,
|
||||
TargetMachine *TM) = 0;
|
||||
ExecutionEngine *(*ExecutionEngine::InterpCtor)(Module *M,
|
||||
@@ -455,10 +456,12 @@ ExecutionEngine *EngineBuilder::create(TargetMachine *TM) {
|
||||
if (sys::DynamicLibrary::LoadLibraryPermanently(0, ErrorStr))
|
||||
return 0;
|
||||
|
||||
assert(!(JMM && MCJMM));
|
||||
|
||||
// If the user specified a memory manager but didn't specify which engine to
|
||||
// create, we assume they only want the JIT, and we fail if they only want
|
||||
// the interpreter.
|
||||
if (JMM) {
|
||||
if (JMM || MCJMM) {
|
||||
if (WhichEngine & EngineKind::JIT)
|
||||
WhichEngine = EngineKind::JIT;
|
||||
else {
|
||||
@@ -467,6 +470,14 @@ ExecutionEngine *EngineBuilder::create(TargetMachine *TM) {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
if (MCJMM && ! UseMCJIT) {
|
||||
if (ErrorStr)
|
||||
*ErrorStr =
|
||||
"Cannot create a legacy JIT with a runtime dyld memory "
|
||||
"manager.";
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Unless the interpreter was explicitly selected or the JIT is not linked,
|
||||
// try making a JIT.
|
||||
@@ -480,7 +491,7 @@ ExecutionEngine *EngineBuilder::create(TargetMachine *TM) {
|
||||
|
||||
if (UseMCJIT && ExecutionEngine::MCJITCtor) {
|
||||
ExecutionEngine *EE =
|
||||
ExecutionEngine::MCJITCtor(M, ErrorStr, JMM,
|
||||
ExecutionEngine::MCJITCtor(M, ErrorStr, MCJMM ? MCJMM : JMM,
|
||||
AllocateGVsWithCode, TheTM.take());
|
||||
if (EE) return EE;
|
||||
} else if (ExecutionEngine::JITCtor) {
|
||||
|
@@ -39,7 +39,7 @@ extern "C" void LLVMLinkInMCJIT() {
|
||||
|
||||
ExecutionEngine *MCJIT::createJIT(Module *M,
|
||||
std::string *ErrorStr,
|
||||
JITMemoryManager *JMM,
|
||||
RTDyldMemoryManager *MemMgr,
|
||||
bool GVsWithCode,
|
||||
TargetMachine *TM) {
|
||||
// Try to register the program as a source of symbols to resolve against.
|
||||
@@ -47,14 +47,14 @@ ExecutionEngine *MCJIT::createJIT(Module *M,
|
||||
// FIXME: Don't do this here.
|
||||
sys::DynamicLibrary::LoadLibraryPermanently(0, NULL);
|
||||
|
||||
return new MCJIT(M, TM, JMM ? JMM : new SectionMemoryManager(), GVsWithCode);
|
||||
return new MCJIT(M, TM, MemMgr ? MemMgr : new SectionMemoryManager(),
|
||||
GVsWithCode);
|
||||
}
|
||||
|
||||
MCJIT::MCJIT(Module *m, TargetMachine *tm, RTDyldMemoryManager *MM,
|
||||
bool AllocateGVsWithCode)
|
||||
: ExecutionEngine(m), TM(tm), Ctx(0),
|
||||
MemMgr(MM ? MM : new SectionMemoryManager()), Dyld(MemMgr),
|
||||
IsLoaded(false), M(m), ObjCache(0) {
|
||||
: ExecutionEngine(m), TM(tm), Ctx(0), MemMgr(MM), Dyld(MM),
|
||||
IsLoaded(false), M(m), ObjCache(0) {
|
||||
|
||||
setDataLayout(TM->getDataLayout());
|
||||
}
|
||||
|
@@ -98,7 +98,7 @@ public:
|
||||
|
||||
static ExecutionEngine *createJIT(Module *M,
|
||||
std::string *ErrorStr,
|
||||
JITMemoryManager *JMM,
|
||||
RTDyldMemoryManager *MemMgr,
|
||||
bool GVsWithCode,
|
||||
TargetMachine *TM);
|
||||
|
||||
|
Reference in New Issue
Block a user