unique_ptrify passing the TargetMachine to ExecutionEngine::MCJITCtor

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@216988 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
David Blaikie
2014-09-02 22:41:07 +00:00
parent 41b6e327f7
commit 4becee113c
4 changed files with 16 additions and 21 deletions

View File

@@ -139,11 +139,10 @@ protected:
/// getMemoryforGV - Allocate memory for a global variable. /// getMemoryforGV - Allocate memory for a global variable.
virtual char *getMemoryForGV(const GlobalVariable *GV); virtual char *getMemoryForGV(const GlobalVariable *GV);
static ExecutionEngine *(*MCJITCtor)( static ExecutionEngine *(*MCJITCtor)(std::unique_ptr<Module> M,
std::unique_ptr<Module> M, std::string *ErrorStr,
std::string *ErrorStr, RTDyldMemoryManager *MCJMM,
RTDyldMemoryManager *MCJMM, std::unique_ptr<TargetMachine> TM);
TargetMachine *TM);
static ExecutionEngine *(*InterpCtor)(std::unique_ptr<Module> M, static ExecutionEngine *(*InterpCtor)(std::unique_ptr<Module> M,
std::string *ErrorStr); std::string *ErrorStr);

View File

@@ -49,10 +49,8 @@ void ObjectBuffer::anchor() {}
void ObjectBufferStream::anchor() {} void ObjectBufferStream::anchor() {}
ExecutionEngine *(*ExecutionEngine::MCJITCtor)( ExecutionEngine *(*ExecutionEngine::MCJITCtor)(
std::unique_ptr<Module >M, std::unique_ptr<Module> M, std::string *ErrorStr,
std::string *ErrorStr, RTDyldMemoryManager *MCJMM, std::unique_ptr<TargetMachine> TM) = nullptr;
RTDyldMemoryManager *MCJMM,
TargetMachine *TM) = nullptr;
ExecutionEngine *(*ExecutionEngine::InterpCtor)(std::unique_ptr<Module> M, ExecutionEngine *(*ExecutionEngine::InterpCtor)(std::unique_ptr<Module> M,
std::string *ErrorStr) =nullptr; std::string *ErrorStr) =nullptr;
@@ -453,7 +451,7 @@ ExecutionEngine *EngineBuilder::create(TargetMachine *TM) {
ExecutionEngine *EE = nullptr; ExecutionEngine *EE = nullptr;
if (ExecutionEngine::MCJITCtor) if (ExecutionEngine::MCJITCtor)
EE = ExecutionEngine::MCJITCtor(std::move(M), ErrorStr, EE = ExecutionEngine::MCJITCtor(std::move(M), ErrorStr,
MCJMM ? MCJMM : JMM, TheTM.release()); MCJMM ? MCJMM : JMM, std::move(TheTM));
if (EE) { if (EE) {
EE->setVerifyModules(VerifyModules); EE->setVerifyModules(VerifyModules);
return EE; return EE;

View File

@@ -46,20 +46,20 @@ extern "C" void LLVMLinkInMCJIT() {
ExecutionEngine *MCJIT::createJIT(std::unique_ptr<Module> M, ExecutionEngine *MCJIT::createJIT(std::unique_ptr<Module> M,
std::string *ErrorStr, std::string *ErrorStr,
RTDyldMemoryManager *MemMgr, RTDyldMemoryManager *MemMgr,
TargetMachine *TM) { std::unique_ptr<TargetMachine> TM) {
// Try to register the program as a source of symbols to resolve against. // Try to register the program as a source of symbols to resolve against.
// //
// FIXME: Don't do this here. // FIXME: Don't do this here.
sys::DynamicLibrary::LoadLibraryPermanently(nullptr, nullptr); sys::DynamicLibrary::LoadLibraryPermanently(nullptr, nullptr);
return new MCJIT(std::move(M), TM, return new MCJIT(std::move(M), std::move(TM),
MemMgr ? MemMgr : new SectionMemoryManager()); MemMgr ? MemMgr : new SectionMemoryManager());
} }
MCJIT::MCJIT(std::unique_ptr<Module> M, TargetMachine *tm, MCJIT::MCJIT(std::unique_ptr<Module> M, std::unique_ptr<TargetMachine> tm,
RTDyldMemoryManager *MM) RTDyldMemoryManager *MM)
: ExecutionEngine(std::move(M)), TM(tm), Ctx(nullptr), MemMgr(this, MM), : ExecutionEngine(std::move(M)), TM(std::move(tm)), Ctx(nullptr),
Dyld(&MemMgr), ObjCache(nullptr) { MemMgr(this, MM), Dyld(&MemMgr), ObjCache(nullptr) {
// FIXME: We are managing our modules, so we do not want the base class // FIXME: We are managing our modules, so we do not want the base class
// ExecutionEngine to manage them as well. To avoid double destruction // ExecutionEngine to manage them as well. To avoid double destruction
// of the first (and only) module added in ExecutionEngine constructor // of the first (and only) module added in ExecutionEngine constructor
@@ -93,8 +93,6 @@ MCJIT::~MCJIT() {
LoadedObjects.clear(); LoadedObjects.clear();
Archives.clear(); Archives.clear();
delete TM;
} }
void MCJIT::addModule(std::unique_ptr<Module> M) { void MCJIT::addModule(std::unique_ptr<Module> M) {

View File

@@ -101,7 +101,7 @@ private:
// called. // called.
class MCJIT : public ExecutionEngine { class MCJIT : public ExecutionEngine {
MCJIT(std::unique_ptr<Module> M, TargetMachine *tm, MCJIT(std::unique_ptr<Module> M, std::unique_ptr<TargetMachine> tm,
RTDyldMemoryManager *MemMgr); RTDyldMemoryManager *MemMgr);
typedef llvm::SmallPtrSet<Module *, 4> ModulePtrSet; typedef llvm::SmallPtrSet<Module *, 4> ModulePtrSet;
@@ -208,7 +208,7 @@ class MCJIT : public ExecutionEngine {
} }
}; };
TargetMachine *TM; std::unique_ptr<TargetMachine> TM;
MCContext *Ctx; MCContext *Ctx;
LinkingMemoryManager MemMgr; LinkingMemoryManager MemMgr;
RuntimeDyld Dyld; RuntimeDyld Dyld;
@@ -311,7 +311,7 @@ public:
uint64_t getGlobalValueAddress(const std::string &Name) override; uint64_t getGlobalValueAddress(const std::string &Name) override;
uint64_t getFunctionAddress(const std::string &Name) override; uint64_t getFunctionAddress(const std::string &Name) override;
TargetMachine *getTargetMachine() override { return TM; } TargetMachine *getTargetMachine() override { return TM.get(); }
/// @} /// @}
/// @name (Private) Registration Interfaces /// @name (Private) Registration Interfaces
@@ -324,7 +324,7 @@ public:
static ExecutionEngine *createJIT(std::unique_ptr<Module> M, static ExecutionEngine *createJIT(std::unique_ptr<Module> M,
std::string *ErrorStr, std::string *ErrorStr,
RTDyldMemoryManager *MemMgr, RTDyldMemoryManager *MemMgr,
TargetMachine *TM); std::unique_ptr<TargetMachine> TM);
// @} // @}