summaryrefslogtreecommitdiffstats
path: root/llvm/lib/ExecutionEngine/MCJIT
diff options
context:
space:
mode:
authorMehdi Amini <mehdi.amini@apple.com>2015-07-16 16:34:23 +0000
committerMehdi Amini <mehdi.amini@apple.com>2015-07-16 16:34:23 +0000
commita3fcefb66e8ed3dc45ab05b8e7983e9232606ac0 (patch)
tree4bf2eecbb623e76049d4355c47c35ee29b4c867d /llvm/lib/ExecutionEngine/MCJIT
parentf14af1621942f084a05a772f1e7d06636c0293f3 (diff)
downloadbcm5719-llvm-a3fcefb66e8ed3dc45ab05b8e7983e9232606ac0.tar.gz
bcm5719-llvm-a3fcefb66e8ed3dc45ab05b8e7983e9232606ac0.zip
Make ExecutionEngine owning a DataLayout
Summary: This change is part of a series of commits dedicated to have a single DataLayout during compilation by using always the one owned by the module. The ExecutionEngine will act as an exception and will be unsafe to be reused across context. We don't enforce this rule but undefined behavior can occurs if the user tries to do it. Reviewers: lhames Subscribers: echristo, llvm-commits, rafael, yaron.keren Differential Revision: http://reviews.llvm.org/D11110 From: Mehdi Amini <mehdi.amini@apple.com> llvm-svn: 242414
Diffstat (limited to 'llvm/lib/ExecutionEngine/MCJIT')
-rw-r--r--llvm/lib/ExecutionEngine/MCJIT/MCJIT.cpp18
1 files changed, 11 insertions, 7 deletions
diff --git a/llvm/lib/ExecutionEngine/MCJIT/MCJIT.cpp b/llvm/lib/ExecutionEngine/MCJIT/MCJIT.cpp
index a7d67050c7a..5f4641515ce 100644
--- a/llvm/lib/ExecutionEngine/MCJIT/MCJIT.cpp
+++ b/llvm/lib/ExecutionEngine/MCJIT/MCJIT.cpp
@@ -65,12 +65,13 @@ MCJIT::createJIT(std::unique_ptr<Module> M,
std::move(Resolver));
}
-MCJIT::MCJIT(std::unique_ptr<Module> M, std::unique_ptr<TargetMachine> tm,
+MCJIT::MCJIT(std::unique_ptr<Module> M, std::unique_ptr<TargetMachine> TM,
std::shared_ptr<MCJITMemoryManager> MemMgr,
std::shared_ptr<RuntimeDyld::SymbolResolver> Resolver)
- : ExecutionEngine(std::move(M)), TM(std::move(tm)), Ctx(nullptr),
- MemMgr(std::move(MemMgr)), Resolver(*this, std::move(Resolver)),
- Dyld(*this->MemMgr, this->Resolver), ObjCache(nullptr) {
+ : ExecutionEngine(*TM->getDataLayout(), std::move(M)), TM(std::move(TM)),
+ Ctx(nullptr), MemMgr(std::move(MemMgr)),
+ Resolver(*this, std::move(Resolver)), Dyld(*this->MemMgr, this->Resolver),
+ 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
@@ -85,7 +86,6 @@ MCJIT::MCJIT(std::unique_ptr<Module> M, std::unique_ptr<TargetMachine> tm,
Modules.clear();
OwnedModules.addModule(std::move(First));
- setDataLayout(TM->getDataLayout());
RegisterJITEventListener(JITEventListener::createGDBRegistrationListener());
}
@@ -193,7 +193,11 @@ void MCJIT::generateCodeForModule(Module *M) {
if (ObjCache)
ObjectToLoad = ObjCache->getObject(M);
- M->setDataLayout(*TM->getDataLayout());
+ if (M->getDataLayout().isDefault()) {
+ M->setDataLayout(getDataLayout());
+ } else {
+ assert(M->getDataLayout() == getDataLayout() && "DataLayout Mismatch");
+ }
// If the cache did not contain a suitable object, compile the object
if (!ObjectToLoad) {
@@ -265,7 +269,7 @@ void MCJIT::finalizeModule(Module *M) {
RuntimeDyld::SymbolInfo MCJIT::findExistingSymbol(const std::string &Name) {
SmallString<128> FullName;
- Mangler::getNameWithPrefix(FullName, Name, *TM->getDataLayout());
+ Mangler::getNameWithPrefix(FullName, Name, getDataLayout());
return Dyld.getSymbol(FullName);
}
OpenPOWER on IntegriCloud