summaryrefslogtreecommitdiffstats
path: root/llvm/lib/ExecutionEngine/MCJIT
diff options
context:
space:
mode:
authorLang Hames <lhames@gmail.com>2016-06-11 05:47:04 +0000
committerLang Hames <lhames@gmail.com>2016-06-11 05:47:04 +0000
commit717eacfcf4b47bb1013a4c316a22a0e45091b1f0 (patch)
treeb71e288d80569fb0572d724dc44670c96d85589f /llvm/lib/ExecutionEngine/MCJIT
parent1256cc818b9227e4ff2b17f60c47e04aa21b6f5b (diff)
downloadbcm5719-llvm-717eacfcf4b47bb1013a4c316a22a0e45091b1f0.tar.gz
bcm5719-llvm-717eacfcf4b47bb1013a4c316a22a0e45091b1f0.zip
[MCJIT] Update MCJIT and get the fibonacci example working again.
MCJIT will now set the DataLayout on a module when it is added to the JIT, rather than waiting until it is codegen'd, and the runFunction method will finalize the module containing the function to be run before running it. The fibonacci example has been updated to include and link against MCJIT. llvm-svn: 272455
Diffstat (limited to 'llvm/lib/ExecutionEngine/MCJIT')
-rw-r--r--llvm/lib/ExecutionEngine/MCJIT/MCJIT.cpp14
1 files changed, 9 insertions, 5 deletions
diff --git a/llvm/lib/ExecutionEngine/MCJIT/MCJIT.cpp b/llvm/lib/ExecutionEngine/MCJIT/MCJIT.cpp
index 55c7ff08d2e..30f18db0a46 100644
--- a/llvm/lib/ExecutionEngine/MCJIT/MCJIT.cpp
+++ b/llvm/lib/ExecutionEngine/MCJIT/MCJIT.cpp
@@ -85,6 +85,9 @@ MCJIT::MCJIT(std::unique_ptr<Module> M, std::unique_ptr<TargetMachine> TM,
std::unique_ptr<Module> First = std::move(Modules[0]);
Modules.clear();
+ if (First->getDataLayout().isDefault())
+ First->setDataLayout(getDataLayout());
+
OwnedModules.addModule(std::move(First));
RegisterJITEventListener(JITEventListener::createGDBRegistrationListener());
}
@@ -103,6 +106,10 @@ MCJIT::~MCJIT() {
void MCJIT::addModule(std::unique_ptr<Module> M) {
MutexGuard locked(lock);
+
+ if (M->getDataLayout().isDefault())
+ M->setDataLayout(getDataLayout());
+
OwnedModules.addModule(std::move(M));
}
@@ -192,11 +199,7 @@ void MCJIT::generateCodeForModule(Module *M) {
if (ObjCache)
ObjectToLoad = ObjCache->getObject(M);
- if (M->getDataLayout().isDefault()) {
- M->setDataLayout(getDataLayout());
- } else {
- assert(M->getDataLayout() == getDataLayout() && "DataLayout Mismatch");
- }
+ assert(M->getDataLayout() == getDataLayout() && "DataLayout Mismatch");
// If the cache did not contain a suitable object, compile the object
if (!ObjectToLoad) {
@@ -490,6 +493,7 @@ GenericValue MCJIT::runFunction(Function *F, ArrayRef<GenericValue> ArgValues) {
assert(F && "Function *F was null at entry to run()");
void *FPtr = getPointerToFunction(F);
+ finalizeModule(F->getParent());
assert(FPtr && "Pointer to fn's code was null after getPointerToFunction");
FunctionType *FTy = F->getFunctionType();
Type *RetTy = FTy->getReturnType();
OpenPOWER on IntegriCloud