diff options
author | Lang Hames <lhames@gmail.com> | 2016-08-01 20:49:11 +0000 |
---|---|---|
committer | Lang Hames <lhames@gmail.com> | 2016-08-01 20:49:11 +0000 |
commit | 075c1e2e1aa2a1fc577cb92ab40a260e45929984 (patch) | |
tree | 31fafcd8061d7092ee7d1452d6345df4d021c0ad /examples | |
parent | 9296f21a70e7cd97562d8b3981d436af037731ce (diff) | |
download | llvm-075c1e2e1aa2a1fc577cb92ab40a260e45929984.tar.gz |
[ExecutionEngine][MCJIT][Orc] Replace RuntimeDyld::SymbolInfo with JITSymbol.
This patch replaces RuntimeDyld::SymbolInfo with JITSymbol: A symbol class
that is capable of lazy materialization (i.e. the symbol definition needn't be
emitted until the address is requested). This can be used to support common
and weak symbols in the JIT (though this is not implemented in this patch).
For consistency, RuntimeDyld::SymbolResolver is renamed to JITSymbolResolver.
For space efficiency a new class, JITEvaluatedSymbol, is introduced that
behaves like the old RuntimeDyld::SymbolInfo - i.e. it is just a pair of an
address and symbol flags. Instances of JITEvaluatedSymbol can be used in
symbol-tables to avoid paying the space cost of the materializer.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@277386 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'examples')
6 files changed, 33 insertions, 35 deletions
diff --git a/examples/Kaleidoscope/BuildingAJIT/Chapter1/KaleidoscopeJIT.h b/examples/Kaleidoscope/BuildingAJIT/Chapter1/KaleidoscopeJIT.h index 35c871affec..f750cba5336 100644 --- a/examples/Kaleidoscope/BuildingAJIT/Chapter1/KaleidoscopeJIT.h +++ b/examples/Kaleidoscope/BuildingAJIT/Chapter1/KaleidoscopeJIT.h @@ -16,10 +16,10 @@ #include "llvm/ADT/STLExtras.h" #include "llvm/ExecutionEngine/ExecutionEngine.h" +#include "llvm/ExecutionEngine/JITSymbol.h" #include "llvm/ExecutionEngine/RuntimeDyld.h" #include "llvm/ExecutionEngine/SectionMemoryManager.h" #include "llvm/ExecutionEngine/Orc/CompileUtils.h" -#include "llvm/ExecutionEngine/Orc/JITSymbol.h" #include "llvm/ExecutionEngine/Orc/IRCompileLayer.h" #include "llvm/ExecutionEngine/Orc/LambdaResolver.h" #include "llvm/ExecutionEngine/Orc/ObjectLinkingLayer.h" @@ -62,14 +62,14 @@ public: auto Resolver = createLambdaResolver( [&](const std::string &Name) { if (auto Sym = CompileLayer.findSymbol(Name, false)) - return Sym.toRuntimeDyldSymbol(); - return RuntimeDyld::SymbolInfo(nullptr); + return Sym; + return JITSymbol(nullptr); }, [](const std::string &Name) { if (auto SymAddr = RTDyldMemoryManager::getSymbolAddressInProcess(Name)) - return RuntimeDyld::SymbolInfo(SymAddr, JITSymbolFlags::Exported); - return RuntimeDyld::SymbolInfo(nullptr); + return JITSymbol(SymAddr, JITSymbolFlags::Exported); + return JITSymbol(nullptr); }); // Build a singlton module set to hold our module. diff --git a/examples/Kaleidoscope/BuildingAJIT/Chapter2/KaleidoscopeJIT.h b/examples/Kaleidoscope/BuildingAJIT/Chapter2/KaleidoscopeJIT.h index 30cfed6af95..2b05b117b9a 100644 --- a/examples/Kaleidoscope/BuildingAJIT/Chapter2/KaleidoscopeJIT.h +++ b/examples/Kaleidoscope/BuildingAJIT/Chapter2/KaleidoscopeJIT.h @@ -16,10 +16,10 @@ #include "llvm/ADT/STLExtras.h" #include "llvm/ExecutionEngine/ExecutionEngine.h" +#include "llvm/ExecutionEngine/JITSymbol.h" #include "llvm/ExecutionEngine/RuntimeDyld.h" #include "llvm/ExecutionEngine/SectionMemoryManager.h" #include "llvm/ExecutionEngine/Orc/CompileUtils.h" -#include "llvm/ExecutionEngine/Orc/JITSymbol.h" #include "llvm/ExecutionEngine/Orc/IRCompileLayer.h" #include "llvm/ExecutionEngine/Orc/IRTransformLayer.h" #include "llvm/ExecutionEngine/Orc/LambdaResolver.h" @@ -72,14 +72,14 @@ public: auto Resolver = createLambdaResolver( [&](const std::string &Name) { if (auto Sym = OptimizeLayer.findSymbol(Name, false)) - return Sym.toRuntimeDyldSymbol(); - return RuntimeDyld::SymbolInfo(nullptr); + return Sym; + return JITSymbol(nullptr); }, [](const std::string &Name) { if (auto SymAddr = RTDyldMemoryManager::getSymbolAddressInProcess(Name)) - return RuntimeDyld::SymbolInfo(SymAddr, JITSymbolFlags::Exported); - return RuntimeDyld::SymbolInfo(nullptr); + return JITSymbol(SymAddr, JITSymbolFlags::Exported); + return JITSymbol(nullptr); }); // Build a singlton module set to hold our module. diff --git a/examples/Kaleidoscope/BuildingAJIT/Chapter3/KaleidoscopeJIT.h b/examples/Kaleidoscope/BuildingAJIT/Chapter3/KaleidoscopeJIT.h index 68bdafe9897..58afd9ab158 100644 --- a/examples/Kaleidoscope/BuildingAJIT/Chapter3/KaleidoscopeJIT.h +++ b/examples/Kaleidoscope/BuildingAJIT/Chapter3/KaleidoscopeJIT.h @@ -16,11 +16,11 @@ #include "llvm/ADT/STLExtras.h" #include "llvm/ExecutionEngine/ExecutionEngine.h" +#include "llvm/ExecutionEngine/JITSymbol.h" #include "llvm/ExecutionEngine/RuntimeDyld.h" #include "llvm/ExecutionEngine/SectionMemoryManager.h" #include "llvm/ExecutionEngine/Orc/CompileOnDemandLayer.h" #include "llvm/ExecutionEngine/Orc/CompileUtils.h" -#include "llvm/ExecutionEngine/Orc/JITSymbol.h" #include "llvm/ExecutionEngine/Orc/IRCompileLayer.h" #include "llvm/ExecutionEngine/Orc/IRTransformLayer.h" #include "llvm/ExecutionEngine/Orc/LambdaResolver.h" @@ -83,14 +83,14 @@ public: auto Resolver = createLambdaResolver( [&](const std::string &Name) { if (auto Sym = CODLayer.findSymbol(Name, false)) - return Sym.toRuntimeDyldSymbol(); - return RuntimeDyld::SymbolInfo(nullptr); + return Sym; + return JITSymbol(nullptr); }, [](const std::string &Name) { if (auto SymAddr = RTDyldMemoryManager::getSymbolAddressInProcess(Name)) - return RuntimeDyld::SymbolInfo(SymAddr, JITSymbolFlags::Exported); - return RuntimeDyld::SymbolInfo(nullptr); + return JITSymbol(SymAddr, JITSymbolFlags::Exported); + return JITSymbol(nullptr); }); // Build a singlton module set to hold our module. diff --git a/examples/Kaleidoscope/BuildingAJIT/Chapter4/KaleidoscopeJIT.h b/examples/Kaleidoscope/BuildingAJIT/Chapter4/KaleidoscopeJIT.h index d14c2b1805f..3aed48757bf 100644 --- a/examples/Kaleidoscope/BuildingAJIT/Chapter4/KaleidoscopeJIT.h +++ b/examples/Kaleidoscope/BuildingAJIT/Chapter4/KaleidoscopeJIT.h @@ -16,11 +16,11 @@ #include "llvm/ADT/STLExtras.h" #include "llvm/ExecutionEngine/ExecutionEngine.h" +#include "llvm/ExecutionEngine/JITSymbol.h" #include "llvm/ExecutionEngine/RuntimeDyld.h" #include "llvm/ExecutionEngine/SectionMemoryManager.h" #include "llvm/ExecutionEngine/Orc/CompileOnDemandLayer.h" #include "llvm/ExecutionEngine/Orc/CompileUtils.h" -#include "llvm/ExecutionEngine/Orc/JITSymbol.h" #include "llvm/ExecutionEngine/Orc/IRCompileLayer.h" #include "llvm/ExecutionEngine/Orc/IRTransformLayer.h" #include "llvm/ExecutionEngine/Orc/LambdaResolver.h" @@ -107,16 +107,16 @@ public: auto Resolver = createLambdaResolver( [&](const std::string &Name) { if (auto Sym = IndirectStubsMgr->findStub(Name, false)) - return Sym.toRuntimeDyldSymbol(); + return Sym; if (auto Sym = OptimizeLayer.findSymbol(Name, false)) - return Sym.toRuntimeDyldSymbol(); - return RuntimeDyld::SymbolInfo(nullptr); + return Sym; + return JITSymbol(nullptr); }, [](const std::string &Name) { if (auto SymAddr = RTDyldMemoryManager::getSymbolAddressInProcess(Name)) - return RuntimeDyld::SymbolInfo(SymAddr, JITSymbolFlags::Exported); - return RuntimeDyld::SymbolInfo(nullptr); + return JITSymbol(SymAddr, JITSymbolFlags::Exported); + return JITSymbol(nullptr); }); // Build a singlton module set to hold our module. @@ -173,7 +173,7 @@ public: addModule(std::move(M)); auto Sym = findSymbol(SharedFnAST->getName() + "$impl"); assert(Sym && "Couldn't find compiled function?"); - TargetAddress SymAddr = Sym.getAddress(); + JITTargetAddress SymAddr = Sym.getAddress(); if (auto Err = IndirectStubsMgr->updatePointer(mangle(SharedFnAST->getName()), SymAddr)) { diff --git a/examples/Kaleidoscope/BuildingAJIT/Chapter5/KaleidoscopeJIT.h b/examples/Kaleidoscope/BuildingAJIT/Chapter5/KaleidoscopeJIT.h index 24d6dc9b7b8..0ba785eab9b 100644 --- a/examples/Kaleidoscope/BuildingAJIT/Chapter5/KaleidoscopeJIT.h +++ b/examples/Kaleidoscope/BuildingAJIT/Chapter5/KaleidoscopeJIT.h @@ -17,11 +17,11 @@ #include "RemoteJITUtils.h" #include "llvm/ADT/STLExtras.h" #include "llvm/ExecutionEngine/ExecutionEngine.h" +#include "llvm/ExecutionEngine/JITSymbol.h" #include "llvm/ExecutionEngine/RuntimeDyld.h" #include "llvm/ExecutionEngine/SectionMemoryManager.h" #include "llvm/ExecutionEngine/Orc/CompileOnDemandLayer.h" #include "llvm/ExecutionEngine/Orc/CompileUtils.h" -#include "llvm/ExecutionEngine/Orc/JITSymbol.h" #include "llvm/ExecutionEngine/Orc/IRCompileLayer.h" #include "llvm/ExecutionEngine/Orc/IRTransformLayer.h" #include "llvm/ExecutionEngine/Orc/LambdaResolver.h" @@ -123,21 +123,20 @@ public: auto Resolver = createLambdaResolver( [&](const std::string &Name) { if (auto Sym = IndirectStubsMgr->findStub(Name, false)) - return Sym.toRuntimeDyldSymbol(); + return Sym; if (auto Sym = OptimizeLayer.findSymbol(Name, false)) - return Sym.toRuntimeDyldSymbol(); - return RuntimeDyld::SymbolInfo(nullptr); + return Sym; + return JITSymbol(nullptr); }, [&](const std::string &Name) { if (auto AddrOrErr = Remote.getSymbolAddress(Name)) - return RuntimeDyld::SymbolInfo(*AddrOrErr, - JITSymbolFlags::Exported); + return JITSymbol(*AddrOrErr, JITSymbolFlags::Exported); else { logAllUnhandledErrors(AddrOrErr.takeError(), errs(), "Error resolving remote symbol:"); exit(1); } - return RuntimeDyld::SymbolInfo(nullptr); + return JITSymbol(nullptr); }); std::unique_ptr<MyRemote::RCMemoryManager> MemMgr; @@ -201,7 +200,7 @@ public: addModule(std::move(M)); auto Sym = findSymbol(SharedFnAST->getName() + "$impl"); assert(Sym && "Couldn't find compiled function?"); - TargetAddress SymAddr = Sym.getAddress(); + JITTargetAddress SymAddr = Sym.getAddress(); if (auto Err = IndirectStubsMgr->updatePointer(mangle(SharedFnAST->getName()), SymAddr)) { @@ -216,7 +215,7 @@ public: return Error::success(); } - Error executeRemoteExpr(TargetAddress ExprAddr) { + Error executeRemoteExpr(JITTargetAddress ExprAddr) { return Remote.callVoidVoid(ExprAddr); } diff --git a/examples/Kaleidoscope/include/KaleidoscopeJIT.h b/examples/Kaleidoscope/include/KaleidoscopeJIT.h index 2f492b0e17f..553ba2d15bd 100644 --- a/examples/Kaleidoscope/include/KaleidoscopeJIT.h +++ b/examples/Kaleidoscope/include/KaleidoscopeJIT.h @@ -17,12 +17,11 @@ #include "llvm/ADT/iterator_range.h" #include "llvm/ADT/STLExtras.h" #include "llvm/ExecutionEngine/ExecutionEngine.h" -#include "llvm/ExecutionEngine/JITSymbolFlags.h" +#include "llvm/ExecutionEngine/JITSymbol.h" #include "llvm/ExecutionEngine/RTDyldMemoryManager.h" #include "llvm/ExecutionEngine/RuntimeDyld.h" #include "llvm/ExecutionEngine/SectionMemoryManager.h" #include "llvm/ExecutionEngine/Orc/CompileUtils.h" -#include "llvm/ExecutionEngine/Orc/JITSymbol.h" #include "llvm/ExecutionEngine/Orc/IRCompileLayer.h" #include "llvm/ExecutionEngine/Orc/LambdaResolver.h" #include "llvm/ExecutionEngine/Orc/ObjectLinkingLayer.h" @@ -60,8 +59,8 @@ public: auto Resolver = createLambdaResolver( [&](const std::string &Name) { if (auto Sym = findMangledSymbol(Name)) - return Sym.toRuntimeDyldSymbol(); - return RuntimeDyld::SymbolInfo(nullptr); + return Sym; + return JITSymbol(nullptr); }, [](const std::string &S) { return nullptr; }); auto H = CompileLayer.addModuleSet(singletonSet(std::move(M)), |