/// getMemoryforGV - Allocate memory for a global variable.
virtual char *getMemoryForGV(const GlobalVariable *GV);
- static ExecutionEngine *(*MCJITCtor)(
- std::unique_ptr<Module> M,
- std::string *ErrorStr,
- RTDyldMemoryManager *MCJMM,
- TargetMachine *TM);
+ static ExecutionEngine *(*MCJITCtor)(std::unique_ptr<Module> M,
+ std::string *ErrorStr,
+ RTDyldMemoryManager *MCJMM,
+ std::unique_ptr<TargetMachine> TM);
static ExecutionEngine *(*InterpCtor)(std::unique_ptr<Module> M,
std::string *ErrorStr);
void ObjectBufferStream::anchor() {}
ExecutionEngine *(*ExecutionEngine::MCJITCtor)(
- std::unique_ptr<Module >M,
- std::string *ErrorStr,
- RTDyldMemoryManager *MCJMM,
- TargetMachine *TM) = nullptr;
+ std::unique_ptr<Module> M, std::string *ErrorStr,
+ RTDyldMemoryManager *MCJMM, std::unique_ptr<TargetMachine> TM) = nullptr;
ExecutionEngine *(*ExecutionEngine::InterpCtor)(std::unique_ptr<Module> M,
std::string *ErrorStr) =nullptr;
ExecutionEngine *EE = nullptr;
if (ExecutionEngine::MCJITCtor)
EE = ExecutionEngine::MCJITCtor(std::move(M), ErrorStr,
- MCJMM ? MCJMM : JMM, TheTM.release());
+ MCJMM ? MCJMM : JMM, std::move(TheTM));
if (EE) {
EE->setVerifyModules(VerifyModules);
return EE;
ExecutionEngine *MCJIT::createJIT(std::unique_ptr<Module> M,
std::string *ErrorStr,
RTDyldMemoryManager *MemMgr,
- TargetMachine *TM) {
+ std::unique_ptr<TargetMachine> TM) {
// Try to register the program as a source of symbols to resolve against.
//
// FIXME: Don't do this here.
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());
}
-MCJIT::MCJIT(std::unique_ptr<Module> M, TargetMachine *tm,
+MCJIT::MCJIT(std::unique_ptr<Module> M, std::unique_ptr<TargetMachine> tm,
RTDyldMemoryManager *MM)
- : ExecutionEngine(std::move(M)), TM(tm), Ctx(nullptr), MemMgr(this, MM),
- Dyld(&MemMgr), ObjCache(nullptr) {
+ : ExecutionEngine(std::move(M)), TM(std::move(tm)), Ctx(nullptr),
+ MemMgr(this, MM), Dyld(&MemMgr), ObjCache(nullptr) {
// FIXME: We are managing our modules, so we do not want the base class
// ExecutionEngine to manage them as well. To avoid double destruction
// of the first (and only) module added in ExecutionEngine constructor
LoadedObjects.clear();
Archives.clear();
-
- delete TM;
}
void MCJIT::addModule(std::unique_ptr<Module> M) {
// called.
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);
typedef llvm::SmallPtrSet<Module *, 4> ModulePtrSet;
}
};
- TargetMachine *TM;
+ std::unique_ptr<TargetMachine> TM;
MCContext *Ctx;
LinkingMemoryManager MemMgr;
RuntimeDyld Dyld;
uint64_t getGlobalValueAddress(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
static ExecutionEngine *createJIT(std::unique_ptr<Module> M,
std::string *ErrorStr,
RTDyldMemoryManager *MemMgr,
- TargetMachine *TM);
+ std::unique_ptr<TargetMachine> TM);
// @}