llvm.org GIT mirror llvm / df424f7
[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. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@272455 91177308-0d34-0410-b5e6-96231b3b80d8 Lang Hames 4 years ago
3 changed file(s) with 12 addition(s) and 5 deletion(s). Raw diff Collapse all Expand all
22 ExecutionEngine
33 Interpreter
44 MC
5 MCJIT
56 Support
67 nativecodegen
78 )
2626 #include "llvm/IR/Verifier.h"
2727 #include "llvm/ExecutionEngine/ExecutionEngine.h"
2828 #include "llvm/ExecutionEngine/GenericValue.h"
29 #include "llvm/ExecutionEngine/MCJIT.h"
2930 #include "llvm/IR/Argument.h"
3031 #include "llvm/IR/BasicBlock.h"
3132 #include "llvm/IR/Constants.h"
102103 int n = argc > 1 ? atol(argv[1]) : 24;
103104
104105 InitializeNativeTarget();
106 InitializeNativeTargetAsmPrinter();
105107 LLVMContext Context;
106108
107109 // Create some module to put our function into it.
8484 std::unique_ptr First = std::move(Modules[0]);
8585 Modules.clear();
8686
87 if (First->getDataLayout().isDefault())
88 First->setDataLayout(getDataLayout());
89
8790 OwnedModules.addModule(std::move(First));
8891 RegisterJITEventListener(JITEventListener::createGDBRegistrationListener());
8992 }
102105
103106 void MCJIT::addModule(std::unique_ptr M) {
104107 MutexGuard locked(lock);
108
109 if (M->getDataLayout().isDefault())
110 M->setDataLayout(getDataLayout());
111
105112 OwnedModules.addModule(std::move(M));
106113 }
107114
191198 if (ObjCache)
192199 ObjectToLoad = ObjCache->getObject(M);
193200
194 if (M->getDataLayout().isDefault()) {
195 M->setDataLayout(getDataLayout());
196 } else {
197 assert(M->getDataLayout() == getDataLayout() && "DataLayout Mismatch");
198 }
201 assert(M->getDataLayout() == getDataLayout() && "DataLayout Mismatch");
199202
200203 // If the cache did not contain a suitable object, compile the object
201204 if (!ObjectToLoad) {
489492 assert(F && "Function *F was null at entry to run()");
490493
491494 void *FPtr = getPointerToFunction(F);
495 finalizeModule(F->getParent());
492496 assert(FPtr && "Pointer to fn's code was null after getPointerToFunction");
493497 FunctionType *FTy = F->getFunctionType();
494498 Type *RetTy = FTy->getReturnType();