X-Git-Url: http://plrg.eecs.uci.edu/git/?p=oota-llvm.git;a=blobdiff_plain;f=examples%2FKaleidoscope%2FOrc%2Flazy_irgen%2Ftoy.cpp;fp=examples%2FKaleidoscope%2FOrc%2Flazy_irgen%2Ftoy.cpp;h=c489a450d79da8a3fb253314218a8c855e04d3d1;hp=19801e12030bbc4c0baffce126ab30a7649ae31b;hb=da62155c112f508b1de986835912917c53fbc073;hpb=8af7cb0001758e7291a133faafd9d413d7e6a5b1 diff --git a/examples/Kaleidoscope/Orc/lazy_irgen/toy.cpp b/examples/Kaleidoscope/Orc/lazy_irgen/toy.cpp index 19801e12030..c489a450d79 100644 --- a/examples/Kaleidoscope/Orc/lazy_irgen/toy.cpp +++ b/examples/Kaleidoscope/Orc/lazy_irgen/toy.cpp @@ -1,6 +1,7 @@ #include "llvm/Analysis/Passes.h" #include "llvm/ExecutionEngine/Orc/CompileUtils.h" #include "llvm/ExecutionEngine/Orc/IRCompileLayer.h" +#include "llvm/ExecutionEngine/Orc/LambdaResolver.h" #include "llvm/ExecutionEngine/Orc/LazyEmittingLayer.h" #include "llvm/ExecutionEngine/Orc/ObjectLinkingLayer.h" #include "llvm/IR/DataLayout.h" @@ -1183,20 +1184,22 @@ public: // We need a memory manager to allocate memory and resolve symbols for this // new module. Create one that resolves symbols by looking back into the // JIT. - auto MM = createLookasideRTDyldMM( - [&](const std::string &Name) { - // First try to find 'Name' within the JIT. - if (auto Symbol = findSymbol(Name)) - return Symbol.getAddress(); - - // If we don't already have a definition of 'Name' then search - // the ASTs. - return searchFunctionASTs(Name); - }, - [](const std::string &S) { return 0; } ); + auto Resolver = createLambdaResolver( + [&](const std::string &Name) { + // First try to find 'Name' within the JIT. + if (auto Symbol = findSymbol(Name)) + return RuntimeDyld::SymbolInfo(Symbol.getAddress(), + Symbol.getFlags()); + + // If we don't already have a definition of 'Name' then search + // the ASTs. + return searchFunctionASTs(Name); + }, + [](const std::string &S) { return nullptr; } ); return LazyEmitLayer.addModuleSet(singletonSet(std::move(M)), - std::move(MM)); + make_unique(), + std::move(Resolver)); } void removeModule(ModuleHandleT H) { LazyEmitLayer.removeModuleSet(H); } @@ -1217,7 +1220,7 @@ private: // This method searches the FunctionDefs map for a definition of 'Name'. If it // finds one it generates a stub for it and returns the address of the stub. - TargetAddress searchFunctionASTs(const std::string &Name) { + RuntimeDyld::SymbolInfo searchFunctionASTs(const std::string &Name) { auto DefI = FunctionDefs.find(Name); if (DefI == FunctionDefs.end()) return 0; @@ -1228,7 +1231,8 @@ private: // IRGen the AST, add it to the JIT, and return the address for it. auto H = addModule(IRGen(Session, *FnAST)); - return findSymbolIn(H, Name).getAddress(); + auto Sym = findSymbolIn(H, Name); + return RuntimeDyld::SymbolInfo(Sym.getAddress(), Sym.getFlags()); } SessionContext &Session;