summaryrefslogtreecommitdiff
path: root/lib/ExecutionEngine/MCJIT
diff options
context:
space:
mode:
authorLang Hames <lhames@gmail.com>2014-12-03 00:51:19 +0000
committerLang Hames <lhames@gmail.com>2014-12-03 00:51:19 +0000
commit5ab94e7135fe4fabbe9934e344b894de21063d92 (patch)
tree688abd0848ea40f1a3c8352b25aee5a4ca21e722 /lib/ExecutionEngine/MCJIT
parent1dce7b19a06742fe8bf7bf1948a8dfdcb71dd118 (diff)
[MCJIT] Unique-ptrify the RTDyldMemoryManager member of MCJIT. NFC.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@223183 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/ExecutionEngine/MCJIT')
-rw-r--r--lib/ExecutionEngine/MCJIT/MCJIT.cpp13
-rw-r--r--lib/ExecutionEngine/MCJIT/MCJIT.h9
2 files changed, 13 insertions, 9 deletions
diff --git a/lib/ExecutionEngine/MCJIT/MCJIT.cpp b/lib/ExecutionEngine/MCJIT/MCJIT.cpp
index 58cf4e5e6dd..f2d53f5326d 100644
--- a/lib/ExecutionEngine/MCJIT/MCJIT.cpp
+++ b/lib/ExecutionEngine/MCJIT/MCJIT.cpp
@@ -45,21 +45,24 @@ extern "C" void LLVMLinkInMCJIT() {
ExecutionEngine *MCJIT::createJIT(std::unique_ptr<Module> M,
std::string *ErrorStr,
- RTDyldMemoryManager *MemMgr,
+ std::unique_ptr<RTDyldMemoryManager> MemMgr,
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), std::move(TM),
- MemMgr ? MemMgr : new SectionMemoryManager());
+ std::unique_ptr<RTDyldMemoryManager> MM = std::move(MemMgr);
+ if (!MM)
+ MM = std::unique_ptr<SectionMemoryManager>(new SectionMemoryManager());
+
+ return new MCJIT(std::move(M), std::move(TM), std::move(MM));
}
MCJIT::MCJIT(std::unique_ptr<Module> M, std::unique_ptr<TargetMachine> tm,
- RTDyldMemoryManager *MM)
+ std::unique_ptr<RTDyldMemoryManager> MM)
: ExecutionEngine(std::move(M)), TM(std::move(tm)), Ctx(nullptr),
- MemMgr(this, MM), Dyld(&MemMgr), ObjCache(nullptr) {
+ MemMgr(this, std::move(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
diff --git a/lib/ExecutionEngine/MCJIT/MCJIT.h b/lib/ExecutionEngine/MCJIT/MCJIT.h
index 6f92e51b64c..f55dd60ecba 100644
--- a/lib/ExecutionEngine/MCJIT/MCJIT.h
+++ b/lib/ExecutionEngine/MCJIT/MCJIT.h
@@ -28,8 +28,9 @@ class MCJIT;
// to that object.
class LinkingMemoryManager : public RTDyldMemoryManager {
public:
- LinkingMemoryManager(MCJIT *Parent, RTDyldMemoryManager *MM)
- : ParentEngine(Parent), ClientMM(MM) {}
+ LinkingMemoryManager(MCJIT *Parent,
+ std::unique_ptr<RTDyldMemoryManager> MM)
+ : ParentEngine(Parent), ClientMM(std::move(MM)) {}
uint64_t getSymbolAddress(const std::string &Name) override;
@@ -102,7 +103,7 @@ private:
class MCJIT : public ExecutionEngine {
MCJIT(std::unique_ptr<Module> M, std::unique_ptr<TargetMachine> tm,
- RTDyldMemoryManager *MemMgr);
+ std::unique_ptr<RTDyldMemoryManager> MemMgr);
typedef llvm::SmallPtrSet<Module *, 4> ModulePtrSet;
@@ -325,7 +326,7 @@ public:
static ExecutionEngine *createJIT(std::unique_ptr<Module> M,
std::string *ErrorStr,
- RTDyldMemoryManager *MemMgr,
+ std::unique_ptr<RTDyldMemoryManager> MemMgr,
std::unique_ptr<TargetMachine> TM);
// @}