mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-11-23 11:13:28 +01:00
[Orc] Reflect process symbols into the LLI Orc-lazy JIT.
This makes symbol resolution essentially identical between MCJIT and the LLI Orc-lazy JIT. llvm-svn: 233786
This commit is contained in:
parent
e31f623da1
commit
cd2a4f7ef3
@ -9,6 +9,7 @@
|
||||
|
||||
#include "OrcLazyJIT.h"
|
||||
#include "llvm/ExecutionEngine/Orc/OrcTargetSupport.h"
|
||||
#include "llvm/Support/DynamicLibrary.h"
|
||||
|
||||
using namespace llvm;
|
||||
|
||||
@ -29,19 +30,31 @@ OrcLazyJIT::createCallbackManagerBuilder(Triple T) {
|
||||
}
|
||||
|
||||
int llvm::runOrcLazyJIT(std::unique_ptr<Module> M, int ArgC, char* ArgV[]) {
|
||||
// Add the program's symbols into the JIT's search space.
|
||||
if (sys::DynamicLibrary::LoadLibraryPermanently(nullptr)) {
|
||||
errs() << "Error loading program symbols.\n";
|
||||
return 1;
|
||||
}
|
||||
|
||||
// Grab a target machine and try to build a factory function for the
|
||||
// target-specific Orc callback manager.
|
||||
auto TM = std::unique_ptr<TargetMachine>(EngineBuilder().selectTarget());
|
||||
auto &Context = getGlobalContext();
|
||||
auto CallbackMgrBuilder =
|
||||
OrcLazyJIT::createCallbackManagerBuilder(Triple(TM->getTargetTriple()));
|
||||
|
||||
// If we couldn't build the factory function then there must not be a callback
|
||||
// manager for this target. Bail out.
|
||||
if (!CallbackMgrBuilder) {
|
||||
errs() << "No callback manager available for target '"
|
||||
<< TM->getTargetTriple() << "'.\n";
|
||||
return 1;
|
||||
}
|
||||
|
||||
// Everything looks good. Build the JIT.
|
||||
OrcLazyJIT J(std::move(TM), Context, CallbackMgrBuilder);
|
||||
|
||||
// Add the module, look up main and run it.
|
||||
auto MainHandle = J.addModule(std::move(M));
|
||||
auto MainSym = J.findSymbolIn(MainHandle, "main");
|
||||
|
||||
|
@ -21,6 +21,7 @@
|
||||
#include "llvm/ExecutionEngine/Orc/IRCompileLayer.h"
|
||||
#include "llvm/ExecutionEngine/Orc/LazyEmittingLayer.h"
|
||||
#include "llvm/ExecutionEngine/Orc/ObjectLinkingLayer.h"
|
||||
#include "llvm/ExecutionEngine/RTDyldMemoryManager.h"
|
||||
#include "llvm/IR/LLVMContext.h"
|
||||
|
||||
namespace llvm {
|
||||
@ -61,7 +62,13 @@ public:
|
||||
|
||||
std::vector<std::unique_ptr<Module>> S;
|
||||
S.push_back(std::move(M));
|
||||
return CODLayer.addModuleSet(std::move(S));
|
||||
auto FallbackLookup =
|
||||
[](const std::string &Name) {
|
||||
if (auto Addr = RTDyldMemoryManager::getSymbolAddressInProcess(Name))
|
||||
return RuntimeDyld::SymbolInfo(Addr, JITSymbolFlags::Exported);
|
||||
return RuntimeDyld::SymbolInfo(nullptr);
|
||||
};
|
||||
return CODLayer.addModuleSet(std::move(S), std::move(FallbackLookup));
|
||||
}
|
||||
|
||||
orc::JITSymbol findSymbol(const std::string &Name) {
|
||||
|
Loading…
Reference in New Issue
Block a user