1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2025-01-31 12:41:49 +01:00

[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.

llvm-svn: 277386
This commit is contained in:
Lang Hames 2016-08-01 20:49:11 +00:00
parent 6f6fbffa9f
commit 9a3ce89b6d
63 changed files with 511 additions and 506 deletions

View File

@ -190,14 +190,14 @@ available for execution.
auto Resolver = createLambdaResolver( auto Resolver = createLambdaResolver(
[&](const std::string &Name) { [&](const std::string &Name) {
if (auto Sym = CompileLayer.findSymbol(Name, false)) if (auto Sym = CompileLayer.findSymbol(Name, false))
return Sym.toRuntimeDyldSymbol(); return Sym;
return RuntimeDyld::SymbolInfo(nullptr); return JITSymbol(nullptr);
}, },
[](const std::string &S) { [](const std::string &S) {
if (auto SymAddr = if (auto SymAddr =
RTDyldMemoryManager::getSymbolAddressInProcess(Name)) RTDyldMemoryManager::getSymbolAddressInProcess(Name))
return RuntimeDyld::SymbolInfo(SymAddr, JITSymbolFlags::Exported); return JITSymbol(SymAddr, JITSymbolFlags::Exported);
return RuntimeDyld::SymbolInfo(nullptr); return JITSymbol(nullptr);
}); });
// Build a singlton module set to hold our module. // Build a singlton module set to hold our module.
@ -242,28 +242,27 @@ implementation? By using a single symbol resolution scheme we are free to choose
whatever makes the most sense for any given use case. whatever makes the most sense for any given use case.
Building a symbol resolver is made especially easy by the *createLambdaResolver* Building a symbol resolver is made especially easy by the *createLambdaResolver*
function. This function takes two lambdas [3]_ and returns a function. This function takes two lambdas [3]_ and returns a JITSymbolResolver
RuntimeDyld::SymbolResolver instance. The first lambda is used as the instance. The first lambda is used as the implementation of the resolver's
implementation of the resolver's findSymbolInLogicalDylib method, which searches findSymbolInLogicalDylib method, which searches for symbol definitions that
for symbol definitions that should be thought of as being part of the same should be thought of as being part of the same "logical" dynamic library as this
"logical" dynamic library as this Module. If you are familiar with static Module. If you are familiar with static linking: this means that
linking: this means that findSymbolInLogicalDylib should expose symbols with findSymbolInLogicalDylib should expose symbols with common linkage and hidden
common linkage and hidden visibility. If all this sounds foreign you can ignore visibility. If all this sounds foreign you can ignore the details and just
the details and just remember that this is the first method that the linker will remember that this is the first method that the linker will use to try to find a
use to try to find a symbol definition. If the findSymbolInLogicalDylib method symbol definition. If the findSymbolInLogicalDylib method returns a null result
returns a null result then the linker will call the second symbol resolver then the linker will call the second symbol resolver method, called findSymbol,
method, called findSymbol, which searches for symbols that should be thought of which searches for symbols that should be thought of as external to (but
as external to (but visibile from) the module and its logical dylib. In this visibile from) the module and its logical dylib. In this tutorial we will adopt
tutorial we will adopt the following simple scheme: All modules added to the JIT the following simple scheme: All modules added to the JIT will behave as if they
will behave as if they were linked into a single, ever-growing logical dylib. To were linked into a single, ever-growing logical dylib. To implement this our
implement this our first lambda (the one defining findSymbolInLogicalDylib) will first lambda (the one defining findSymbolInLogicalDylib) will just search for
just search for JIT'd code by calling the CompileLayer's findSymbol method. If JIT'd code by calling the CompileLayer's findSymbol method. If we don't find a
we don't find a symbol in the JIT itself we'll fall back to our second lambda, symbol in the JIT itself we'll fall back to our second lambda, which implements
which implements findSymbol. This will use the findSymbol. This will use the RTDyldMemoyrManager::getSymbolAddressInProcess
RTDyldMemoyrManager::getSymbolAddressInProcess method to search for the symbol method to search for the symbol within the program itself. If we can't find a
within the program itself. If we can't find a symbol definition via either of symbol definition via either of these paths the JIT will refuse to accept our
these paths the JIT will refuse to accept our module, returning a "symbol not module, returning a "symbol not found" error.
found" error.
Now that we've built our symbol resolver we're ready to add our module to the Now that we've built our symbol resolver we're ready to add our module to the
JIT. We do this by calling the CompileLayer's addModuleSet method [4]_. Since JIT. We do this by calling the CompileLayer's addModuleSet method [4]_. Since

View File

@ -93,8 +93,8 @@ define below.
auto Resolver = createLambdaResolver( auto Resolver = createLambdaResolver(
[&](const std::string &Name) { [&](const std::string &Name) {
if (auto Sym = OptimizeLayer.findSymbol(Name, false)) if (auto Sym = OptimizeLayer.findSymbol(Name, false))
return Sym.toRuntimeDyldSymbol(); return Sym;
return RuntimeDyld::SymbolInfo(nullptr); return JITSymbol(nullptr);
}, },
// ... // ...

View File

@ -113,10 +113,11 @@ to create the compile callback needed for each function.
Next we have to update our constructor to initialize the new members. To create Next we have to update our constructor to initialize the new members. To create
an appropriate compile callback manager we use the an appropriate compile callback manager we use the
createLocalCompileCallbackManager function, which takes a TargetMachine and a createLocalCompileCallbackManager function, which takes a TargetMachine and a
TargetAddress to call if it receives a request to compile an unknown function. JITTargetAddress to call if it receives a request to compile an unknown
In our simple JIT this situation is unlikely to come up, so we'll cheat and function. In our simple JIT this situation is unlikely to come up, so we'll
just pass '0' here. In a production quality JIT you could give the address of a cheat and just pass '0' here. In a production quality JIT you could give the
function that throws an exception in order to unwind the JIT'd code's stack. address of a function that throws an exception in order to unwind the JIT'd
code's stack.
Now we can construct our CompileOnDemandLayer. Following the pattern from Now we can construct our CompileOnDemandLayer. Following the pattern from
previous layers we start by passing a reference to the next layer down in our previous layers we start by passing a reference to the next layer down in our

View File

@ -16,10 +16,10 @@
#include "llvm/ADT/STLExtras.h" #include "llvm/ADT/STLExtras.h"
#include "llvm/ExecutionEngine/ExecutionEngine.h" #include "llvm/ExecutionEngine/ExecutionEngine.h"
#include "llvm/ExecutionEngine/JITSymbol.h"
#include "llvm/ExecutionEngine/RuntimeDyld.h" #include "llvm/ExecutionEngine/RuntimeDyld.h"
#include "llvm/ExecutionEngine/SectionMemoryManager.h" #include "llvm/ExecutionEngine/SectionMemoryManager.h"
#include "llvm/ExecutionEngine/Orc/CompileUtils.h" #include "llvm/ExecutionEngine/Orc/CompileUtils.h"
#include "llvm/ExecutionEngine/Orc/JITSymbol.h"
#include "llvm/ExecutionEngine/Orc/IRCompileLayer.h" #include "llvm/ExecutionEngine/Orc/IRCompileLayer.h"
#include "llvm/ExecutionEngine/Orc/LambdaResolver.h" #include "llvm/ExecutionEngine/Orc/LambdaResolver.h"
#include "llvm/ExecutionEngine/Orc/ObjectLinkingLayer.h" #include "llvm/ExecutionEngine/Orc/ObjectLinkingLayer.h"
@ -62,14 +62,14 @@ public:
auto Resolver = createLambdaResolver( auto Resolver = createLambdaResolver(
[&](const std::string &Name) { [&](const std::string &Name) {
if (auto Sym = CompileLayer.findSymbol(Name, false)) if (auto Sym = CompileLayer.findSymbol(Name, false))
return Sym.toRuntimeDyldSymbol(); return Sym;
return RuntimeDyld::SymbolInfo(nullptr); return JITSymbol(nullptr);
}, },
[](const std::string &Name) { [](const std::string &Name) {
if (auto SymAddr = if (auto SymAddr =
RTDyldMemoryManager::getSymbolAddressInProcess(Name)) RTDyldMemoryManager::getSymbolAddressInProcess(Name))
return RuntimeDyld::SymbolInfo(SymAddr, JITSymbolFlags::Exported); return JITSymbol(SymAddr, JITSymbolFlags::Exported);
return RuntimeDyld::SymbolInfo(nullptr); return JITSymbol(nullptr);
}); });
// Build a singlton module set to hold our module. // Build a singlton module set to hold our module.

View File

@ -16,10 +16,10 @@
#include "llvm/ADT/STLExtras.h" #include "llvm/ADT/STLExtras.h"
#include "llvm/ExecutionEngine/ExecutionEngine.h" #include "llvm/ExecutionEngine/ExecutionEngine.h"
#include "llvm/ExecutionEngine/JITSymbol.h"
#include "llvm/ExecutionEngine/RuntimeDyld.h" #include "llvm/ExecutionEngine/RuntimeDyld.h"
#include "llvm/ExecutionEngine/SectionMemoryManager.h" #include "llvm/ExecutionEngine/SectionMemoryManager.h"
#include "llvm/ExecutionEngine/Orc/CompileUtils.h" #include "llvm/ExecutionEngine/Orc/CompileUtils.h"
#include "llvm/ExecutionEngine/Orc/JITSymbol.h"
#include "llvm/ExecutionEngine/Orc/IRCompileLayer.h" #include "llvm/ExecutionEngine/Orc/IRCompileLayer.h"
#include "llvm/ExecutionEngine/Orc/IRTransformLayer.h" #include "llvm/ExecutionEngine/Orc/IRTransformLayer.h"
#include "llvm/ExecutionEngine/Orc/LambdaResolver.h" #include "llvm/ExecutionEngine/Orc/LambdaResolver.h"
@ -72,14 +72,14 @@ public:
auto Resolver = createLambdaResolver( auto Resolver = createLambdaResolver(
[&](const std::string &Name) { [&](const std::string &Name) {
if (auto Sym = OptimizeLayer.findSymbol(Name, false)) if (auto Sym = OptimizeLayer.findSymbol(Name, false))
return Sym.toRuntimeDyldSymbol(); return Sym;
return RuntimeDyld::SymbolInfo(nullptr); return JITSymbol(nullptr);
}, },
[](const std::string &Name) { [](const std::string &Name) {
if (auto SymAddr = if (auto SymAddr =
RTDyldMemoryManager::getSymbolAddressInProcess(Name)) RTDyldMemoryManager::getSymbolAddressInProcess(Name))
return RuntimeDyld::SymbolInfo(SymAddr, JITSymbolFlags::Exported); return JITSymbol(SymAddr, JITSymbolFlags::Exported);
return RuntimeDyld::SymbolInfo(nullptr); return JITSymbol(nullptr);
}); });
// Build a singlton module set to hold our module. // Build a singlton module set to hold our module.

View File

@ -16,11 +16,11 @@
#include "llvm/ADT/STLExtras.h" #include "llvm/ADT/STLExtras.h"
#include "llvm/ExecutionEngine/ExecutionEngine.h" #include "llvm/ExecutionEngine/ExecutionEngine.h"
#include "llvm/ExecutionEngine/JITSymbol.h"
#include "llvm/ExecutionEngine/RuntimeDyld.h" #include "llvm/ExecutionEngine/RuntimeDyld.h"
#include "llvm/ExecutionEngine/SectionMemoryManager.h" #include "llvm/ExecutionEngine/SectionMemoryManager.h"
#include "llvm/ExecutionEngine/Orc/CompileOnDemandLayer.h" #include "llvm/ExecutionEngine/Orc/CompileOnDemandLayer.h"
#include "llvm/ExecutionEngine/Orc/CompileUtils.h" #include "llvm/ExecutionEngine/Orc/CompileUtils.h"
#include "llvm/ExecutionEngine/Orc/JITSymbol.h"
#include "llvm/ExecutionEngine/Orc/IRCompileLayer.h" #include "llvm/ExecutionEngine/Orc/IRCompileLayer.h"
#include "llvm/ExecutionEngine/Orc/IRTransformLayer.h" #include "llvm/ExecutionEngine/Orc/IRTransformLayer.h"
#include "llvm/ExecutionEngine/Orc/LambdaResolver.h" #include "llvm/ExecutionEngine/Orc/LambdaResolver.h"
@ -83,14 +83,14 @@ public:
auto Resolver = createLambdaResolver( auto Resolver = createLambdaResolver(
[&](const std::string &Name) { [&](const std::string &Name) {
if (auto Sym = CODLayer.findSymbol(Name, false)) if (auto Sym = CODLayer.findSymbol(Name, false))
return Sym.toRuntimeDyldSymbol(); return Sym;
return RuntimeDyld::SymbolInfo(nullptr); return JITSymbol(nullptr);
}, },
[](const std::string &Name) { [](const std::string &Name) {
if (auto SymAddr = if (auto SymAddr =
RTDyldMemoryManager::getSymbolAddressInProcess(Name)) RTDyldMemoryManager::getSymbolAddressInProcess(Name))
return RuntimeDyld::SymbolInfo(SymAddr, JITSymbolFlags::Exported); return JITSymbol(SymAddr, JITSymbolFlags::Exported);
return RuntimeDyld::SymbolInfo(nullptr); return JITSymbol(nullptr);
}); });
// Build a singlton module set to hold our module. // Build a singlton module set to hold our module.

View File

@ -16,11 +16,11 @@
#include "llvm/ADT/STLExtras.h" #include "llvm/ADT/STLExtras.h"
#include "llvm/ExecutionEngine/ExecutionEngine.h" #include "llvm/ExecutionEngine/ExecutionEngine.h"
#include "llvm/ExecutionEngine/JITSymbol.h"
#include "llvm/ExecutionEngine/RuntimeDyld.h" #include "llvm/ExecutionEngine/RuntimeDyld.h"
#include "llvm/ExecutionEngine/SectionMemoryManager.h" #include "llvm/ExecutionEngine/SectionMemoryManager.h"
#include "llvm/ExecutionEngine/Orc/CompileOnDemandLayer.h" #include "llvm/ExecutionEngine/Orc/CompileOnDemandLayer.h"
#include "llvm/ExecutionEngine/Orc/CompileUtils.h" #include "llvm/ExecutionEngine/Orc/CompileUtils.h"
#include "llvm/ExecutionEngine/Orc/JITSymbol.h"
#include "llvm/ExecutionEngine/Orc/IRCompileLayer.h" #include "llvm/ExecutionEngine/Orc/IRCompileLayer.h"
#include "llvm/ExecutionEngine/Orc/IRTransformLayer.h" #include "llvm/ExecutionEngine/Orc/IRTransformLayer.h"
#include "llvm/ExecutionEngine/Orc/LambdaResolver.h" #include "llvm/ExecutionEngine/Orc/LambdaResolver.h"
@ -107,16 +107,16 @@ public:
auto Resolver = createLambdaResolver( auto Resolver = createLambdaResolver(
[&](const std::string &Name) { [&](const std::string &Name) {
if (auto Sym = IndirectStubsMgr->findStub(Name, false)) if (auto Sym = IndirectStubsMgr->findStub(Name, false))
return Sym.toRuntimeDyldSymbol(); return Sym;
if (auto Sym = OptimizeLayer.findSymbol(Name, false)) if (auto Sym = OptimizeLayer.findSymbol(Name, false))
return Sym.toRuntimeDyldSymbol(); return Sym;
return RuntimeDyld::SymbolInfo(nullptr); return JITSymbol(nullptr);
}, },
[](const std::string &Name) { [](const std::string &Name) {
if (auto SymAddr = if (auto SymAddr =
RTDyldMemoryManager::getSymbolAddressInProcess(Name)) RTDyldMemoryManager::getSymbolAddressInProcess(Name))
return RuntimeDyld::SymbolInfo(SymAddr, JITSymbolFlags::Exported); return JITSymbol(SymAddr, JITSymbolFlags::Exported);
return RuntimeDyld::SymbolInfo(nullptr); return JITSymbol(nullptr);
}); });
// Build a singlton module set to hold our module. // Build a singlton module set to hold our module.
@ -173,7 +173,7 @@ public:
addModule(std::move(M)); addModule(std::move(M));
auto Sym = findSymbol(SharedFnAST->getName() + "$impl"); auto Sym = findSymbol(SharedFnAST->getName() + "$impl");
assert(Sym && "Couldn't find compiled function?"); assert(Sym && "Couldn't find compiled function?");
TargetAddress SymAddr = Sym.getAddress(); JITTargetAddress SymAddr = Sym.getAddress();
if (auto Err = if (auto Err =
IndirectStubsMgr->updatePointer(mangle(SharedFnAST->getName()), IndirectStubsMgr->updatePointer(mangle(SharedFnAST->getName()),
SymAddr)) { SymAddr)) {

View File

@ -17,11 +17,11 @@
#include "RemoteJITUtils.h" #include "RemoteJITUtils.h"
#include "llvm/ADT/STLExtras.h" #include "llvm/ADT/STLExtras.h"
#include "llvm/ExecutionEngine/ExecutionEngine.h" #include "llvm/ExecutionEngine/ExecutionEngine.h"
#include "llvm/ExecutionEngine/JITSymbol.h"
#include "llvm/ExecutionEngine/RuntimeDyld.h" #include "llvm/ExecutionEngine/RuntimeDyld.h"
#include "llvm/ExecutionEngine/SectionMemoryManager.h" #include "llvm/ExecutionEngine/SectionMemoryManager.h"
#include "llvm/ExecutionEngine/Orc/CompileOnDemandLayer.h" #include "llvm/ExecutionEngine/Orc/CompileOnDemandLayer.h"
#include "llvm/ExecutionEngine/Orc/CompileUtils.h" #include "llvm/ExecutionEngine/Orc/CompileUtils.h"
#include "llvm/ExecutionEngine/Orc/JITSymbol.h"
#include "llvm/ExecutionEngine/Orc/IRCompileLayer.h" #include "llvm/ExecutionEngine/Orc/IRCompileLayer.h"
#include "llvm/ExecutionEngine/Orc/IRTransformLayer.h" #include "llvm/ExecutionEngine/Orc/IRTransformLayer.h"
#include "llvm/ExecutionEngine/Orc/LambdaResolver.h" #include "llvm/ExecutionEngine/Orc/LambdaResolver.h"
@ -123,21 +123,20 @@ public:
auto Resolver = createLambdaResolver( auto Resolver = createLambdaResolver(
[&](const std::string &Name) { [&](const std::string &Name) {
if (auto Sym = IndirectStubsMgr->findStub(Name, false)) if (auto Sym = IndirectStubsMgr->findStub(Name, false))
return Sym.toRuntimeDyldSymbol(); return Sym;
if (auto Sym = OptimizeLayer.findSymbol(Name, false)) if (auto Sym = OptimizeLayer.findSymbol(Name, false))
return Sym.toRuntimeDyldSymbol(); return Sym;
return RuntimeDyld::SymbolInfo(nullptr); return JITSymbol(nullptr);
}, },
[&](const std::string &Name) { [&](const std::string &Name) {
if (auto AddrOrErr = Remote.getSymbolAddress(Name)) if (auto AddrOrErr = Remote.getSymbolAddress(Name))
return RuntimeDyld::SymbolInfo(*AddrOrErr, return JITSymbol(*AddrOrErr, JITSymbolFlags::Exported);
JITSymbolFlags::Exported);
else { else {
logAllUnhandledErrors(AddrOrErr.takeError(), errs(), logAllUnhandledErrors(AddrOrErr.takeError(), errs(),
"Error resolving remote symbol:"); "Error resolving remote symbol:");
exit(1); exit(1);
} }
return RuntimeDyld::SymbolInfo(nullptr); return JITSymbol(nullptr);
}); });
std::unique_ptr<MyRemote::RCMemoryManager> MemMgr; std::unique_ptr<MyRemote::RCMemoryManager> MemMgr;
@ -201,7 +200,7 @@ public:
addModule(std::move(M)); addModule(std::move(M));
auto Sym = findSymbol(SharedFnAST->getName() + "$impl"); auto Sym = findSymbol(SharedFnAST->getName() + "$impl");
assert(Sym && "Couldn't find compiled function?"); assert(Sym && "Couldn't find compiled function?");
TargetAddress SymAddr = Sym.getAddress(); JITTargetAddress SymAddr = Sym.getAddress();
if (auto Err = if (auto Err =
IndirectStubsMgr->updatePointer(mangle(SharedFnAST->getName()), IndirectStubsMgr->updatePointer(mangle(SharedFnAST->getName()),
SymAddr)) { SymAddr)) {
@ -216,7 +215,7 @@ public:
return Error::success(); return Error::success();
} }
Error executeRemoteExpr(TargetAddress ExprAddr) { Error executeRemoteExpr(JITTargetAddress ExprAddr) {
return Remote.callVoidVoid(ExprAddr); return Remote.callVoidVoid(ExprAddr);
} }

View File

@ -17,12 +17,11 @@
#include "llvm/ADT/iterator_range.h" #include "llvm/ADT/iterator_range.h"
#include "llvm/ADT/STLExtras.h" #include "llvm/ADT/STLExtras.h"
#include "llvm/ExecutionEngine/ExecutionEngine.h" #include "llvm/ExecutionEngine/ExecutionEngine.h"
#include "llvm/ExecutionEngine/JITSymbolFlags.h" #include "llvm/ExecutionEngine/JITSymbol.h"
#include "llvm/ExecutionEngine/RTDyldMemoryManager.h" #include "llvm/ExecutionEngine/RTDyldMemoryManager.h"
#include "llvm/ExecutionEngine/RuntimeDyld.h" #include "llvm/ExecutionEngine/RuntimeDyld.h"
#include "llvm/ExecutionEngine/SectionMemoryManager.h" #include "llvm/ExecutionEngine/SectionMemoryManager.h"
#include "llvm/ExecutionEngine/Orc/CompileUtils.h" #include "llvm/ExecutionEngine/Orc/CompileUtils.h"
#include "llvm/ExecutionEngine/Orc/JITSymbol.h"
#include "llvm/ExecutionEngine/Orc/IRCompileLayer.h" #include "llvm/ExecutionEngine/Orc/IRCompileLayer.h"
#include "llvm/ExecutionEngine/Orc/LambdaResolver.h" #include "llvm/ExecutionEngine/Orc/LambdaResolver.h"
#include "llvm/ExecutionEngine/Orc/ObjectLinkingLayer.h" #include "llvm/ExecutionEngine/Orc/ObjectLinkingLayer.h"
@ -60,8 +59,8 @@ public:
auto Resolver = createLambdaResolver( auto Resolver = createLambdaResolver(
[&](const std::string &Name) { [&](const std::string &Name) {
if (auto Sym = findMangledSymbol(Name)) if (auto Sym = findMangledSymbol(Name))
return Sym.toRuntimeDyldSymbol(); return Sym;
return RuntimeDyld::SymbolInfo(nullptr); return JITSymbol(nullptr);
}, },
[](const std::string &S) { return nullptr; }); [](const std::string &S) { return nullptr; });
auto H = CompileLayer.addModuleSet(singletonSet(std::move(M)), auto H = CompileLayer.addModuleSet(singletonSet(std::move(M)),

View File

@ -137,13 +137,13 @@ protected:
std::unique_ptr<Module> M, std::unique_ptr<Module> M,
std::string *ErrorStr, std::string *ErrorStr,
std::shared_ptr<MCJITMemoryManager> MM, std::shared_ptr<MCJITMemoryManager> MM,
std::shared_ptr<RuntimeDyld::SymbolResolver> SR, std::shared_ptr<JITSymbolResolver> SR,
std::unique_ptr<TargetMachine> TM); std::unique_ptr<TargetMachine> TM);
static ExecutionEngine *(*OrcMCJITReplacementCtor)( static ExecutionEngine *(*OrcMCJITReplacementCtor)(
std::string *ErrorStr, std::string *ErrorStr,
std::shared_ptr<MCJITMemoryManager> MM, std::shared_ptr<MCJITMemoryManager> MM,
std::shared_ptr<RuntimeDyld::SymbolResolver> SR, std::shared_ptr<JITSymbolResolver> SR,
std::unique_ptr<TargetMachine> TM); std::unique_ptr<TargetMachine> TM);
static ExecutionEngine *(*InterpCtor)(std::unique_ptr<Module> M, static ExecutionEngine *(*InterpCtor)(std::unique_ptr<Module> M,
@ -516,7 +516,7 @@ private:
std::string *ErrorStr; std::string *ErrorStr;
CodeGenOpt::Level OptLevel; CodeGenOpt::Level OptLevel;
std::shared_ptr<MCJITMemoryManager> MemMgr; std::shared_ptr<MCJITMemoryManager> MemMgr;
std::shared_ptr<RuntimeDyld::SymbolResolver> Resolver; std::shared_ptr<JITSymbolResolver> Resolver;
TargetOptions Options; TargetOptions Options;
Optional<Reloc::Model> RelocModel; Optional<Reloc::Model> RelocModel;
CodeModel::Model CMModel; CodeModel::Model CMModel;
@ -555,7 +555,7 @@ public:
setMemoryManager(std::unique_ptr<MCJITMemoryManager> MM); setMemoryManager(std::unique_ptr<MCJITMemoryManager> MM);
EngineBuilder& EngineBuilder&
setSymbolResolver(std::unique_ptr<RuntimeDyld::SymbolResolver> SR); setSymbolResolver(std::unique_ptr<JITSymbolResolver> SR);
/// setErrorStr - Set the error string to write to on error. This option /// setErrorStr - Set the error string to write to on error. This option
/// defaults to NULL. /// defaults to NULL.

View File

@ -0,0 +1,132 @@
//===----------- JITSymbol.h - JIT symbol abstraction -----------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
//
// Abstraction for target process addresses.
//
//===----------------------------------------------------------------------===//
#ifndef LLVM_EXECUTIONENGINE_JITSYMBOL_H
#define LLVM_EXECUTIONENGINE_JITSYMBOL_H
#include "llvm/ExecutionEngine/JITSymbolFlags.h"
#include "llvm/Support/DataTypes.h"
#include <cassert>
#include <functional>
namespace llvm {
/// @brief Represents an address in the target process's address space.
typedef uint64_t JITTargetAddress;
/// @brief Represents a symbol that has been evaluated to an address already.
class JITEvaluatedSymbol : public JITSymbolBase {
public:
/// @brief Create a 'null' symbol.
JITEvaluatedSymbol(std::nullptr_t)
: JITSymbolBase(JITSymbolFlags::None), Address(0) {}
/// @brief Create a symbol for the given address and flags.
JITEvaluatedSymbol(JITTargetAddress Address, JITSymbolFlags Flags)
: JITSymbolBase(Flags), Address(Address) {}
/// @brief An evaluated symbol converts to 'true' if its address is non-zero.
explicit operator bool() const { return Address != 0; }
/// @brief Return the address of this symbol.
JITTargetAddress getAddress() const { return Address; }
private:
JITTargetAddress Address;
};
/// @brief Represents a symbol in the JIT.
class JITSymbol : public JITSymbolBase {
public:
typedef std::function<JITTargetAddress()> GetAddressFtor;
/// @brief Create a 'null' symbol that represents failure to find a symbol
/// definition.
JITSymbol(std::nullptr_t)
: JITSymbolBase(JITSymbolFlags::None), CachedAddr(0) {}
/// @brief Create a symbol for a definition with a known address.
JITSymbol(JITTargetAddress Addr, JITSymbolFlags Flags)
: JITSymbolBase(Flags), CachedAddr(Addr) {}
/// @brief Construct a JITSymbol from a JITEvaluatedSymbol.
JITSymbol(JITEvaluatedSymbol Sym)
: JITSymbolBase(Sym.getFlags()), CachedAddr(Sym.getAddress()) {}
/// @brief Create a symbol for a definition that doesn't have a known address
/// yet.
/// @param GetAddress A functor to materialize a definition (fixing the
/// address) on demand.
///
/// This constructor allows a JIT layer to provide a reference to a symbol
/// definition without actually materializing the definition up front. The
/// user can materialize the definition at any time by calling the getAddress
/// method.
JITSymbol(GetAddressFtor GetAddress, JITSymbolFlags Flags)
: JITSymbolBase(Flags), GetAddress(std::move(GetAddress)), CachedAddr(0) {}
/// @brief Returns true if the symbol exists, false otherwise.
explicit operator bool() const { return CachedAddr || GetAddress; }
/// @brief Get the address of the symbol in the target address space. Returns
/// '0' if the symbol does not exist.
JITTargetAddress getAddress() {
if (GetAddress) {
CachedAddr = GetAddress();
assert(CachedAddr && "Symbol could not be materialized.");
GetAddress = nullptr;
}
return CachedAddr;
}
private:
GetAddressFtor GetAddress;
JITTargetAddress CachedAddr;
};
/// \brief Symbol resolution.
class JITSymbolResolver {
public:
virtual ~JITSymbolResolver() {}
/// This method returns the address of the specified symbol if it exists
/// within the logical dynamic library represented by this JITSymbolResolver.
/// Unlike findSymbol, queries through this interface should return addresses
/// for hidden symbols.
///
/// This is of particular importance for the Orc JIT APIs, which support lazy
/// compilation by breaking up modules: Each of those broken out modules
/// must be able to resolve hidden symbols provided by the others. Clients
/// writing memory managers for MCJIT can usually ignore this method.
///
/// This method will be queried by RuntimeDyld when checking for previous
/// definitions of common symbols.
virtual JITSymbol findSymbolInLogicalDylib(const std::string &Name) = 0;
/// This method returns the address of the specified function or variable.
/// It is used to resolve symbols during module linking.
///
/// If the returned symbol's address is equal to ~0ULL then RuntimeDyld will
/// skip all relocations for that symbol, and the client will be responsible
/// for handling them manually.
virtual JITSymbol findSymbol(const std::string &Name) = 0;
private:
virtual void anchor();
};
} // End namespace llvm.
#endif // LLVM_EXECUTIONENGINE_JITSYMBOL_H

View File

@ -120,13 +120,12 @@ private:
}; };
struct LogicalDylibResources { struct LogicalDylibResources {
typedef std::function<RuntimeDyld::SymbolInfo(const std::string&)> typedef std::function<JITSymbol(const std::string&)> SymbolResolverFtor;
SymbolResolverFtor;
typedef std::function<typename BaseLayerT::ModuleSetHandleT( typedef std::function<typename BaseLayerT::ModuleSetHandleT(
BaseLayerT&, BaseLayerT&,
std::unique_ptr<Module>, std::unique_ptr<Module>,
std::unique_ptr<RuntimeDyld::SymbolResolver>)> std::unique_ptr<JITSymbolResolver>)>
ModuleAdderFtor; ModuleAdderFtor;
LogicalDylibResources() = default; LogicalDylibResources() = default;
@ -145,7 +144,7 @@ private:
return *this; return *this;
} }
std::unique_ptr<RuntimeDyld::SymbolResolver> ExternalSymbolResolver; std::unique_ptr<JITSymbolResolver> ExternalSymbolResolver;
std::unique_ptr<ResourceOwner<RuntimeDyld::MemoryManager>> MemMgr; std::unique_ptr<ResourceOwner<RuntimeDyld::MemoryManager>> MemMgr;
ModuleAdderFtor ModuleAdder; ModuleAdderFtor ModuleAdder;
}; };
@ -196,7 +195,7 @@ public:
LDResources.ModuleAdder = LDResources.ModuleAdder =
[&MemMgrRef](BaseLayerT &B, std::unique_ptr<Module> M, [&MemMgrRef](BaseLayerT &B, std::unique_ptr<Module> M,
std::unique_ptr<RuntimeDyld::SymbolResolver> R) { std::unique_ptr<JITSymbolResolver> R) {
std::vector<std::unique_ptr<Module>> Ms; std::vector<std::unique_ptr<Module>> Ms;
Ms.push_back(std::move(M)); Ms.push_back(std::move(M));
return B.addModuleSet(std::move(Ms), &MemMgrRef, std::move(R)); return B.addModuleSet(std::move(Ms), &MemMgrRef, std::move(R));
@ -245,7 +244,7 @@ public:
// callbacks, uncompiled IR, and no-longer-needed/reachable function // callbacks, uncompiled IR, and no-longer-needed/reachable function
// implementations). // implementations).
// FIXME: Return Error once the JIT APIs are Errorized. // FIXME: Return Error once the JIT APIs are Errorized.
bool updatePointer(std::string FuncName, TargetAddress FnBodyAddr) { bool updatePointer(std::string FuncName, JITTargetAddress FnBodyAddr) {
//Find out which logical dylib contains our symbol //Find out which logical dylib contains our symbol
auto LDI = LogicalDylibs.begin(); auto LDI = LogicalDylibs.begin();
for (auto LDE = LogicalDylibs.end(); LDI != LDE; ++LDI) { for (auto LDE = LogicalDylibs.end(); LDI != LDE; ++LDI) {
@ -386,7 +385,7 @@ private:
[&LD, LMH](const std::string &Name) { [&LD, LMH](const std::string &Name) {
auto &LMResources = LD.getLogicalModuleResources(LMH); auto &LMResources = LD.getLogicalModuleResources(LMH);
if (auto Sym = LMResources.StubsMgr->findStub(Name, false)) if (auto Sym = LMResources.StubsMgr->findStub(Name, false))
return Sym.toRuntimeDyldSymbol(); return Sym;
auto &LDResolver = LD.getDylibResources().ExternalSymbolResolver; auto &LDResolver = LD.getDylibResources().ExternalSymbolResolver;
return LDResolver->findSymbolInLogicalDylib(Name); return LDResolver->findSymbolInLogicalDylib(Name);
}, },
@ -409,9 +408,9 @@ private:
return MangledName; return MangledName;
} }
TargetAddress extractAndCompile(CODLogicalDylib &LD, JITTargetAddress extractAndCompile(CODLogicalDylib &LD,
LogicalModuleHandle LMH, LogicalModuleHandle LMH,
Function &F) { Function &F) {
auto &LMResources = LD.getLogicalModuleResources(LMH); auto &LMResources = LD.getLogicalModuleResources(LMH);
Module &SrcM = LMResources.SourceModule->getResource(); Module &SrcM = LMResources.SourceModule->getResource();
@ -425,13 +424,13 @@ private:
auto Part = Partition(F); auto Part = Partition(F);
auto PartH = emitPartition(LD, LMH, Part); auto PartH = emitPartition(LD, LMH, Part);
TargetAddress CalledAddr = 0; JITTargetAddress CalledAddr = 0;
for (auto *SubF : Part) { for (auto *SubF : Part) {
std::string FnName = mangle(SubF->getName(), SrcM.getDataLayout()); std::string FnName = mangle(SubF->getName(), SrcM.getDataLayout());
auto FnBodySym = BaseLayer.findSymbolIn(PartH, FnName, false); auto FnBodySym = BaseLayer.findSymbolIn(PartH, FnName, false);
assert(FnBodySym && "Couldn't find function body."); assert(FnBodySym && "Couldn't find function body.");
TargetAddress FnBodyAddr = FnBodySym.getAddress(); JITTargetAddress FnBodyAddr = FnBodySym.getAddress();
// If this is the function we're calling record the address so we can // If this is the function we're calling record the address so we can
// return it from this function. // return it from this function.
@ -513,7 +512,7 @@ private:
auto Resolver = createLambdaResolver( auto Resolver = createLambdaResolver(
[this, &LD, LMH](const std::string &Name) { [this, &LD, LMH](const std::string &Name) {
if (auto Sym = LD.findSymbolInternally(LMH, Name)) if (auto Sym = LD.findSymbolInternally(LMH, Name))
return Sym.toRuntimeDyldSymbol(); return Sym;
auto &LDResolver = LD.getDylibResources().ExternalSymbolResolver; auto &LDResolver = LD.getDylibResources().ExternalSymbolResolver;
return LDResolver->findSymbolInLogicalDylib(Name); return LDResolver->findSymbolInLogicalDylib(Name);
}, },

View File

@ -14,9 +14,9 @@
#ifndef LLVM_EXECUTIONENGINE_ORC_EXECUTIONUTILS_H #ifndef LLVM_EXECUTIONENGINE_ORC_EXECUTIONUTILS_H
#define LLVM_EXECUTIONENGINE_ORC_EXECUTIONUTILS_H #define LLVM_EXECUTIONENGINE_ORC_EXECUTIONUTILS_H
#include "JITSymbol.h"
#include "llvm/ADT/iterator_range.h" #include "llvm/ADT/iterator_range.h"
#include "llvm/ADT/StringMap.h" #include "llvm/ADT/StringMap.h"
#include "llvm/ExecutionEngine/JITSymbol.h"
#include "llvm/ExecutionEngine/RuntimeDyld.h" #include "llvm/ExecutionEngine/RuntimeDyld.h"
#include <vector> #include <vector>
@ -144,10 +144,10 @@ public:
} }
/// Search overrided symbols. /// Search overrided symbols.
RuntimeDyld::SymbolInfo searchOverrides(const std::string &Name) { JITEvaluatedSymbol searchOverrides(const std::string &Name) {
auto I = CXXRuntimeOverrides.find(Name); auto I = CXXRuntimeOverrides.find(Name);
if (I != CXXRuntimeOverrides.end()) if (I != CXXRuntimeOverrides.end())
return RuntimeDyld::SymbolInfo(I->second, JITSymbolFlags::Exported); return JITEvaluatedSymbol(I->second, JITSymbolFlags::Exported);
return nullptr; return nullptr;
} }
@ -158,15 +158,15 @@ public:
private: private:
template <typename PtrTy> template <typename PtrTy>
TargetAddress toTargetAddress(PtrTy* P) { JITTargetAddress toTargetAddress(PtrTy* P) {
return static_cast<TargetAddress>(reinterpret_cast<uintptr_t>(P)); return static_cast<JITTargetAddress>(reinterpret_cast<uintptr_t>(P));
} }
void addOverride(const std::string &Name, TargetAddress Addr) { void addOverride(const std::string &Name, JITTargetAddress Addr) {
CXXRuntimeOverrides.insert(std::make_pair(Name, Addr)); CXXRuntimeOverrides.insert(std::make_pair(Name, Addr));
} }
StringMap<TargetAddress> CXXRuntimeOverrides; StringMap<JITTargetAddress> CXXRuntimeOverrides;
typedef void (*DestructorPtr)(void*); typedef void (*DestructorPtr)(void*);
typedef std::pair<DestructorPtr, void*> CXXDestructorDataPair; typedef std::pair<DestructorPtr, void*> CXXDestructorDataPair;

View File

@ -15,7 +15,7 @@
#ifndef LLVM_EXECUTIONENGINE_ORC_GLOBALMAPPINGLAYER_H #ifndef LLVM_EXECUTIONENGINE_ORC_GLOBALMAPPINGLAYER_H
#define LLVM_EXECUTIONENGINE_ORC_GLOBALMAPPINGLAYER_H #define LLVM_EXECUTIONENGINE_ORC_GLOBALMAPPINGLAYER_H
#include "JITSymbol.h" #include "llvm/ExecutionEngine/JITSymbol.h"
#include <map> #include <map>
namespace llvm { namespace llvm {
@ -52,7 +52,7 @@ public:
void removeModuleSet(ModuleSetHandleT H) { BaseLayer.removeModuleSet(H); } void removeModuleSet(ModuleSetHandleT H) { BaseLayer.removeModuleSet(H); }
/// @brief Manually set the address to return for the given symbol. /// @brief Manually set the address to return for the given symbol.
void setGlobalMapping(const std::string &Name, TargetAddress Addr) { void setGlobalMapping(const std::string &Name, JITTargetAddress Addr) {
SymbolTable[Name] = Addr; SymbolTable[Name] = Addr;
} }
@ -99,7 +99,7 @@ public:
private: private:
BaseLayerT &BaseLayer; BaseLayerT &BaseLayer;
std::map<std::string, TargetAddress> SymbolTable; std::map<std::string, JITTargetAddress> SymbolTable;
}; };
} // End namespace orc. } // End namespace orc.

View File

@ -14,9 +14,8 @@
#ifndef LLVM_EXECUTIONENGINE_ORC_IRCOMPILELAYER_H #ifndef LLVM_EXECUTIONENGINE_ORC_IRCOMPILELAYER_H
#define LLVM_EXECUTIONENGINE_ORC_IRCOMPILELAYER_H #define LLVM_EXECUTIONENGINE_ORC_IRCOMPILELAYER_H
#include "JITSymbol.h"
#include "llvm/ExecutionEngine/ObjectCache.h" #include "llvm/ExecutionEngine/ObjectCache.h"
#include "llvm/ExecutionEngine/RTDyldMemoryManager.h" #include "llvm/ExecutionEngine/JITSymbol.h"
#include "llvm/Object/ObjectFile.h" #include "llvm/Object/ObjectFile.h"
#include <memory> #include <memory>

View File

@ -14,7 +14,7 @@
#ifndef LLVM_EXECUTIONENGINE_ORC_IRTRANSFORMLAYER_H #ifndef LLVM_EXECUTIONENGINE_ORC_IRTRANSFORMLAYER_H
#define LLVM_EXECUTIONENGINE_ORC_IRTRANSFORMLAYER_H #define LLVM_EXECUTIONENGINE_ORC_IRTRANSFORMLAYER_H
#include "JITSymbol.h" #include "llvm/ExecutionEngine/JITSymbol.h"
namespace llvm { namespace llvm {
namespace orc { namespace orc {

View File

@ -14,8 +14,8 @@
#ifndef LLVM_EXECUTIONENGINE_ORC_INDIRECTIONUTILS_H #ifndef LLVM_EXECUTIONENGINE_ORC_INDIRECTIONUTILS_H
#define LLVM_EXECUTIONENGINE_ORC_INDIRECTIONUTILS_H #define LLVM_EXECUTIONENGINE_ORC_INDIRECTIONUTILS_H
#include "JITSymbol.h"
#include "LambdaResolver.h" #include "LambdaResolver.h"
#include "llvm/ExecutionEngine/JITSymbol.h"
#include "llvm/ExecutionEngine/RuntimeDyld.h" #include "llvm/ExecutionEngine/RuntimeDyld.h"
#include "llvm/IR/IRBuilder.h" #include "llvm/IR/IRBuilder.h"
#include "llvm/IR/Mangler.h" #include "llvm/IR/Mangler.h"
@ -29,37 +29,37 @@ namespace orc {
/// @brief Target-independent base class for compile callback management. /// @brief Target-independent base class for compile callback management.
class JITCompileCallbackManager { class JITCompileCallbackManager {
public: public:
typedef std::function<TargetAddress()> CompileFtor; typedef std::function<JITTargetAddress()> CompileFtor;
/// @brief Handle to a newly created compile callback. Can be used to get an /// @brief Handle to a newly created compile callback. Can be used to get an
/// IR constant representing the address of the trampoline, and to set /// IR constant representing the address of the trampoline, and to set
/// the compile action for the callback. /// the compile action for the callback.
class CompileCallbackInfo { class CompileCallbackInfo {
public: public:
CompileCallbackInfo(TargetAddress Addr, CompileFtor &Compile) CompileCallbackInfo(JITTargetAddress Addr, CompileFtor &Compile)
: Addr(Addr), Compile(Compile) {} : Addr(Addr), Compile(Compile) {}
TargetAddress getAddress() const { return Addr; } JITTargetAddress getAddress() const { return Addr; }
void setCompileAction(CompileFtor Compile) { void setCompileAction(CompileFtor Compile) {
this->Compile = std::move(Compile); this->Compile = std::move(Compile);
} }
private: private:
TargetAddress Addr; JITTargetAddress Addr;
CompileFtor &Compile; CompileFtor &Compile;
}; };
/// @brief Construct a JITCompileCallbackManager. /// @brief Construct a JITCompileCallbackManager.
/// @param ErrorHandlerAddress The address of an error handler in the target /// @param ErrorHandlerAddress The address of an error handler in the target
/// process to be used if a compile callback fails. /// process to be used if a compile callback fails.
JITCompileCallbackManager(TargetAddress ErrorHandlerAddress) JITCompileCallbackManager(JITTargetAddress ErrorHandlerAddress)
: ErrorHandlerAddress(ErrorHandlerAddress) {} : ErrorHandlerAddress(ErrorHandlerAddress) {}
virtual ~JITCompileCallbackManager() {} virtual ~JITCompileCallbackManager() {}
/// @brief Execute the callback for the given trampoline id. Called by the JIT /// @brief Execute the callback for the given trampoline id. Called by the JIT
/// to compile functions on demand. /// to compile functions on demand.
TargetAddress executeCompileCallback(TargetAddress TrampolineAddr) { JITTargetAddress executeCompileCallback(JITTargetAddress TrampolineAddr) {
auto I = ActiveTrampolines.find(TrampolineAddr); auto I = ActiveTrampolines.find(TrampolineAddr);
// FIXME: Also raise an error in the Orc error-handler when we finally have // FIXME: Also raise an error in the Orc error-handler when we finally have
// one. // one.
@ -86,13 +86,13 @@ public:
/// @brief Reserve a compile callback. /// @brief Reserve a compile callback.
CompileCallbackInfo getCompileCallback() { CompileCallbackInfo getCompileCallback() {
TargetAddress TrampolineAddr = getAvailableTrampolineAddr(); JITTargetAddress TrampolineAddr = getAvailableTrampolineAddr();
auto &Compile = this->ActiveTrampolines[TrampolineAddr]; auto &Compile = this->ActiveTrampolines[TrampolineAddr];
return CompileCallbackInfo(TrampolineAddr, Compile); return CompileCallbackInfo(TrampolineAddr, Compile);
} }
/// @brief Get a CompileCallbackInfo for an existing callback. /// @brief Get a CompileCallbackInfo for an existing callback.
CompileCallbackInfo getCompileCallbackInfo(TargetAddress TrampolineAddr) { CompileCallbackInfo getCompileCallbackInfo(JITTargetAddress TrampolineAddr) {
auto I = ActiveTrampolines.find(TrampolineAddr); auto I = ActiveTrampolines.find(TrampolineAddr);
assert(I != ActiveTrampolines.end() && "Not an active trampoline."); assert(I != ActiveTrampolines.end() && "Not an active trampoline.");
return CompileCallbackInfo(I->first, I->second); return CompileCallbackInfo(I->first, I->second);
@ -103,7 +103,7 @@ public:
/// Note: Callbacks are auto-released after they execute. This method should /// Note: Callbacks are auto-released after they execute. This method should
/// only be called to manually release a callback that is not going to /// only be called to manually release a callback that is not going to
/// execute. /// execute.
void releaseCompileCallback(TargetAddress TrampolineAddr) { void releaseCompileCallback(JITTargetAddress TrampolineAddr) {
auto I = ActiveTrampolines.find(TrampolineAddr); auto I = ActiveTrampolines.find(TrampolineAddr);
assert(I != ActiveTrampolines.end() && "Not an active trampoline."); assert(I != ActiveTrampolines.end() && "Not an active trampoline.");
ActiveTrampolines.erase(I); ActiveTrampolines.erase(I);
@ -111,19 +111,19 @@ public:
} }
protected: protected:
TargetAddress ErrorHandlerAddress; JITTargetAddress ErrorHandlerAddress;
typedef std::map<TargetAddress, CompileFtor> TrampolineMapT; typedef std::map<JITTargetAddress, CompileFtor> TrampolineMapT;
TrampolineMapT ActiveTrampolines; TrampolineMapT ActiveTrampolines;
std::vector<TargetAddress> AvailableTrampolines; std::vector<JITTargetAddress> AvailableTrampolines;
private: private:
TargetAddress getAvailableTrampolineAddr() { JITTargetAddress getAvailableTrampolineAddr() {
if (this->AvailableTrampolines.empty()) if (this->AvailableTrampolines.empty())
grow(); grow();
assert(!this->AvailableTrampolines.empty() && assert(!this->AvailableTrampolines.empty() &&
"Failed to grow available trampolines."); "Failed to grow available trampolines.");
TargetAddress TrampolineAddr = this->AvailableTrampolines.back(); JITTargetAddress TrampolineAddr = this->AvailableTrampolines.back();
this->AvailableTrampolines.pop_back(); this->AvailableTrampolines.pop_back();
return TrampolineAddr; return TrampolineAddr;
} }
@ -141,7 +141,7 @@ public:
/// @brief Construct a InProcessJITCompileCallbackManager. /// @brief Construct a InProcessJITCompileCallbackManager.
/// @param ErrorHandlerAddress The address of an error handler in the target /// @param ErrorHandlerAddress The address of an error handler in the target
/// process to be used if a compile callback fails. /// process to be used if a compile callback fails.
LocalJITCompileCallbackManager(TargetAddress ErrorHandlerAddress) LocalJITCompileCallbackManager(JITTargetAddress ErrorHandlerAddress)
: JITCompileCallbackManager(ErrorHandlerAddress) { : JITCompileCallbackManager(ErrorHandlerAddress) {
/// Set up the resolver block. /// Set up the resolver block.
@ -161,11 +161,12 @@ public:
} }
private: private:
static TargetAddress reenter(void *CCMgr, void *TrampolineId) { static JITTargetAddress reenter(void *CCMgr, void *TrampolineId) {
JITCompileCallbackManager *Mgr = JITCompileCallbackManager *Mgr =
static_cast<JITCompileCallbackManager *>(CCMgr); static_cast<JITCompileCallbackManager *>(CCMgr);
return Mgr->executeCompileCallback( return Mgr->executeCompileCallback(
static_cast<TargetAddress>(reinterpret_cast<uintptr_t>(TrampolineId))); static_cast<JITTargetAddress>(
reinterpret_cast<uintptr_t>(TrampolineId)));
} }
void grow() override { void grow() override {
@ -188,7 +189,7 @@ private:
for (unsigned I = 0; I < NumTrampolines; ++I) for (unsigned I = 0; I < NumTrampolines; ++I)
this->AvailableTrampolines.push_back( this->AvailableTrampolines.push_back(
static_cast<TargetAddress>(reinterpret_cast<uintptr_t>( static_cast<JITTargetAddress>(reinterpret_cast<uintptr_t>(
TrampolineMem + (I * TargetT::TrampolineSize)))); TrampolineMem + (I * TargetT::TrampolineSize))));
EC = sys::Memory::protectMappedMemory(TrampolineBlock.getMemoryBlock(), EC = sys::Memory::protectMappedMemory(TrampolineBlock.getMemoryBlock(),
@ -207,12 +208,12 @@ private:
class IndirectStubsManager { class IndirectStubsManager {
public: public:
/// @brief Map type for initializing the manager. See init. /// @brief Map type for initializing the manager. See init.
typedef StringMap<std::pair<TargetAddress, JITSymbolFlags>> StubInitsMap; typedef StringMap<std::pair<JITTargetAddress, JITSymbolFlags>> StubInitsMap;
virtual ~IndirectStubsManager() {} virtual ~IndirectStubsManager() {}
/// @brief Create a single stub with the given name, target address and flags. /// @brief Create a single stub with the given name, target address and flags.
virtual Error createStub(StringRef StubName, TargetAddress StubAddr, virtual Error createStub(StringRef StubName, JITTargetAddress StubAddr,
JITSymbolFlags StubFlags) = 0; JITSymbolFlags StubFlags) = 0;
/// @brief Create StubInits.size() stubs with the given names, target /// @brief Create StubInits.size() stubs with the given names, target
@ -228,7 +229,7 @@ public:
virtual JITSymbol findPointer(StringRef Name) = 0; virtual JITSymbol findPointer(StringRef Name) = 0;
/// @brief Change the value of the implementation pointer for the stub. /// @brief Change the value of the implementation pointer for the stub.
virtual Error updatePointer(StringRef Name, TargetAddress NewAddr) = 0; virtual Error updatePointer(StringRef Name, JITTargetAddress NewAddr) = 0;
private: private:
virtual void anchor(); virtual void anchor();
@ -239,7 +240,7 @@ private:
template <typename TargetT> template <typename TargetT>
class LocalIndirectStubsManager : public IndirectStubsManager { class LocalIndirectStubsManager : public IndirectStubsManager {
public: public:
Error createStub(StringRef StubName, TargetAddress StubAddr, Error createStub(StringRef StubName, JITTargetAddress StubAddr,
JITSymbolFlags StubFlags) override { JITSymbolFlags StubFlags) override {
if (auto Err = reserveStubs(1)) if (auto Err = reserveStubs(1))
return Err; return Err;
@ -268,7 +269,7 @@ public:
void *StubAddr = IndirectStubsInfos[Key.first].getStub(Key.second); void *StubAddr = IndirectStubsInfos[Key.first].getStub(Key.second);
assert(StubAddr && "Missing stub address"); assert(StubAddr && "Missing stub address");
auto StubTargetAddr = auto StubTargetAddr =
static_cast<TargetAddress>(reinterpret_cast<uintptr_t>(StubAddr)); static_cast<JITTargetAddress>(reinterpret_cast<uintptr_t>(StubAddr));
auto StubSymbol = JITSymbol(StubTargetAddr, I->second.second); auto StubSymbol = JITSymbol(StubTargetAddr, I->second.second);
if (ExportedStubsOnly && !StubSymbol.isExported()) if (ExportedStubsOnly && !StubSymbol.isExported())
return nullptr; return nullptr;
@ -283,11 +284,11 @@ public:
void *PtrAddr = IndirectStubsInfos[Key.first].getPtr(Key.second); void *PtrAddr = IndirectStubsInfos[Key.first].getPtr(Key.second);
assert(PtrAddr && "Missing pointer address"); assert(PtrAddr && "Missing pointer address");
auto PtrTargetAddr = auto PtrTargetAddr =
static_cast<TargetAddress>(reinterpret_cast<uintptr_t>(PtrAddr)); static_cast<JITTargetAddress>(reinterpret_cast<uintptr_t>(PtrAddr));
return JITSymbol(PtrTargetAddr, I->second.second); return JITSymbol(PtrTargetAddr, I->second.second);
} }
Error updatePointer(StringRef Name, TargetAddress NewAddr) override { Error updatePointer(StringRef Name, JITTargetAddress NewAddr) override {
auto I = StubIndexes.find(Name); auto I = StubIndexes.find(Name);
assert(I != StubIndexes.end() && "No stub pointer for symbol"); assert(I != StubIndexes.end() && "No stub pointer for symbol");
auto Key = I->second.first; auto Key = I->second.first;
@ -313,7 +314,7 @@ private:
return Error::success(); return Error::success();
} }
void createStubInternal(StringRef StubName, TargetAddress InitAddr, void createStubInternal(StringRef StubName, JITTargetAddress InitAddr,
JITSymbolFlags StubFlags) { JITSymbolFlags StubFlags) {
auto Key = FreeStubs.back(); auto Key = FreeStubs.back();
FreeStubs.pop_back(); FreeStubs.pop_back();
@ -335,7 +336,7 @@ private:
/// manager if a compile callback fails. /// manager if a compile callback fails.
std::unique_ptr<JITCompileCallbackManager> std::unique_ptr<JITCompileCallbackManager>
createLocalCompileCallbackManager(const Triple &T, createLocalCompileCallbackManager(const Triple &T,
TargetAddress ErrorHandlerAddress); JITTargetAddress ErrorHandlerAddress);
/// @brief Create a local indriect stubs manager builder. /// @brief Create a local indriect stubs manager builder.
/// ///
@ -348,7 +349,7 @@ createLocalIndirectStubsManagerBuilder(const Triple &T);
/// ///
/// Usage example: Turn a trampoline address into a function pointer constant /// Usage example: Turn a trampoline address into a function pointer constant
/// for use in a stub. /// for use in a stub.
Constant *createIRTypedAddress(FunctionType &FT, TargetAddress Addr); Constant *createIRTypedAddress(FunctionType &FT, JITTargetAddress Addr);
/// @brief Create a function pointer with the given type, name, and initializer /// @brief Create a function pointer with the given type, name, and initializer
/// in the given Module. /// in the given Module.

View File

@ -1,87 +0,0 @@
//===----------- JITSymbol.h - JIT symbol abstraction -----------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
//
// Abstraction for target process addresses.
//
//===----------------------------------------------------------------------===//
#ifndef LLVM_EXECUTIONENGINE_ORC_JITSYMBOL_H
#define LLVM_EXECUTIONENGINE_ORC_JITSYMBOL_H
#include "llvm/ExecutionEngine/JITSymbolFlags.h"
#include "llvm/ExecutionEngine/RuntimeDyld.h"
#include "llvm/Support/DataTypes.h"
#include <cassert>
#include <functional>
namespace llvm {
namespace orc {
/// @brief Represents an address in the target process's address space.
typedef uint64_t TargetAddress;
/// @brief Represents a symbol in the JIT.
class JITSymbol : public JITSymbolBase {
public:
typedef std::function<TargetAddress()> GetAddressFtor;
/// @brief Create a 'null' symbol that represents failure to find a symbol
/// definition.
JITSymbol(std::nullptr_t)
: JITSymbolBase(JITSymbolFlags::None), CachedAddr(0) {}
/// @brief Create a symbol for a definition with a known address.
JITSymbol(TargetAddress Addr, JITSymbolFlags Flags)
: JITSymbolBase(Flags), CachedAddr(Addr) {}
/// @brief Create a symbol for a definition that doesn't have a known address
/// yet.
/// @param GetAddress A functor to materialize a definition (fixing the
/// address) on demand.
///
/// This constructor allows a JIT layer to provide a reference to a symbol
/// definition without actually materializing the definition up front. The
/// user can materialize the definition at any time by calling the getAddress
/// method.
JITSymbol(GetAddressFtor GetAddress, JITSymbolFlags Flags)
: JITSymbolBase(Flags), GetAddress(std::move(GetAddress)), CachedAddr(0) {}
/// @brief Create a JITSymbol from a RuntimeDyld::SymbolInfo.
JITSymbol(const RuntimeDyld::SymbolInfo &Sym)
: JITSymbolBase(Sym.getFlags()), CachedAddr(Sym.getAddress()) {}
/// @brief Returns true if the symbol exists, false otherwise.
explicit operator bool() const { return CachedAddr || GetAddress; }
/// @brief Get the address of the symbol in the target address space. Returns
/// '0' if the symbol does not exist.
TargetAddress getAddress() {
if (GetAddress) {
CachedAddr = GetAddress();
assert(CachedAddr && "Symbol could not be materialized.");
GetAddress = nullptr;
}
return CachedAddr;
}
/// @brief Convert this JITSymbol to a RuntimeDyld::SymbolInfo.
RuntimeDyld::SymbolInfo toRuntimeDyldSymbol() {
return RuntimeDyld::SymbolInfo(getAddress(), getFlags());
}
private:
GetAddressFtor GetAddress;
TargetAddress CachedAddr;
};
} // End namespace orc.
} // End namespace llvm.
#endif // LLVM_EXECUTIONENGINE_ORC_JITSYMBOL_H

View File

@ -23,7 +23,7 @@ namespace llvm {
namespace orc { namespace orc {
template <typename DylibLookupFtorT, typename ExternalLookupFtorT> template <typename DylibLookupFtorT, typename ExternalLookupFtorT>
class LambdaResolver : public RuntimeDyld::SymbolResolver { class LambdaResolver : public JITSymbolResolver {
public: public:
LambdaResolver(DylibLookupFtorT DylibLookupFtor, LambdaResolver(DylibLookupFtorT DylibLookupFtor,
@ -31,12 +31,11 @@ public:
: DylibLookupFtor(DylibLookupFtor), : DylibLookupFtor(DylibLookupFtor),
ExternalLookupFtor(ExternalLookupFtor) {} ExternalLookupFtor(ExternalLookupFtor) {}
RuntimeDyld::SymbolInfo JITSymbol findSymbolInLogicalDylib(const std::string &Name) final {
findSymbolInLogicalDylib(const std::string &Name) final {
return DylibLookupFtor(Name); return DylibLookupFtor(Name);
} }
RuntimeDyld::SymbolInfo findSymbol(const std::string &Name) final { JITSymbol findSymbol(const std::string &Name) final {
return ExternalLookupFtor(Name); return ExternalLookupFtor(Name);
} }

View File

@ -14,8 +14,7 @@
#ifndef LLVM_EXECUTIONENGINE_ORC_LAZYEMITTINGLAYER_H #ifndef LLVM_EXECUTIONENGINE_ORC_LAZYEMITTINGLAYER_H
#define LLVM_EXECUTIONENGINE_ORC_LAZYEMITTINGLAYER_H #define LLVM_EXECUTIONENGINE_ORC_LAZYEMITTINGLAYER_H
#include "JITSymbol.h" #include "llvm/ExecutionEngine/JITSymbol.h"
#include "llvm/ExecutionEngine/RTDyldMemoryManager.h"
#include "llvm/IR/GlobalValue.h" #include "llvm/IR/GlobalValue.h"
#include "llvm/IR/Mangler.h" #include "llvm/IR/Mangler.h"
#include "llvm/IR/Module.h" #include "llvm/IR/Module.h"
@ -52,7 +51,7 @@ private:
std::string PName = Name; std::string PName = Name;
JITSymbolFlags Flags = JITSymbolBase::flagsFromGlobalValue(*GV); JITSymbolFlags Flags = JITSymbolBase::flagsFromGlobalValue(*GV);
auto GetAddress = auto GetAddress =
[this, ExportedSymbolsOnly, PName, &B]() -> TargetAddress { [this, ExportedSymbolsOnly, PName, &B]() -> JITTargetAddress {
if (this->EmitState == Emitting) if (this->EmitState == Emitting)
return 0; return 0;
else if (this->EmitState == NotEmitted) { else if (this->EmitState == NotEmitted) {

View File

@ -14,7 +14,7 @@
#ifndef LLVM_EXECUTIONENGINE_ORC_LOGICALDYLIB_H #ifndef LLVM_EXECUTIONENGINE_ORC_LOGICALDYLIB_H
#define LLVM_EXECUTIONENGINE_ORC_LOGICALDYLIB_H #define LLVM_EXECUTIONENGINE_ORC_LOGICALDYLIB_H
#include "llvm/ExecutionEngine/Orc/JITSymbol.h" #include "llvm/ExecutionEngine/JITSymbol.h"
#include <string> #include <string>
#include <vector> #include <vector>

View File

@ -22,12 +22,11 @@ namespace orc {
/// SymbolResolver impliementation that rejects all resolution requests. /// SymbolResolver impliementation that rejects all resolution requests.
/// Useful for clients that have no cross-object fixups. /// Useful for clients that have no cross-object fixups.
class NullResolver : public RuntimeDyld::SymbolResolver { class NullResolver : public JITSymbolResolver {
public: public:
RuntimeDyld::SymbolInfo findSymbol(const std::string &Name) final; JITSymbol findSymbol(const std::string &Name) final;
RuntimeDyld::SymbolInfo JITSymbol findSymbolInLogicalDylib(const std::string &Name) final;
findSymbolInLogicalDylib(const std::string &Name) final;
}; };
} // End namespace orc. } // End namespace orc.

View File

@ -14,9 +14,9 @@
#ifndef LLVM_EXECUTIONENGINE_ORC_OBJECTLINKINGLAYER_H #ifndef LLVM_EXECUTIONENGINE_ORC_OBJECTLINKINGLAYER_H
#define LLVM_EXECUTIONENGINE_ORC_OBJECTLINKINGLAYER_H #define LLVM_EXECUTIONENGINE_ORC_OBJECTLINKINGLAYER_H
#include "JITSymbol.h"
#include "llvm/ADT/STLExtras.h" #include "llvm/ADT/STLExtras.h"
#include "llvm/ExecutionEngine/ExecutionEngine.h" #include "llvm/ExecutionEngine/ExecutionEngine.h"
#include "llvm/ExecutionEngine/JITSymbol.h"
#include "llvm/ExecutionEngine/SectionMemoryManager.h" #include "llvm/ExecutionEngine/SectionMemoryManager.h"
#include <list> #include <list>
#include <memory> #include <memory>
@ -46,7 +46,7 @@ protected:
getSymbolMaterializer(std::string Name) = 0; getSymbolMaterializer(std::string Name) = 0;
virtual void mapSectionAddress(const void *LocalAddress, virtual void mapSectionAddress(const void *LocalAddress,
TargetAddress TargetAddr) const = 0; JITTargetAddress TargetAddr) const = 0;
JITSymbol getSymbol(StringRef Name, bool ExportedSymbolsOnly) { JITSymbol getSymbol(StringRef Name, bool ExportedSymbolsOnly) {
auto SymEntry = SymbolTable.find(Name); auto SymEntry = SymbolTable.find(Name);
@ -60,7 +60,7 @@ protected:
return JITSymbol(SymEntry->second); return JITSymbol(SymEntry->second);
} }
protected: protected:
StringMap<RuntimeDyld::SymbolInfo> SymbolTable; StringMap<JITEvaluatedSymbol> SymbolTable;
bool Finalized = false; bool Finalized = false;
}; };
@ -144,7 +144,7 @@ private:
} }
void mapSectionAddress(const void *LocalAddress, void mapSectionAddress(const void *LocalAddress,
TargetAddress TargetAddr) const override { JITTargetAddress TargetAddr) const override {
assert(PFC && "mapSectionAddress called on finalized LinkedObjectSet"); assert(PFC && "mapSectionAddress called on finalized LinkedObjectSet");
assert(PFC->RTDyld && "mapSectionAddress called on raw LinkedObjectSet"); assert(PFC->RTDyld && "mapSectionAddress called on raw LinkedObjectSet");
PFC->RTDyld->mapSectionAddress(LocalAddress, TargetAddr); PFC->RTDyld->mapSectionAddress(LocalAddress, TargetAddr);
@ -165,7 +165,7 @@ private:
} }
auto Flags = JITSymbol::flagsFromObjectSymbol(Symbol); auto Flags = JITSymbol::flagsFromObjectSymbol(Symbol);
SymbolTable.insert( SymbolTable.insert(
std::make_pair(*SymbolName, RuntimeDyld::SymbolInfo(0, Flags))); std::make_pair(*SymbolName, JITEvaluatedSymbol(0, Flags)));
} }
} }
@ -322,7 +322,7 @@ public:
/// @brief Map section addresses for the objects associated with the handle H. /// @brief Map section addresses for the objects associated with the handle H.
void mapSectionAddress(ObjSetHandleT H, const void *LocalAddress, void mapSectionAddress(ObjSetHandleT H, const void *LocalAddress,
TargetAddress TargetAddr) { JITTargetAddress TargetAddr) {
(*H)->mapSectionAddress(LocalAddress, TargetAddr); (*H)->mapSectionAddress(LocalAddress, TargetAddr);
} }

View File

@ -14,7 +14,7 @@
#ifndef LLVM_EXECUTIONENGINE_ORC_OBJECTTRANSFORMLAYER_H #ifndef LLVM_EXECUTIONENGINE_ORC_OBJECTTRANSFORMLAYER_H
#define LLVM_EXECUTIONENGINE_ORC_OBJECTTRANSFORMLAYER_H #define LLVM_EXECUTIONENGINE_ORC_OBJECTTRANSFORMLAYER_H
#include "JITSymbol.h" #include "llvm/ExecutionEngine/JITSymbol.h"
namespace llvm { namespace llvm {
namespace orc { namespace orc {
@ -83,7 +83,7 @@ public:
/// @brief Map section addresses for the objects associated with the handle H. /// @brief Map section addresses for the objects associated with the handle H.
void mapSectionAddress(ObjSetHandleT H, const void *LocalAddress, void mapSectionAddress(ObjSetHandleT H, const void *LocalAddress,
TargetAddress TargetAddr) { JITTargetAddress TargetAddr) {
BaseLayer.mapSectionAddress(H, LocalAddress, TargetAddr); BaseLayer.mapSectionAddress(H, LocalAddress, TargetAddr);
} }

View File

@ -37,7 +37,8 @@ public:
static const unsigned TrampolineSize = 1; static const unsigned TrampolineSize = 1;
static const unsigned ResolverCodeSize = 1; static const unsigned ResolverCodeSize = 1;
typedef TargetAddress (*JITReentryFn)(void *CallbackMgr, void *TrampolineId); typedef JITTargetAddress (*JITReentryFn)(void *CallbackMgr,
void *TrampolineId);
static void writeResolverCode(uint8_t *ResolveMem, JITReentryFn Reentry, static void writeResolverCode(uint8_t *ResolveMem, JITReentryFn Reentry,
void *CallbackMgr) { void *CallbackMgr) {
@ -115,7 +116,8 @@ public:
typedef GenericIndirectStubsInfo<8> IndirectStubsInfo; typedef GenericIndirectStubsInfo<8> IndirectStubsInfo;
typedef TargetAddress (*JITReentryFn)(void *CallbackMgr, void *TrampolineId); typedef JITTargetAddress (*JITReentryFn)(void *CallbackMgr,
void *TrampolineId);
/// @brief Write the resolver code into the given memory. The user is be /// @brief Write the resolver code into the given memory. The user is be
/// responsible for allocating the memory and setting permissions. /// responsible for allocating the memory and setting permissions.
@ -170,7 +172,8 @@ public:
class OrcX86_64_SysV : public OrcX86_64_Base { class OrcX86_64_SysV : public OrcX86_64_Base {
public: public:
static const unsigned ResolverCodeSize = 0x6C; static const unsigned ResolverCodeSize = 0x6C;
typedef TargetAddress(*JITReentryFn)(void *CallbackMgr, void *TrampolineId); typedef JITTargetAddress (*JITReentryFn)(void *CallbackMgr,
void *TrampolineId);
/// @brief Write the resolver code into the given memory. The user is be /// @brief Write the resolver code into the given memory. The user is be
/// responsible for allocating the memory and setting permissions. /// responsible for allocating the memory and setting permissions.
@ -184,7 +187,8 @@ public:
class OrcX86_64_Win32 : public OrcX86_64_Base { class OrcX86_64_Win32 : public OrcX86_64_Base {
public: public:
static const unsigned ResolverCodeSize = 0x74; static const unsigned ResolverCodeSize = 0x74;
typedef TargetAddress(*JITReentryFn)(void *CallbackMgr, void *TrampolineId); typedef JITTargetAddress (*JITReentryFn)(void *CallbackMgr,
void *TrampolineId);
/// @brief Write the resolver code into the given memory. The user is be /// @brief Write the resolver code into the given memory. The user is be
/// responsible for allocating the memory and setting permissions. /// responsible for allocating the memory and setting permissions.
@ -203,7 +207,8 @@ public:
typedef GenericIndirectStubsInfo<8> IndirectStubsInfo; typedef GenericIndirectStubsInfo<8> IndirectStubsInfo;
typedef TargetAddress (*JITReentryFn)(void *CallbackMgr, void *TrampolineId); typedef JITTargetAddress (*JITReentryFn)(void *CallbackMgr,
void *TrampolineId);
/// @brief Write the resolver code into the given memory. The user is be /// @brief Write the resolver code into the given memory. The user is be
/// responsible for allocating the memory and setting permissions. /// responsible for allocating the memory and setting permissions.

View File

@ -185,7 +185,7 @@ public:
DEBUG(dbgs() << "Allocator " << Id << " applied mappings:\n"); DEBUG(dbgs() << "Allocator " << Id << " applied mappings:\n");
for (auto &ObjAllocs : Unmapped) { for (auto &ObjAllocs : Unmapped) {
{ {
TargetAddress NextCodeAddr = ObjAllocs.RemoteCodeAddr; JITTargetAddress NextCodeAddr = ObjAllocs.RemoteCodeAddr;
for (auto &Alloc : ObjAllocs.CodeAllocs) { for (auto &Alloc : ObjAllocs.CodeAllocs) {
NextCodeAddr = alignTo(NextCodeAddr, Alloc.getAlign()); NextCodeAddr = alignTo(NextCodeAddr, Alloc.getAlign());
Dyld.mapSectionAddress(Alloc.getLocalAddress(), NextCodeAddr); Dyld.mapSectionAddress(Alloc.getLocalAddress(), NextCodeAddr);
@ -197,7 +197,7 @@ public:
} }
} }
{ {
TargetAddress NextRODataAddr = ObjAllocs.RemoteRODataAddr; JITTargetAddress NextRODataAddr = ObjAllocs.RemoteRODataAddr;
for (auto &Alloc : ObjAllocs.RODataAllocs) { for (auto &Alloc : ObjAllocs.RODataAllocs) {
NextRODataAddr = alignTo(NextRODataAddr, Alloc.getAlign()); NextRODataAddr = alignTo(NextRODataAddr, Alloc.getAlign());
Dyld.mapSectionAddress(Alloc.getLocalAddress(), NextRODataAddr); Dyld.mapSectionAddress(Alloc.getLocalAddress(), NextRODataAddr);
@ -210,7 +210,7 @@ public:
} }
} }
{ {
TargetAddress NextRWDataAddr = ObjAllocs.RemoteRWDataAddr; JITTargetAddress NextRWDataAddr = ObjAllocs.RemoteRWDataAddr;
for (auto &Alloc : ObjAllocs.RWDataAllocs) { for (auto &Alloc : ObjAllocs.RWDataAllocs) {
NextRWDataAddr = alignTo(NextRWDataAddr, Alloc.getAlign()); NextRWDataAddr = alignTo(NextRWDataAddr, Alloc.getAlign());
Dyld.mapSectionAddress(Alloc.getLocalAddress(), NextRWDataAddr); Dyld.mapSectionAddress(Alloc.getLocalAddress(), NextRWDataAddr);
@ -389,17 +389,17 @@ public:
return reinterpret_cast<char *>(LocalAddr); return reinterpret_cast<char *>(LocalAddr);
} }
void setRemoteAddress(TargetAddress RemoteAddr) { void setRemoteAddress(JITTargetAddress RemoteAddr) {
this->RemoteAddr = RemoteAddr; this->RemoteAddr = RemoteAddr;
} }
TargetAddress getRemoteAddress() const { return RemoteAddr; } JITTargetAddress getRemoteAddress() const { return RemoteAddr; }
private: private:
uint64_t Size; uint64_t Size;
unsigned Align; unsigned Align;
std::unique_ptr<char[]> Contents; std::unique_ptr<char[]> Contents;
TargetAddress RemoteAddr = 0; JITTargetAddress RemoteAddr = 0;
}; };
struct ObjectAllocs { struct ObjectAllocs {
@ -423,9 +423,9 @@ public:
return *this; return *this;
} }
TargetAddress RemoteCodeAddr = 0; JITTargetAddress RemoteCodeAddr = 0;
TargetAddress RemoteRODataAddr = 0; JITTargetAddress RemoteRODataAddr = 0;
TargetAddress RemoteRWDataAddr = 0; JITTargetAddress RemoteRWDataAddr = 0;
std::vector<Alloc> CodeAllocs, RODataAllocs, RWDataAllocs; std::vector<Alloc> CodeAllocs, RODataAllocs, RWDataAllocs;
}; };
@ -450,7 +450,7 @@ public:
} }
} }
Error createStub(StringRef StubName, TargetAddress StubAddr, Error createStub(StringRef StubName, JITTargetAddress StubAddr,
JITSymbolFlags StubFlags) override { JITSymbolFlags StubFlags) override {
if (auto Err = reserveStubs(1)) if (auto Err = reserveStubs(1))
return Err; return Err;
@ -491,7 +491,7 @@ public:
return JITSymbol(getPtrAddr(Key), Flags); return JITSymbol(getPtrAddr(Key), Flags);
} }
Error updatePointer(StringRef Name, TargetAddress NewAddr) override { Error updatePointer(StringRef Name, JITTargetAddress NewAddr) override {
auto I = StubIndexes.find(Name); auto I = StubIndexes.find(Name);
assert(I != StubIndexes.end() && "No stub pointer for symbol"); assert(I != StubIndexes.end() && "No stub pointer for symbol");
auto Key = I->second.first; auto Key = I->second.first;
@ -500,8 +500,8 @@ public:
private: private:
struct RemoteIndirectStubsInfo { struct RemoteIndirectStubsInfo {
TargetAddress StubBase; JITTargetAddress StubBase;
TargetAddress PtrBase; JITTargetAddress PtrBase;
unsigned NumStubs; unsigned NumStubs;
}; };
@ -517,8 +517,8 @@ public:
return Error::success(); return Error::success();
unsigned NewStubsRequired = NumStubs - FreeStubs.size(); unsigned NewStubsRequired = NumStubs - FreeStubs.size();
TargetAddress StubBase; JITTargetAddress StubBase;
TargetAddress PtrBase; JITTargetAddress PtrBase;
unsigned NumStubsEmitted; unsigned NumStubsEmitted;
if (auto StubInfoOrErr = Remote.emitIndirectStubs(Id, NewStubsRequired)) if (auto StubInfoOrErr = Remote.emitIndirectStubs(Id, NewStubsRequired))
@ -535,7 +535,7 @@ public:
return Error::success(); return Error::success();
} }
Error createStubInternal(StringRef StubName, TargetAddress InitAddr, Error createStubInternal(StringRef StubName, JITTargetAddress InitAddr,
JITSymbolFlags StubFlags) { JITSymbolFlags StubFlags) {
auto Key = FreeStubs.back(); auto Key = FreeStubs.back();
FreeStubs.pop_back(); FreeStubs.pop_back();
@ -543,14 +543,14 @@ public:
return Remote.writePointer(getPtrAddr(Key), InitAddr); return Remote.writePointer(getPtrAddr(Key), InitAddr);
} }
TargetAddress getStubAddr(StubKey K) { JITTargetAddress getStubAddr(StubKey K) {
assert(RemoteIndirectStubsInfos[K.first].StubBase != 0 && assert(RemoteIndirectStubsInfos[K.first].StubBase != 0 &&
"Missing stub address"); "Missing stub address");
return RemoteIndirectStubsInfos[K.first].StubBase + return RemoteIndirectStubsInfos[K.first].StubBase +
K.second * Remote.getIndirectStubSize(); K.second * Remote.getIndirectStubSize();
} }
TargetAddress getPtrAddr(StubKey K) { JITTargetAddress getPtrAddr(StubKey K) {
assert(RemoteIndirectStubsInfos[K.first].PtrBase != 0 && assert(RemoteIndirectStubsInfos[K.first].PtrBase != 0 &&
"Missing pointer address"); "Missing pointer address");
return RemoteIndirectStubsInfos[K.first].PtrBase + return RemoteIndirectStubsInfos[K.first].PtrBase +
@ -561,13 +561,13 @@ public:
/// Remote compile callback manager. /// Remote compile callback manager.
class RCCompileCallbackManager : public JITCompileCallbackManager { class RCCompileCallbackManager : public JITCompileCallbackManager {
public: public:
RCCompileCallbackManager(TargetAddress ErrorHandlerAddress, RCCompileCallbackManager(JITTargetAddress ErrorHandlerAddress,
OrcRemoteTargetClient &Remote) OrcRemoteTargetClient &Remote)
: JITCompileCallbackManager(ErrorHandlerAddress), Remote(Remote) {} : JITCompileCallbackManager(ErrorHandlerAddress), Remote(Remote) {}
private: private:
void grow() override { void grow() override {
TargetAddress BlockAddr = 0; JITTargetAddress BlockAddr = 0;
uint32_t NumTrampolines = 0; uint32_t NumTrampolines = 0;
if (auto TrampolineInfoOrErr = Remote.emitTrampolineBlock()) if (auto TrampolineInfoOrErr = Remote.emitTrampolineBlock())
std::tie(BlockAddr, NumTrampolines) = *TrampolineInfoOrErr; std::tie(BlockAddr, NumTrampolines) = *TrampolineInfoOrErr;
@ -597,7 +597,7 @@ public:
/// Call the int(void) function at the given address in the target and return /// Call the int(void) function at the given address in the target and return
/// its result. /// its result.
Expected<int> callIntVoid(TargetAddress Addr) { Expected<int> callIntVoid(JITTargetAddress Addr) {
DEBUG(dbgs() << "Calling int(*)(void) " << format("0x%016x", Addr) << "\n"); DEBUG(dbgs() << "Calling int(*)(void) " << format("0x%016x", Addr) << "\n");
auto Listen = [&](RPCChannel &C, uint32_t Id) { auto Listen = [&](RPCChannel &C, uint32_t Id) {
@ -608,7 +608,7 @@ public:
/// Call the int(int, char*[]) function at the given address in the target and /// Call the int(int, char*[]) function at the given address in the target and
/// return its result. /// return its result.
Expected<int> callMain(TargetAddress Addr, Expected<int> callMain(JITTargetAddress Addr,
const std::vector<std::string> &Args) { const std::vector<std::string> &Args) {
DEBUG(dbgs() << "Calling int(*)(int, char*[]) " << format("0x%016x", Addr) DEBUG(dbgs() << "Calling int(*)(int, char*[]) " << format("0x%016x", Addr)
<< "\n"); << "\n");
@ -621,7 +621,7 @@ public:
/// Call the void() function at the given address in the target and wait for /// Call the void() function at the given address in the target and wait for
/// it to finish. /// it to finish.
Error callVoidVoid(TargetAddress Addr) { Error callVoidVoid(JITTargetAddress Addr) {
DEBUG(dbgs() << "Calling void(*)(void) " << format("0x%016x", Addr) DEBUG(dbgs() << "Calling void(*)(void) " << format("0x%016x", Addr)
<< "\n"); << "\n");
@ -655,7 +655,7 @@ public:
} }
Expected<RCCompileCallbackManager &> Expected<RCCompileCallbackManager &>
enableCompileCallbacks(TargetAddress ErrorHandlerAddress) { enableCompileCallbacks(JITTargetAddress ErrorHandlerAddress) {
// Check for an 'out-of-band' error, e.g. from an MM destructor. // Check for an 'out-of-band' error, e.g. from an MM destructor.
if (ExistingError) if (ExistingError)
return std::move(ExistingError); return std::move(ExistingError);
@ -673,7 +673,7 @@ public:
/// Search for symbols in the remote process. Note: This should be used by /// Search for symbols in the remote process. Note: This should be used by
/// symbol resolvers *after* they've searched the local symbol table in the /// symbol resolvers *after* they've searched the local symbol table in the
/// JIT stack. /// JIT stack.
Expected<TargetAddress> getSymbolAddress(StringRef Name) { Expected<JITTargetAddress> getSymbolAddress(StringRef Name) {
// Check for an 'out-of-band' error, e.g. from an MM destructor. // Check for an 'out-of-band' error, e.g. from an MM destructor.
if (ExistingError) if (ExistingError)
return std::move(ExistingError); return std::move(ExistingError);
@ -698,7 +698,7 @@ private:
} }
} }
Error deregisterEHFrames(TargetAddress Addr, uint32_t Size) { Error deregisterEHFrames(JITTargetAddress Addr, uint32_t Size) {
return callST<RegisterEHFrames>(Channel, Addr, Size); return callST<RegisterEHFrames>(Channel, Addr, Size);
} }
@ -716,12 +716,12 @@ private:
return callST<DestroyIndirectStubsOwner>(Channel, Id); return callST<DestroyIndirectStubsOwner>(Channel, Id);
} }
Expected<std::tuple<TargetAddress, TargetAddress, uint32_t>> Expected<std::tuple<JITTargetAddress, JITTargetAddress, uint32_t>>
emitIndirectStubs(ResourceIdMgr::ResourceId Id, uint32_t NumStubsRequired) { emitIndirectStubs(ResourceIdMgr::ResourceId Id, uint32_t NumStubsRequired) {
return callST<EmitIndirectStubs>(Channel, Id, NumStubsRequired); return callST<EmitIndirectStubs>(Channel, Id, NumStubsRequired);
} }
Expected<std::tuple<TargetAddress, uint32_t>> emitTrampolineBlock() { Expected<std::tuple<JITTargetAddress, uint32_t>> emitTrampolineBlock() {
// Check for an 'out-of-band' error, e.g. from an MM destructor. // Check for an 'out-of-band' error, e.g. from an MM destructor.
if (ExistingError) if (ExistingError)
return std::move(ExistingError); return std::move(ExistingError);
@ -747,7 +747,7 @@ private:
// site below, but that triggers a GCC 4.7 ICE. When we move off // site below, but that triggers a GCC 4.7 ICE. When we move off
// GCC 4.7, tidy this up. // GCC 4.7, tidy this up.
auto CompileCallback = auto CompileCallback =
[this](TargetAddress Addr) -> Expected<TargetAddress> { [this](JITTargetAddress Addr) -> Expected<JITTargetAddress> {
return this->CallbackManager->executeCompileCallback(Addr); return this->CallbackManager->executeCompileCallback(Addr);
}; };
@ -760,7 +760,7 @@ private:
return orcError(OrcErrorCode::UnexpectedRPCCall); return orcError(OrcErrorCode::UnexpectedRPCCall);
} }
Expected<std::vector<char>> readMem(char *Dst, TargetAddress Src, Expected<std::vector<char>> readMem(char *Dst, JITTargetAddress Src,
uint64_t Size) { uint64_t Size) {
// Check for an 'out-of-band' error, e.g. from an MM destructor. // Check for an 'out-of-band' error, e.g. from an MM destructor.
if (ExistingError) if (ExistingError)
@ -769,12 +769,12 @@ private:
return callST<ReadMem>(Channel, Src, Size); return callST<ReadMem>(Channel, Src, Size);
} }
Error registerEHFrames(TargetAddress &RAddr, uint32_t Size) { Error registerEHFrames(JITTargetAddress &RAddr, uint32_t Size) {
return callST<RegisterEHFrames>(Channel, RAddr, Size); return callST<RegisterEHFrames>(Channel, RAddr, Size);
} }
Expected<TargetAddress> reserveMem(ResourceIdMgr::ResourceId Id, Expected<JITTargetAddress> reserveMem(ResourceIdMgr::ResourceId Id,
uint64_t Size, uint32_t Align) { uint64_t Size, uint32_t Align) {
// Check for an 'out-of-band' error, e.g. from an MM destructor. // Check for an 'out-of-band' error, e.g. from an MM destructor.
if (ExistingError) if (ExistingError)
@ -784,11 +784,11 @@ private:
} }
Error setProtections(ResourceIdMgr::ResourceId Id, Error setProtections(ResourceIdMgr::ResourceId Id,
TargetAddress RemoteSegAddr, unsigned ProtFlags) { JITTargetAddress RemoteSegAddr, unsigned ProtFlags) {
return callST<SetProtections>(Channel, Id, RemoteSegAddr, ProtFlags); return callST<SetProtections>(Channel, Id, RemoteSegAddr, ProtFlags);
} }
Error writeMem(TargetAddress Addr, const char *Src, uint64_t Size) { Error writeMem(JITTargetAddress Addr, const char *Src, uint64_t Size) {
// Check for an 'out-of-band' error, e.g. from an MM destructor. // Check for an 'out-of-band' error, e.g. from an MM destructor.
if (ExistingError) if (ExistingError)
return std::move(ExistingError); return std::move(ExistingError);
@ -796,7 +796,7 @@ private:
return callST<WriteMem>(Channel, DirectBufferWriter(Src, Addr, Size)); return callST<WriteMem>(Channel, DirectBufferWriter(Src, Addr, Size));
} }
Error writePointer(TargetAddress Addr, TargetAddress PtrVal) { Error writePointer(JITTargetAddress Addr, JITTargetAddress PtrVal) {
// Check for an 'out-of-band' error, e.g. from an MM destructor. // Check for an 'out-of-band' error, e.g. from an MM destructor.
if (ExistingError) if (ExistingError)
return std::move(ExistingError); return std::move(ExistingError);

View File

@ -16,9 +16,9 @@
#ifndef LLVM_EXECUTIONENGINE_ORC_ORCREMOTETARGETRPCAPI_H #ifndef LLVM_EXECUTIONENGINE_ORC_ORCREMOTETARGETRPCAPI_H
#define LLVM_EXECUTIONENGINE_ORC_ORCREMOTETARGETRPCAPI_H #define LLVM_EXECUTIONENGINE_ORC_ORCREMOTETARGETRPCAPI_H
#include "JITSymbol.h"
#include "RPCChannel.h" #include "RPCChannel.h"
#include "RPCUtils.h" #include "RPCUtils.h"
#include "llvm/ExecutionEngine/JITSymbol.h"
namespace llvm { namespace llvm {
namespace orc { namespace orc {
@ -27,16 +27,16 @@ namespace remote {
class DirectBufferWriter { class DirectBufferWriter {
public: public:
DirectBufferWriter() = default; DirectBufferWriter() = default;
DirectBufferWriter(const char *Src, TargetAddress Dst, uint64_t Size) DirectBufferWriter(const char *Src, JITTargetAddress Dst, uint64_t Size)
: Src(Src), Dst(Dst), Size(Size) {} : Src(Src), Dst(Dst), Size(Size) {}
const char *getSrc() const { return Src; } const char *getSrc() const { return Src; }
TargetAddress getDst() const { return Dst; } JITTargetAddress getDst() const { return Dst; }
uint64_t getSize() const { return Size; } uint64_t getSize() const { return Size; }
private: private:
const char *Src; const char *Src;
TargetAddress Dst; JITTargetAddress Dst;
uint64_t Size; uint64_t Size;
}; };
@ -49,7 +49,7 @@ inline Error serialize(RPCChannel &C, const DirectBufferWriter &DBW) {
} }
inline Error deserialize(RPCChannel &C, DirectBufferWriter &DBW) { inline Error deserialize(RPCChannel &C, DirectBufferWriter &DBW) {
TargetAddress Dst; JITTargetAddress Dst;
if (auto EC = deserialize(C, Dst)) if (auto EC = deserialize(C, Dst))
return EC; return EC;
uint64_t Size; uint64_t Size;
@ -120,13 +120,14 @@ public:
static const char *getJITFuncIdName(JITFuncId Id); static const char *getJITFuncIdName(JITFuncId Id);
typedef Function<CallIntVoidId, int32_t(TargetAddress Addr)> CallIntVoid; typedef Function<CallIntVoidId, int32_t(JITTargetAddress Addr)> CallIntVoid;
typedef Function<CallMainId, typedef Function<CallMainId,
int32_t(TargetAddress Addr, std::vector<std::string> Args)> int32_t(JITTargetAddress Addr,
std::vector<std::string> Args)>
CallMain; CallMain;
typedef Function<CallVoidVoidId, void(TargetAddress FnAddr)> CallVoidVoid; typedef Function<CallVoidVoidId, void(JITTargetAddress FnAddr)> CallVoidVoid;
typedef Function<CreateRemoteAllocatorId, typedef Function<CreateRemoteAllocatorId,
void(ResourceIdMgr::ResourceId AllocatorID)> void(ResourceIdMgr::ResourceId AllocatorID)>
@ -137,7 +138,7 @@ public:
CreateIndirectStubsOwner; CreateIndirectStubsOwner;
typedef Function<DeregisterEHFramesId, typedef Function<DeregisterEHFramesId,
void(TargetAddress Addr, uint32_t Size)> void(JITTargetAddress Addr, uint32_t Size)>
DeregisterEHFrames; DeregisterEHFrames;
typedef Function<DestroyRemoteAllocatorId, typedef Function<DestroyRemoteAllocatorId,
@ -150,7 +151,7 @@ public:
/// EmitIndirectStubs result is (StubsBase, PtrsBase, NumStubsEmitted). /// EmitIndirectStubs result is (StubsBase, PtrsBase, NumStubsEmitted).
typedef Function<EmitIndirectStubsId, typedef Function<EmitIndirectStubsId,
std::tuple<TargetAddress, TargetAddress, uint32_t>( std::tuple<JITTargetAddress, JITTargetAddress, uint32_t>(
ResourceIdMgr::ResourceId StubsOwnerID, ResourceIdMgr::ResourceId StubsOwnerID,
uint32_t NumStubsRequired)> uint32_t NumStubsRequired)>
EmitIndirectStubs; EmitIndirectStubs;
@ -158,10 +159,11 @@ public:
typedef Function<EmitResolverBlockId, void()> EmitResolverBlock; typedef Function<EmitResolverBlockId, void()> EmitResolverBlock;
/// EmitTrampolineBlock result is (BlockAddr, NumTrampolines). /// EmitTrampolineBlock result is (BlockAddr, NumTrampolines).
typedef Function<EmitTrampolineBlockId, std::tuple<TargetAddress, uint32_t>()> typedef Function<EmitTrampolineBlockId,
std::tuple<JITTargetAddress, uint32_t>()>
EmitTrampolineBlock; EmitTrampolineBlock;
typedef Function<GetSymbolAddressId, TargetAddress(std::string SymbolName)> typedef Function<GetSymbolAddressId, JITTargetAddress(std::string SymbolName)>
GetSymbolAddress; GetSymbolAddress;
/// GetRemoteInfo result is (Triple, PointerSize, PageSize, TrampolineSize, /// GetRemoteInfo result is (Triple, PointerSize, PageSize, TrampolineSize,
@ -171,23 +173,23 @@ public:
GetRemoteInfo; GetRemoteInfo;
typedef Function<ReadMemId, typedef Function<ReadMemId,
std::vector<char>(TargetAddress Src, uint64_t Size)> std::vector<char>(JITTargetAddress Src, uint64_t Size)>
ReadMem; ReadMem;
typedef Function<RegisterEHFramesId, void(TargetAddress Addr, uint32_t Size)> typedef Function<RegisterEHFramesId, void(JITTargetAddress Addr, uint32_t Size)>
RegisterEHFrames; RegisterEHFrames;
typedef Function<ReserveMemId, typedef Function<ReserveMemId,
TargetAddress(ResourceIdMgr::ResourceId AllocID, JITTargetAddress(ResourceIdMgr::ResourceId AllocID,
uint64_t Size, uint32_t Align)> uint64_t Size, uint32_t Align)>
ReserveMem; ReserveMem;
typedef Function<RequestCompileId, typedef Function<RequestCompileId,
TargetAddress(TargetAddress TrampolineAddr)> JITTargetAddress(JITTargetAddress TrampolineAddr)>
RequestCompile; RequestCompile;
typedef Function<SetProtectionsId, typedef Function<SetProtectionsId,
void(ResourceIdMgr::ResourceId AllocID, TargetAddress Dst, void(ResourceIdMgr::ResourceId AllocID, JITTargetAddress Dst,
uint32_t ProtFlags)> uint32_t ProtFlags)>
SetProtections; SetProtections;
@ -195,7 +197,7 @@ public:
typedef Function<WriteMemId, void(DirectBufferWriter DB)> WriteMem; typedef Function<WriteMemId, void(DirectBufferWriter DB)> WriteMem;
typedef Function<WritePtrId, void(TargetAddress Dst, TargetAddress Val)> typedef Function<WritePtrId, void(JITTargetAddress Dst, JITTargetAddress Val)>
WritePtr; WritePtr;
}; };

View File

@ -32,7 +32,7 @@ namespace remote {
template <typename ChannelT, typename TargetT> template <typename ChannelT, typename TargetT>
class OrcRemoteTargetServer : public OrcRemoteTargetRPCAPI { class OrcRemoteTargetServer : public OrcRemoteTargetRPCAPI {
public: public:
typedef std::function<TargetAddress(const std::string &Name)> typedef std::function<JITTargetAddress(const std::string &Name)>
SymbolLookupFtor; SymbolLookupFtor;
typedef std::function<void(uint8_t *Addr, uint32_t Size)> typedef std::function<void(uint8_t *Addr, uint32_t Size)>
@ -118,7 +118,7 @@ public:
llvm_unreachable("Unhandled JIT RPC procedure Id."); llvm_unreachable("Unhandled JIT RPC procedure Id.");
} }
Expected<TargetAddress> requestCompile(TargetAddress TrampolineAddr) { Expected<JITTargetAddress> requestCompile(JITTargetAddress TrampolineAddr) {
auto Listen = [&](RPCChannel &C, uint32_t Id) { auto Listen = [&](RPCChannel &C, uint32_t Id) {
return handleKnownFunction(static_cast<JITFuncId>(Id)); return handleKnownFunction(static_cast<JITFuncId>(Id));
}; };
@ -171,16 +171,16 @@ private:
static Error doNothing() { return Error::success(); } static Error doNothing() { return Error::success(); }
static TargetAddress reenter(void *JITTargetAddr, void *TrampolineAddr) { static JITTargetAddress reenter(void *JITTargetAddr, void *TrampolineAddr) {
auto T = static_cast<OrcRemoteTargetServer *>(JITTargetAddr); auto T = static_cast<OrcRemoteTargetServer *>(JITTargetAddr);
auto AddrOrErr = T->requestCompile(static_cast<TargetAddress>( auto AddrOrErr = T->requestCompile(static_cast<JITTargetAddress>(
reinterpret_cast<uintptr_t>(TrampolineAddr))); reinterpret_cast<uintptr_t>(TrampolineAddr)));
// FIXME: Allow customizable failure substitution functions. // FIXME: Allow customizable failure substitution functions.
assert(AddrOrErr && "Compile request failed"); assert(AddrOrErr && "Compile request failed");
return *AddrOrErr; return *AddrOrErr;
} }
Expected<int32_t> handleCallIntVoid(TargetAddress Addr) { Expected<int32_t> handleCallIntVoid(JITTargetAddress Addr) {
typedef int (*IntVoidFnTy)(); typedef int (*IntVoidFnTy)();
IntVoidFnTy Fn = IntVoidFnTy Fn =
reinterpret_cast<IntVoidFnTy>(static_cast<uintptr_t>(Addr)); reinterpret_cast<IntVoidFnTy>(static_cast<uintptr_t>(Addr));
@ -192,7 +192,7 @@ private:
return Result; return Result;
} }
Expected<int32_t> handleCallMain(TargetAddress Addr, Expected<int32_t> handleCallMain(JITTargetAddress Addr,
std::vector<std::string> Args) { std::vector<std::string> Args) {
typedef int (*MainFnTy)(int, const char *[]); typedef int (*MainFnTy)(int, const char *[]);
@ -211,7 +211,7 @@ private:
return Result; return Result;
} }
Error handleCallVoidVoid(TargetAddress Addr) { Error handleCallVoidVoid(JITTargetAddress Addr) {
typedef void (*VoidVoidFnTy)(); typedef void (*VoidVoidFnTy)();
VoidVoidFnTy Fn = VoidVoidFnTy Fn =
reinterpret_cast<VoidVoidFnTy>(static_cast<uintptr_t>(Addr)); reinterpret_cast<VoidVoidFnTy>(static_cast<uintptr_t>(Addr));
@ -241,7 +241,7 @@ private:
return Error::success(); return Error::success();
} }
Error handleDeregisterEHFrames(TargetAddress TAddr, uint32_t Size) { Error handleDeregisterEHFrames(JITTargetAddress TAddr, uint32_t Size) {
uint8_t *Addr = reinterpret_cast<uint8_t *>(static_cast<uintptr_t>(TAddr)); uint8_t *Addr = reinterpret_cast<uint8_t *>(static_cast<uintptr_t>(TAddr));
DEBUG(dbgs() << " Registering EH frames at " << format("0x%016x", TAddr) DEBUG(dbgs() << " Registering EH frames at " << format("0x%016x", TAddr)
<< ", Size = " << Size << " bytes\n"); << ", Size = " << Size << " bytes\n");
@ -266,7 +266,7 @@ private:
return Error::success(); return Error::success();
} }
Expected<std::tuple<TargetAddress, TargetAddress, uint32_t>> Expected<std::tuple<JITTargetAddress, JITTargetAddress, uint32_t>>
handleEmitIndirectStubs(ResourceIdMgr::ResourceId Id, handleEmitIndirectStubs(ResourceIdMgr::ResourceId Id,
uint32_t NumStubsRequired) { uint32_t NumStubsRequired) {
DEBUG(dbgs() << " ISMgr " << Id << " request " << NumStubsRequired DEBUG(dbgs() << " ISMgr " << Id << " request " << NumStubsRequired
@ -281,10 +281,12 @@ private:
TargetT::emitIndirectStubsBlock(IS, NumStubsRequired, nullptr)) TargetT::emitIndirectStubsBlock(IS, NumStubsRequired, nullptr))
return std::move(Err); return std::move(Err);
TargetAddress StubsBase = JITTargetAddress StubsBase =
static_cast<TargetAddress>(reinterpret_cast<uintptr_t>(IS.getStub(0))); static_cast<JITTargetAddress>(
TargetAddress PtrsBase = reinterpret_cast<uintptr_t>(IS.getStub(0)));
static_cast<TargetAddress>(reinterpret_cast<uintptr_t>(IS.getPtr(0))); JITTargetAddress PtrsBase =
static_cast<JITTargetAddress>(
reinterpret_cast<uintptr_t>(IS.getPtr(0)));
uint32_t NumStubsEmitted = IS.getNumStubs(); uint32_t NumStubsEmitted = IS.getNumStubs();
auto &BlockList = StubOwnerItr->second; auto &BlockList = StubOwnerItr->second;
@ -309,7 +311,7 @@ private:
sys::Memory::MF_READ | sys::Memory::MF_EXEC)); sys::Memory::MF_READ | sys::Memory::MF_EXEC));
} }
Expected<std::tuple<TargetAddress, uint32_t>> handleEmitTrampolineBlock() { Expected<std::tuple<JITTargetAddress, uint32_t>> handleEmitTrampolineBlock() {
std::error_code EC; std::error_code EC;
auto TrampolineBlock = auto TrampolineBlock =
sys::OwningMemoryBlock(sys::Memory::allocateMappedMemory( sys::OwningMemoryBlock(sys::Memory::allocateMappedMemory(
@ -333,13 +335,14 @@ private:
TrampolineBlocks.push_back(std::move(TrampolineBlock)); TrampolineBlocks.push_back(std::move(TrampolineBlock));
auto TrampolineBaseAddr = auto TrampolineBaseAddr =
static_cast<TargetAddress>(reinterpret_cast<uintptr_t>(TrampolineMem)); static_cast<JITTargetAddress>(
reinterpret_cast<uintptr_t>(TrampolineMem));
return std::make_tuple(TrampolineBaseAddr, NumTrampolines); return std::make_tuple(TrampolineBaseAddr, NumTrampolines);
} }
Expected<TargetAddress> handleGetSymbolAddress(const std::string &Name) { Expected<JITTargetAddress> handleGetSymbolAddress(const std::string &Name) {
TargetAddress Addr = SymbolLookup(Name); JITTargetAddress Addr = SymbolLookup(Name);
DEBUG(dbgs() << " Symbol '" << Name << "' = " << format("0x%016x", Addr) DEBUG(dbgs() << " Symbol '" << Name << "' = " << format("0x%016x", Addr)
<< "\n"); << "\n");
return Addr; return Addr;
@ -362,7 +365,7 @@ private:
IndirectStubSize); IndirectStubSize);
} }
Expected<std::vector<char>> handleReadMem(TargetAddress RSrc, uint64_t Size) { Expected<std::vector<char>> handleReadMem(JITTargetAddress RSrc, uint64_t Size) {
char *Src = reinterpret_cast<char *>(static_cast<uintptr_t>(RSrc)); char *Src = reinterpret_cast<char *>(static_cast<uintptr_t>(RSrc));
DEBUG(dbgs() << " Reading " << Size << " bytes from " DEBUG(dbgs() << " Reading " << Size << " bytes from "
@ -376,7 +379,7 @@ private:
return Buffer; return Buffer;
} }
Error handleRegisterEHFrames(TargetAddress TAddr, uint32_t Size) { Error handleRegisterEHFrames(JITTargetAddress TAddr, uint32_t Size) {
uint8_t *Addr = reinterpret_cast<uint8_t *>(static_cast<uintptr_t>(TAddr)); uint8_t *Addr = reinterpret_cast<uint8_t *>(static_cast<uintptr_t>(TAddr));
DEBUG(dbgs() << " Registering EH frames at " << format("0x%016x", TAddr) DEBUG(dbgs() << " Registering EH frames at " << format("0x%016x", TAddr)
<< ", Size = " << Size << " bytes\n"); << ", Size = " << Size << " bytes\n");
@ -384,8 +387,8 @@ private:
return Error::success(); return Error::success();
} }
Expected<TargetAddress> handleReserveMem(ResourceIdMgr::ResourceId Id, Expected<JITTargetAddress> handleReserveMem(ResourceIdMgr::ResourceId Id,
uint64_t Size, uint32_t Align) { uint64_t Size, uint32_t Align) {
auto I = Allocators.find(Id); auto I = Allocators.find(Id);
if (I == Allocators.end()) if (I == Allocators.end())
return orcError(OrcErrorCode::RemoteAllocatorDoesNotExist); return orcError(OrcErrorCode::RemoteAllocatorDoesNotExist);
@ -397,13 +400,14 @@ private:
DEBUG(dbgs() << " Allocator " << Id << " reserved " << LocalAllocAddr DEBUG(dbgs() << " Allocator " << Id << " reserved " << LocalAllocAddr
<< " (" << Size << " bytes, alignment " << Align << ")\n"); << " (" << Size << " bytes, alignment " << Align << ")\n");
TargetAddress AllocAddr = JITTargetAddress AllocAddr =
static_cast<TargetAddress>(reinterpret_cast<uintptr_t>(LocalAllocAddr)); static_cast<JITTargetAddress>(
reinterpret_cast<uintptr_t>(LocalAllocAddr));
return AllocAddr; return AllocAddr;
} }
Error handleSetProtections(ResourceIdMgr::ResourceId Id, TargetAddress Addr, Error handleSetProtections(ResourceIdMgr::ResourceId Id, JITTargetAddress Addr,
uint32_t Flags) { uint32_t Flags) {
auto I = Allocators.find(Id); auto I = Allocators.find(Id);
if (I == Allocators.end()) if (I == Allocators.end())
@ -423,7 +427,7 @@ private:
return Error::success(); return Error::success();
} }
Error handleWritePtr(TargetAddress Addr, TargetAddress PtrVal) { Error handleWritePtr(JITTargetAddress Addr, JITTargetAddress PtrVal) {
DEBUG(dbgs() << " Writing pointer *" << format("0x%016x", Addr) << " = " DEBUG(dbgs() << " Writing pointer *" << format("0x%016x", Addr) << " = "
<< format("0x%016x", PtrVal) << "\n"); << format("0x%016x", PtrVal) << "\n");
uintptr_t *Ptr = uintptr_t *Ptr =

View File

@ -54,7 +54,7 @@ public:
// FIXME: As the RuntimeDyld fills out, additional routines will be needed // FIXME: As the RuntimeDyld fills out, additional routines will be needed
// for the varying types of objects to be allocated. // for the varying types of objects to be allocated.
class RTDyldMemoryManager : public MCJITMemoryManager, class RTDyldMemoryManager : public MCJITMemoryManager,
public RuntimeDyld::SymbolResolver { public JITSymbolResolver {
RTDyldMemoryManager(const RTDyldMemoryManager&) = delete; RTDyldMemoryManager(const RTDyldMemoryManager&) = delete;
void operator=(const RTDyldMemoryManager&) = delete; void operator=(const RTDyldMemoryManager&) = delete;
public: public:
@ -98,9 +98,8 @@ public:
/// Clients writing custom RTDyldMemoryManagers are encouraged to override /// Clients writing custom RTDyldMemoryManagers are encouraged to override
/// this method and return a SymbolInfo with the flags set correctly. This is /// this method and return a SymbolInfo with the flags set correctly. This is
/// necessary for RuntimeDyld to correctly handle weak and non-exported symbols. /// necessary for RuntimeDyld to correctly handle weak and non-exported symbols.
RuntimeDyld::SymbolInfo findSymbol(const std::string &Name) override { JITSymbol findSymbol(const std::string &Name) override {
return RuntimeDyld::SymbolInfo(getSymbolAddress(Name), return JITSymbol(getSymbolAddress(Name), JITSymbolFlags::Exported);
JITSymbolFlags::Exported);
} }
/// Legacy symbol lookup -- DEPRECATED! Please override /// Legacy symbol lookup -- DEPRECATED! Please override
@ -121,10 +120,10 @@ public:
/// Clients writing custom RTDyldMemoryManagers are encouraged to override /// Clients writing custom RTDyldMemoryManagers are encouraged to override
/// this method and return a SymbolInfo with the flags set correctly. This is /// this method and return a SymbolInfo with the flags set correctly. This is
/// necessary for RuntimeDyld to correctly handle weak and non-exported symbols. /// necessary for RuntimeDyld to correctly handle weak and non-exported symbols.
RuntimeDyld::SymbolInfo JITSymbol
findSymbolInLogicalDylib(const std::string &Name) override { findSymbolInLogicalDylib(const std::string &Name) override {
return RuntimeDyld::SymbolInfo(getSymbolAddressInLogicalDylib(Name), return JITSymbol(getSymbolAddressInLogicalDylib(Name),
JITSymbolFlags::Exported); JITSymbolFlags::Exported);
} }
/// This method returns the address of the specified function. As such it is /// This method returns the address of the specified function. As such it is

View File

@ -14,7 +14,7 @@
#ifndef LLVM_EXECUTIONENGINE_RUNTIMEDYLD_H #ifndef LLVM_EXECUTIONENGINE_RUNTIMEDYLD_H
#define LLVM_EXECUTIONENGINE_RUNTIMEDYLD_H #define LLVM_EXECUTIONENGINE_RUNTIMEDYLD_H
#include "JITSymbolFlags.h" #include "JITSymbol.h"
#include "llvm/ADT/STLExtras.h" #include "llvm/ADT/STLExtras.h"
#include "llvm/DebugInfo/DIContext.h" #include "llvm/DebugInfo/DIContext.h"
#include "llvm/Object/ObjectFile.h" #include "llvm/Object/ObjectFile.h"
@ -60,18 +60,6 @@ protected:
void reassignSectionAddress(unsigned SectionID, uint64_t Addr); void reassignSectionAddress(unsigned SectionID, uint64_t Addr);
public: public:
/// \brief Information about a named symbol.
class SymbolInfo : public JITSymbolBase {
public:
SymbolInfo(std::nullptr_t) : JITSymbolBase(JITSymbolFlags::None), Address(0) {}
SymbolInfo(uint64_t Address, JITSymbolFlags Flags)
: JITSymbolBase(Flags), Address(Address) {}
explicit operator bool() const { return Address != 0; }
uint64_t getAddress() const { return Address; }
private:
uint64_t Address;
};
/// \brief Information about the loaded object. /// \brief Information about the loaded object.
class LoadedObjectInfo : public llvm::LoadedObjectInfo { class LoadedObjectInfo : public llvm::LoadedObjectInfo {
friend class RuntimeDyldImpl; friend class RuntimeDyldImpl;
@ -189,39 +177,8 @@ public:
bool FinalizationLocked; bool FinalizationLocked;
}; };
/// \brief Symbol resolution.
class SymbolResolver {
public:
virtual ~SymbolResolver() {}
/// This method returns the address of the specified symbol if it exists
/// within the logical dynamic library represented by this
/// RTDyldMemoryManager. Unlike findSymbol, queries through this
/// interface should return addresses for hidden symbols.
///
/// This is of particular importance for the Orc JIT APIs, which support lazy
/// compilation by breaking up modules: Each of those broken out modules
/// must be able to resolve hidden symbols provided by the others. Clients
/// writing memory managers for MCJIT can usually ignore this method.
///
/// This method will be queried by RuntimeDyld when checking for previous
/// definitions of common symbols.
virtual SymbolInfo findSymbolInLogicalDylib(const std::string &Name) = 0;
/// This method returns the address of the specified function or variable.
/// It is used to resolve symbols during module linking.
///
/// If the returned symbol's address is equal to ~0ULL then RuntimeDyld will
/// skip all relocations for that symbol, and the client will be responsible
/// for handling them manually.
virtual SymbolInfo findSymbol(const std::string &Name) = 0;
private:
virtual void anchor();
};
/// \brief Construct a RuntimeDyld instance. /// \brief Construct a RuntimeDyld instance.
RuntimeDyld(MemoryManager &MemMgr, SymbolResolver &Resolver); RuntimeDyld(MemoryManager &MemMgr, JITSymbolResolver &Resolver);
~RuntimeDyld(); ~RuntimeDyld();
/// Add the referenced object file to the list of objects to be loaded and /// Add the referenced object file to the list of objects to be loaded and
@ -235,7 +192,7 @@ public:
/// Get the target address and flags for the named symbol. /// Get the target address and flags for the named symbol.
/// This address is the one used for relocation. /// This address is the one used for relocation.
SymbolInfo getSymbol(StringRef Name) const; JITEvaluatedSymbol getSymbol(StringRef Name) const;
/// Resolve the relocations for all symbols we currently know about. /// Resolve the relocations for all symbols we currently know about.
void resolveRelocations(); void resolveRelocations();
@ -295,7 +252,7 @@ private:
// interface. // interface.
std::unique_ptr<RuntimeDyldImpl> Dyld; std::unique_ptr<RuntimeDyldImpl> Dyld;
MemoryManager &MemMgr; MemoryManager &MemMgr;
SymbolResolver &Resolver; JITSymbolResolver &Resolver;
bool ProcessAllSections; bool ProcessAllSections;
RuntimeDyldCheckerImpl *Checker; RuntimeDyldCheckerImpl *Checker;
}; };

View File

@ -48,12 +48,13 @@ STATISTIC(NumGlobals , "Number of global vars initialized");
ExecutionEngine *(*ExecutionEngine::MCJITCtor)( ExecutionEngine *(*ExecutionEngine::MCJITCtor)(
std::unique_ptr<Module> M, std::string *ErrorStr, std::unique_ptr<Module> M, std::string *ErrorStr,
std::shared_ptr<MCJITMemoryManager> MemMgr, std::shared_ptr<MCJITMemoryManager> MemMgr,
std::shared_ptr<RuntimeDyld::SymbolResolver> Resolver,
std::shared_ptr<JITSymbolResolver> Resolver,
std::unique_ptr<TargetMachine> TM) = nullptr; std::unique_ptr<TargetMachine> TM) = nullptr;
ExecutionEngine *(*ExecutionEngine::OrcMCJITReplacementCtor)( ExecutionEngine *(*ExecutionEngine::OrcMCJITReplacementCtor)(
std::string *ErrorStr, std::shared_ptr<MCJITMemoryManager> MemMgr, std::string *ErrorStr, std::shared_ptr<MCJITMemoryManager> MemMgr,
std::shared_ptr<RuntimeDyld::SymbolResolver> Resolver, std::shared_ptr<JITSymbolResolver> Resolver,
std::unique_ptr<TargetMachine> TM) = nullptr; std::unique_ptr<TargetMachine> TM) = nullptr;
ExecutionEngine *(*ExecutionEngine::InterpCtor)(std::unique_ptr<Module> M, ExecutionEngine *(*ExecutionEngine::InterpCtor)(std::unique_ptr<Module> M,
@ -499,8 +500,8 @@ EngineBuilder::setMemoryManager(std::unique_ptr<MCJITMemoryManager> MM) {
} }
EngineBuilder& EngineBuilder&
EngineBuilder::setSymbolResolver(std::unique_ptr<RuntimeDyld::SymbolResolver> SR) { EngineBuilder::setSymbolResolver(std::unique_ptr<JITSymbolResolver> SR) {
Resolver = std::shared_ptr<RuntimeDyld::SymbolResolver>(std::move(SR)); Resolver = std::shared_ptr<JITSymbolResolver>(std::move(SR));
return *this; return *this;
} }

View File

@ -46,7 +46,7 @@ ExecutionEngine*
MCJIT::createJIT(std::unique_ptr<Module> M, MCJIT::createJIT(std::unique_ptr<Module> M,
std::string *ErrorStr, std::string *ErrorStr,
std::shared_ptr<MCJITMemoryManager> MemMgr, std::shared_ptr<MCJITMemoryManager> MemMgr,
std::shared_ptr<RuntimeDyld::SymbolResolver> Resolver, std::shared_ptr<JITSymbolResolver> Resolver,
std::unique_ptr<TargetMachine> TM) { std::unique_ptr<TargetMachine> TM) {
// Try to register the program as a source of symbols to resolve against. // Try to register the program as a source of symbols to resolve against.
// //
@ -67,7 +67,7 @@ MCJIT::createJIT(std::unique_ptr<Module> M,
MCJIT::MCJIT(std::unique_ptr<Module> M, std::unique_ptr<TargetMachine> TM, MCJIT::MCJIT(std::unique_ptr<Module> M, std::unique_ptr<TargetMachine> TM,
std::shared_ptr<MCJITMemoryManager> MemMgr, std::shared_ptr<MCJITMemoryManager> MemMgr,
std::shared_ptr<RuntimeDyld::SymbolResolver> Resolver) std::shared_ptr<JITSymbolResolver> Resolver)
: ExecutionEngine(TM->createDataLayout(), std::move(M)), TM(std::move(TM)), : ExecutionEngine(TM->createDataLayout(), std::move(M)), TM(std::move(TM)),
Ctx(nullptr), MemMgr(std::move(MemMgr)), Ctx(nullptr), MemMgr(std::move(MemMgr)),
Resolver(*this, std::move(Resolver)), Dyld(*this->MemMgr, this->Resolver), Resolver(*this, std::move(Resolver)), Dyld(*this->MemMgr, this->Resolver),
@ -276,14 +276,14 @@ void MCJIT::finalizeModule(Module *M) {
finalizeLoadedModules(); finalizeLoadedModules();
} }
RuntimeDyld::SymbolInfo MCJIT::findExistingSymbol(const std::string &Name) { JITSymbol MCJIT::findExistingSymbol(const std::string &Name) {
SmallString<128> FullName; SmallString<128> FullName;
Mangler::getNameWithPrefix(FullName, Name, getDataLayout()); Mangler::getNameWithPrefix(FullName, Name, getDataLayout());
if (void *Addr = getPointerToGlobalIfAvailable(FullName)) if (void *Addr = getPointerToGlobalIfAvailable(FullName))
return RuntimeDyld::SymbolInfo(static_cast<uint64_t>( return JITSymbol(static_cast<uint64_t>(
reinterpret_cast<uintptr_t>(Addr)), reinterpret_cast<uintptr_t>(Addr)),
JITSymbolFlags::Exported); JITSymbolFlags::Exported);
return Dyld.getSymbol(FullName); return Dyld.getSymbol(FullName);
} }
@ -316,8 +316,8 @@ uint64_t MCJIT::getSymbolAddress(const std::string &Name,
return findSymbol(Name, CheckFunctionsOnly).getAddress(); return findSymbol(Name, CheckFunctionsOnly).getAddress();
} }
RuntimeDyld::SymbolInfo MCJIT::findSymbol(const std::string &Name, JITSymbol MCJIT::findSymbol(const std::string &Name,
bool CheckFunctionsOnly) { bool CheckFunctionsOnly) {
MutexGuard locked(lock); MutexGuard locked(lock);
// First, check to see if we already have this symbol. // First, check to see if we already have this symbol.
@ -367,7 +367,7 @@ RuntimeDyld::SymbolInfo MCJIT::findSymbol(const std::string &Name,
if (LazyFunctionCreator) { if (LazyFunctionCreator) {
auto Addr = static_cast<uint64_t>( auto Addr = static_cast<uint64_t>(
reinterpret_cast<uintptr_t>(LazyFunctionCreator(Name))); reinterpret_cast<uintptr_t>(LazyFunctionCreator(Name)));
return RuntimeDyld::SymbolInfo(Addr, JITSymbolFlags::Exported); return JITSymbol(Addr, JITSymbolFlags::Exported);
} }
return nullptr; return nullptr;
@ -644,7 +644,7 @@ void MCJIT::NotifyFreeingObject(const object::ObjectFile& Obj) {
L->NotifyFreeingObject(Obj); L->NotifyFreeingObject(Obj);
} }
RuntimeDyld::SymbolInfo JITSymbol
LinkingSymbolResolver::findSymbol(const std::string &Name) { LinkingSymbolResolver::findSymbol(const std::string &Name) {
auto Result = ParentEngine.findSymbol(Name, false); auto Result = ParentEngine.findSymbol(Name, false);
// If the symbols wasn't found and it begins with an underscore, try again // If the symbols wasn't found and it begins with an underscore, try again

View File

@ -26,23 +26,22 @@ class MCJIT;
// functions across modules that it owns. It aggregates the memory manager // functions across modules that it owns. It aggregates the memory manager
// that is passed in to the MCJIT constructor and defers most functionality // that is passed in to the MCJIT constructor and defers most functionality
// to that object. // to that object.
class LinkingSymbolResolver : public RuntimeDyld::SymbolResolver { class LinkingSymbolResolver : public JITSymbolResolver {
public: public:
LinkingSymbolResolver(MCJIT &Parent, LinkingSymbolResolver(MCJIT &Parent,
std::shared_ptr<RuntimeDyld::SymbolResolver> Resolver) std::shared_ptr<JITSymbolResolver> Resolver)
: ParentEngine(Parent), ClientResolver(std::move(Resolver)) {} : ParentEngine(Parent), ClientResolver(std::move(Resolver)) {}
RuntimeDyld::SymbolInfo findSymbol(const std::string &Name) override; JITSymbol findSymbol(const std::string &Name) override;
// MCJIT doesn't support logical dylibs. // MCJIT doesn't support logical dylibs.
RuntimeDyld::SymbolInfo JITSymbol findSymbolInLogicalDylib(const std::string &Name) override {
findSymbolInLogicalDylib(const std::string &Name) override {
return nullptr; return nullptr;
} }
private: private:
MCJIT &ParentEngine; MCJIT &ParentEngine;
std::shared_ptr<RuntimeDyld::SymbolResolver> ClientResolver; std::shared_ptr<JITSymbolResolver> ClientResolver;
}; };
// About Module states: added->loaded->finalized. // About Module states: added->loaded->finalized.
@ -68,7 +67,7 @@ private:
class MCJIT : public ExecutionEngine { class MCJIT : public ExecutionEngine {
MCJIT(std::unique_ptr<Module> M, std::unique_ptr<TargetMachine> tm, MCJIT(std::unique_ptr<Module> M, std::unique_ptr<TargetMachine> tm,
std::shared_ptr<MCJITMemoryManager> MemMgr, std::shared_ptr<MCJITMemoryManager> MemMgr,
std::shared_ptr<RuntimeDyld::SymbolResolver> Resolver); std::shared_ptr<JITSymbolResolver> Resolver);
typedef llvm::SmallPtrSet<Module *, 4> ModulePtrSet; typedef llvm::SmallPtrSet<Module *, 4> ModulePtrSet;
@ -305,13 +304,12 @@ public:
createJIT(std::unique_ptr<Module> M, createJIT(std::unique_ptr<Module> M,
std::string *ErrorStr, std::string *ErrorStr,
std::shared_ptr<MCJITMemoryManager> MemMgr, std::shared_ptr<MCJITMemoryManager> MemMgr,
std::shared_ptr<RuntimeDyld::SymbolResolver> Resolver, std::shared_ptr<JITSymbolResolver> Resolver,
std::unique_ptr<TargetMachine> TM); std::unique_ptr<TargetMachine> TM);
// @} // @}
RuntimeDyld::SymbolInfo findSymbol(const std::string &Name, JITSymbol findSymbol(const std::string &Name, bool CheckFunctionsOnly);
bool CheckFunctionsOnly);
// DEPRECATED - Please use findSymbol instead. // DEPRECATED - Please use findSymbol instead.
// This is not directly exposed via the ExecutionEngine API, but it is // This is not directly exposed via the ExecutionEngine API, but it is
// used by the LinkingMemoryManager. // used by the LinkingMemoryManager.
@ -330,9 +328,8 @@ protected:
const RuntimeDyld::LoadedObjectInfo &L); const RuntimeDyld::LoadedObjectInfo &L);
void NotifyFreeingObject(const object::ObjectFile& Obj); void NotifyFreeingObject(const object::ObjectFile& Obj);
RuntimeDyld::SymbolInfo findExistingSymbol(const std::string &Name); JITSymbol findExistingSymbol(const std::string &Name);
Module *findModuleForSymbol(const std::string &Name, Module *findModuleForSymbol(const std::string &Name, bool CheckFunctionsOnly);
bool CheckFunctionsOnly);
}; };
} // end llvm namespace } // end llvm namespace

View File

@ -24,7 +24,7 @@ void IndirectStubsManager::anchor() {}
std::unique_ptr<JITCompileCallbackManager> std::unique_ptr<JITCompileCallbackManager>
createLocalCompileCallbackManager(const Triple &T, createLocalCompileCallbackManager(const Triple &T,
TargetAddress ErrorHandlerAddress) { JITTargetAddress ErrorHandlerAddress) {
switch (T.getArch()) { switch (T.getArch()) {
default: return nullptr; default: return nullptr;
@ -71,7 +71,7 @@ createLocalIndirectStubsManagerBuilder(const Triple &T) {
} }
} }
Constant* createIRTypedAddress(FunctionType &FT, TargetAddress Addr) { Constant* createIRTypedAddress(FunctionType &FT, JITTargetAddress Addr) {
Constant *AddrIntVal = Constant *AddrIntVal =
ConstantInt::get(Type::getInt64Ty(FT.getContext()), Addr); ConstantInt::get(Type::getInt64Ty(FT.getContext()), Addr);
Constant *AddrPtrVal = Constant *AddrPtrVal =

View File

@ -14,12 +14,11 @@
namespace llvm { namespace llvm {
namespace orc { namespace orc {
RuntimeDyld::SymbolInfo NullResolver::findSymbol(const std::string &Name) { JITSymbol NullResolver::findSymbol(const std::string &Name) {
llvm_unreachable("Unexpected cross-object symbol reference"); llvm_unreachable("Unexpected cross-object symbol reference");
} }
RuntimeDyld::SymbolInfo JITSymbol NullResolver::findSymbolInLogicalDylib(const std::string &Name) {
NullResolver::findSymbolInLogicalDylib(const std::string &Name) {
llvm_unreachable("Unexpected cross-object symbol reference"); llvm_unreachable("Unexpected cross-object symbol reference");
} }

View File

@ -44,8 +44,8 @@ private:
class GenericHandle { class GenericHandle {
public: public:
virtual ~GenericHandle() {} virtual ~GenericHandle() {}
virtual orc::JITSymbol findSymbolIn(const std::string &Name, virtual JITSymbol findSymbolIn(const std::string &Name,
bool ExportedSymbolsOnly) = 0; bool ExportedSymbolsOnly) = 0;
virtual void removeModule() = 0; virtual void removeModule() = 0;
}; };
@ -54,8 +54,8 @@ private:
GenericHandleImpl(LayerT &Layer, typename LayerT::ModuleSetHandleT Handle) GenericHandleImpl(LayerT &Layer, typename LayerT::ModuleSetHandleT Handle)
: Layer(Layer), Handle(std::move(Handle)) {} : Layer(Layer), Handle(std::move(Handle)) {}
orc::JITSymbol findSymbolIn(const std::string &Name, JITSymbol findSymbolIn(const std::string &Name,
bool ExportedSymbolsOnly) override { bool ExportedSymbolsOnly) override {
return Layer.findSymbolIn(Handle, Name, ExportedSymbolsOnly); return Layer.findSymbolIn(Handle, Name, ExportedSymbolsOnly);
} }
@ -109,55 +109,56 @@ public:
} }
template <typename PtrTy> template <typename PtrTy>
static PtrTy fromTargetAddress(orc::TargetAddress Addr) { static PtrTy fromTargetAddress(JITTargetAddress Addr) {
return reinterpret_cast<PtrTy>(static_cast<uintptr_t>(Addr)); return reinterpret_cast<PtrTy>(static_cast<uintptr_t>(Addr));
} }
orc::TargetAddress JITTargetAddress
createLazyCompileCallback(LLVMOrcLazyCompileCallbackFn Callback, createLazyCompileCallback(LLVMOrcLazyCompileCallbackFn Callback,
void *CallbackCtx) { void *CallbackCtx) {
auto CCInfo = CCMgr->getCompileCallback(); auto CCInfo = CCMgr->getCompileCallback();
CCInfo.setCompileAction([=]() -> orc::TargetAddress { CCInfo.setCompileAction([=]() -> JITTargetAddress {
return Callback(wrap(this), CallbackCtx); return Callback(wrap(this), CallbackCtx);
}); });
return CCInfo.getAddress(); return CCInfo.getAddress();
} }
LLVMOrcErrorCode createIndirectStub(StringRef StubName, LLVMOrcErrorCode createIndirectStub(StringRef StubName,
orc::TargetAddress Addr) { JITTargetAddress Addr) {
return mapError( return mapError(
IndirectStubsMgr->createStub(StubName, Addr, JITSymbolFlags::Exported)); IndirectStubsMgr->createStub(StubName, Addr, JITSymbolFlags::Exported));
} }
LLVMOrcErrorCode setIndirectStubPointer(StringRef Name, LLVMOrcErrorCode setIndirectStubPointer(StringRef Name,
orc::TargetAddress Addr) { JITTargetAddress Addr) {
return mapError(IndirectStubsMgr->updatePointer(Name, Addr)); return mapError(IndirectStubsMgr->updatePointer(Name, Addr));
} }
std::unique_ptr<RuntimeDyld::SymbolResolver> std::unique_ptr<JITSymbolResolver>
createResolver(LLVMOrcSymbolResolverFn ExternalResolver, createResolver(LLVMOrcSymbolResolverFn ExternalResolver,
void *ExternalResolverCtx) { void *ExternalResolverCtx) {
return orc::createLambdaResolver( return orc::createLambdaResolver(
[this, ExternalResolver, ExternalResolverCtx](const std::string &Name) { [this, ExternalResolver, ExternalResolverCtx](const std::string &Name)
-> JITSymbol {
// Search order: // Search order:
// 1. JIT'd symbols. // 1. JIT'd symbols.
// 2. Runtime overrides. // 2. Runtime overrides.
// 3. External resolver (if present). // 3. External resolver (if present).
if (auto Sym = CODLayer.findSymbol(Name, true)) if (auto Sym = CODLayer.findSymbol(Name, true))
return Sym.toRuntimeDyldSymbol(); return Sym;
if (auto Sym = CXXRuntimeOverrides.searchOverrides(Name)) if (auto Sym = CXXRuntimeOverrides.searchOverrides(Name))
return Sym; return Sym;
if (ExternalResolver) if (ExternalResolver)
return RuntimeDyld::SymbolInfo( return JITSymbol(
ExternalResolver(Name.c_str(), ExternalResolverCtx), ExternalResolver(Name.c_str(), ExternalResolverCtx),
llvm::JITSymbolFlags::Exported); llvm::JITSymbolFlags::Exported);
return RuntimeDyld::SymbolInfo(nullptr); return JITSymbol(nullptr);
}, },
[](const std::string &Name) { [](const std::string &Name) {
return RuntimeDyld::SymbolInfo(nullptr); return JITSymbol(nullptr);
}); });
} }
@ -222,14 +223,14 @@ public:
FreeHandleIndexes.push_back(H); FreeHandleIndexes.push_back(H);
} }
orc::JITSymbol findSymbol(const std::string &Name, bool ExportedSymbolsOnly) { JITSymbol findSymbol(const std::string &Name, bool ExportedSymbolsOnly) {
if (auto Sym = IndirectStubsMgr->findStub(Name, ExportedSymbolsOnly)) if (auto Sym = IndirectStubsMgr->findStub(Name, ExportedSymbolsOnly))
return Sym; return Sym;
return CODLayer.findSymbol(mangle(Name), ExportedSymbolsOnly); return CODLayer.findSymbol(mangle(Name), ExportedSymbolsOnly);
} }
orc::JITSymbol findSymbolIn(ModuleHandleT H, const std::string &Name, JITSymbol findSymbolIn(ModuleHandleT H, const std::string &Name,
bool ExportedSymbolsOnly) { bool ExportedSymbolsOnly) {
return GenericHandles[H]->findSymbolIn(Name, ExportedSymbolsOnly); return GenericHandles[H]->findSymbolIn(Name, ExportedSymbolsOnly);
} }

View File

@ -111,16 +111,15 @@ class OrcMCJITReplacement : public ExecutionEngine {
std::shared_ptr<MCJITMemoryManager> ClientMM; std::shared_ptr<MCJITMemoryManager> ClientMM;
}; };
class LinkingResolver : public RuntimeDyld::SymbolResolver { class LinkingResolver : public JITSymbolResolver {
public: public:
LinkingResolver(OrcMCJITReplacement &M) : M(M) {} LinkingResolver(OrcMCJITReplacement &M) : M(M) {}
RuntimeDyld::SymbolInfo findSymbol(const std::string &Name) override { JITSymbol findSymbol(const std::string &Name) override {
return M.findMangledSymbol(Name); return M.findMangledSymbol(Name);
} }
RuntimeDyld::SymbolInfo JITSymbol findSymbolInLogicalDylib(const std::string &Name) override {
findSymbolInLogicalDylib(const std::string &Name) override {
return M.ClientResolver->findSymbol(Name); return M.ClientResolver->findSymbol(Name);
} }
@ -133,7 +132,7 @@ private:
static ExecutionEngine * static ExecutionEngine *
createOrcMCJITReplacement(std::string *ErrorMsg, createOrcMCJITReplacement(std::string *ErrorMsg,
std::shared_ptr<MCJITMemoryManager> MemMgr, std::shared_ptr<MCJITMemoryManager> MemMgr,
std::shared_ptr<RuntimeDyld::SymbolResolver> Resolver, std::shared_ptr<JITSymbolResolver> Resolver,
std::unique_ptr<TargetMachine> TM) { std::unique_ptr<TargetMachine> TM) {
return new OrcMCJITReplacement(std::move(MemMgr), std::move(Resolver), return new OrcMCJITReplacement(std::move(MemMgr), std::move(Resolver),
std::move(TM)); std::move(TM));
@ -146,7 +145,7 @@ public:
OrcMCJITReplacement( OrcMCJITReplacement(
std::shared_ptr<MCJITMemoryManager> MemMgr, std::shared_ptr<MCJITMemoryManager> MemMgr,
std::shared_ptr<RuntimeDyld::SymbolResolver> ClientResolver, std::shared_ptr<JITSymbolResolver> ClientResolver,
std::unique_ptr<TargetMachine> TM) std::unique_ptr<TargetMachine> TM)
: ExecutionEngine(TM->createDataLayout()), TM(std::move(TM)), : ExecutionEngine(TM->createDataLayout()), TM(std::move(TM)),
MemMgr(*this, std::move(MemMgr)), Resolver(*this), MemMgr(*this, std::move(MemMgr)), Resolver(*this),
@ -193,7 +192,7 @@ public:
return findSymbol(Name).getAddress(); return findSymbol(Name).getAddress();
} }
RuntimeDyld::SymbolInfo findSymbol(StringRef Name) { JITSymbol findSymbol(StringRef Name) {
return findMangledSymbol(Mangle(Name)); return findMangledSymbol(Mangle(Name));
} }
@ -243,13 +242,13 @@ public:
private: private:
RuntimeDyld::SymbolInfo findMangledSymbol(StringRef Name) { JITSymbol findMangledSymbol(StringRef Name) {
if (auto Sym = LazyEmitLayer.findSymbol(Name, false)) if (auto Sym = LazyEmitLayer.findSymbol(Name, false))
return Sym.toRuntimeDyldSymbol(); return Sym;
if (auto Sym = ClientResolver->findSymbol(Name)) if (auto Sym = ClientResolver->findSymbol(Name))
return Sym; return Sym;
if (auto Sym = scanArchives(Name)) if (auto Sym = scanArchives(Name))
return Sym.toRuntimeDyldSymbol(); return Sym;
return nullptr; return nullptr;
} }
@ -346,7 +345,7 @@ private:
std::unique_ptr<TargetMachine> TM; std::unique_ptr<TargetMachine> TM;
MCJITReplacementMemMgr MemMgr; MCJITReplacementMemMgr MemMgr;
LinkingResolver Resolver; LinkingResolver Resolver;
std::shared_ptr<RuntimeDyld::SymbolResolver> ClientResolver; std::shared_ptr<JITSymbolResolver> ClientResolver;
Mangler Mang; Mangler Mang;
NotifyObjectLoadedT NotifyObjectLoaded; NotifyObjectLoadedT NotifyObjectLoaded;

View File

@ -974,10 +974,10 @@ uint64_t RuntimeDyld::LoadedObjectInfo::getSectionLoadAddress(
} }
void RuntimeDyld::MemoryManager::anchor() {} void RuntimeDyld::MemoryManager::anchor() {}
void RuntimeDyld::SymbolResolver::anchor() {} void JITSymbolResolver::anchor() {}
RuntimeDyld::RuntimeDyld(RuntimeDyld::MemoryManager &MemMgr, RuntimeDyld::RuntimeDyld(RuntimeDyld::MemoryManager &MemMgr,
RuntimeDyld::SymbolResolver &Resolver) JITSymbolResolver &Resolver)
: MemMgr(MemMgr), Resolver(Resolver) { : MemMgr(MemMgr), Resolver(Resolver) {
// FIXME: There's a potential issue lurking here if a single instance of // FIXME: There's a potential issue lurking here if a single instance of
// RuntimeDyld is used to load multiple objects. The current implementation // RuntimeDyld is used to load multiple objects. The current implementation
@ -994,8 +994,8 @@ RuntimeDyld::~RuntimeDyld() {}
static std::unique_ptr<RuntimeDyldCOFF> static std::unique_ptr<RuntimeDyldCOFF>
createRuntimeDyldCOFF(Triple::ArchType Arch, RuntimeDyld::MemoryManager &MM, createRuntimeDyldCOFF(Triple::ArchType Arch, RuntimeDyld::MemoryManager &MM,
RuntimeDyld::SymbolResolver &Resolver, JITSymbolResolver &Resolver, bool ProcessAllSections,
bool ProcessAllSections, RuntimeDyldCheckerImpl *Checker) { RuntimeDyldCheckerImpl *Checker) {
std::unique_ptr<RuntimeDyldCOFF> Dyld = std::unique_ptr<RuntimeDyldCOFF> Dyld =
RuntimeDyldCOFF::create(Arch, MM, Resolver); RuntimeDyldCOFF::create(Arch, MM, Resolver);
Dyld->setProcessAllSections(ProcessAllSections); Dyld->setProcessAllSections(ProcessAllSections);
@ -1005,8 +1005,8 @@ createRuntimeDyldCOFF(Triple::ArchType Arch, RuntimeDyld::MemoryManager &MM,
static std::unique_ptr<RuntimeDyldELF> static std::unique_ptr<RuntimeDyldELF>
createRuntimeDyldELF(RuntimeDyld::MemoryManager &MM, createRuntimeDyldELF(RuntimeDyld::MemoryManager &MM,
RuntimeDyld::SymbolResolver &Resolver, JITSymbolResolver &Resolver, bool ProcessAllSections,
bool ProcessAllSections, RuntimeDyldCheckerImpl *Checker) { RuntimeDyldCheckerImpl *Checker) {
std::unique_ptr<RuntimeDyldELF> Dyld(new RuntimeDyldELF(MM, Resolver)); std::unique_ptr<RuntimeDyldELF> Dyld(new RuntimeDyldELF(MM, Resolver));
Dyld->setProcessAllSections(ProcessAllSections); Dyld->setProcessAllSections(ProcessAllSections);
Dyld->setRuntimeDyldChecker(Checker); Dyld->setRuntimeDyldChecker(Checker);
@ -1015,7 +1015,7 @@ createRuntimeDyldELF(RuntimeDyld::MemoryManager &MM,
static std::unique_ptr<RuntimeDyldMachO> static std::unique_ptr<RuntimeDyldMachO>
createRuntimeDyldMachO(Triple::ArchType Arch, RuntimeDyld::MemoryManager &MM, createRuntimeDyldMachO(Triple::ArchType Arch, RuntimeDyld::MemoryManager &MM,
RuntimeDyld::SymbolResolver &Resolver, JITSymbolResolver &Resolver,
bool ProcessAllSections, bool ProcessAllSections,
RuntimeDyldCheckerImpl *Checker) { RuntimeDyldCheckerImpl *Checker) {
std::unique_ptr<RuntimeDyldMachO> Dyld = std::unique_ptr<RuntimeDyldMachO> Dyld =
@ -1056,7 +1056,7 @@ void *RuntimeDyld::getSymbolLocalAddress(StringRef Name) const {
return Dyld->getSymbolLocalAddress(Name); return Dyld->getSymbolLocalAddress(Name);
} }
RuntimeDyld::SymbolInfo RuntimeDyld::getSymbol(StringRef Name) const { JITEvaluatedSymbol RuntimeDyld::getSymbol(StringRef Name) const {
if (!Dyld) if (!Dyld)
return nullptr; return nullptr;
return Dyld->getSymbol(Name); return Dyld->getSymbol(Name);

View File

@ -44,7 +44,7 @@ namespace llvm {
std::unique_ptr<RuntimeDyldCOFF> std::unique_ptr<RuntimeDyldCOFF>
llvm::RuntimeDyldCOFF::create(Triple::ArchType Arch, llvm::RuntimeDyldCOFF::create(Triple::ArchType Arch,
RuntimeDyld::MemoryManager &MemMgr, RuntimeDyld::MemoryManager &MemMgr,
RuntimeDyld::SymbolResolver &Resolver) { JITSymbolResolver &Resolver) {
switch (Arch) { switch (Arch) {
default: llvm_unreachable("Unsupported target for RuntimeDyldCOFF."); default: llvm_unreachable("Unsupported target for RuntimeDyldCOFF.");
case Triple::x86: case Triple::x86:

View File

@ -33,11 +33,11 @@ public:
static std::unique_ptr<RuntimeDyldCOFF> static std::unique_ptr<RuntimeDyldCOFF>
create(Triple::ArchType Arch, RuntimeDyld::MemoryManager &MemMgr, create(Triple::ArchType Arch, RuntimeDyld::MemoryManager &MemMgr,
RuntimeDyld::SymbolResolver &Resolver); JITSymbolResolver &Resolver);
protected: protected:
RuntimeDyldCOFF(RuntimeDyld::MemoryManager &MemMgr, RuntimeDyldCOFF(RuntimeDyld::MemoryManager &MemMgr,
RuntimeDyld::SymbolResolver &Resolver) JITSymbolResolver &Resolver)
: RuntimeDyldImpl(MemMgr, Resolver) {} : RuntimeDyldImpl(MemMgr, Resolver) {}
uint64_t getSymbolOffset(const SymbolRef &Sym); uint64_t getSymbolOffset(const SymbolRef &Sym);
}; };

View File

@ -184,7 +184,7 @@ LoadedELFObjectInfo::getObjectForDebug(const ObjectFile &Obj) const {
namespace llvm { namespace llvm {
RuntimeDyldELF::RuntimeDyldELF(RuntimeDyld::MemoryManager &MemMgr, RuntimeDyldELF::RuntimeDyldELF(RuntimeDyld::MemoryManager &MemMgr,
RuntimeDyld::SymbolResolver &Resolver) JITSymbolResolver &Resolver)
: RuntimeDyldImpl(MemMgr, Resolver), GOTSectionID(0), CurrentGOTIndex(0) {} : RuntimeDyldImpl(MemMgr, Resolver), GOTSectionID(0), CurrentGOTIndex(0) {}
RuntimeDyldELF::~RuntimeDyldELF() {} RuntimeDyldELF::~RuntimeDyldELF() {}

View File

@ -159,7 +159,7 @@ class RuntimeDyldELF : public RuntimeDyldImpl {
public: public:
RuntimeDyldELF(RuntimeDyld::MemoryManager &MemMgr, RuntimeDyldELF(RuntimeDyld::MemoryManager &MemMgr,
RuntimeDyld::SymbolResolver &Resolver); JITSymbolResolver &Resolver);
~RuntimeDyldELF() override; ~RuntimeDyldELF() override;
std::unique_ptr<RuntimeDyld::LoadedObjectInfo> std::unique_ptr<RuntimeDyld::LoadedObjectInfo>

View File

@ -227,7 +227,7 @@ protected:
RuntimeDyld::MemoryManager &MemMgr; RuntimeDyld::MemoryManager &MemMgr;
// The symbol resolver to use for external symbols. // The symbol resolver to use for external symbols.
RuntimeDyld::SymbolResolver &Resolver; JITSymbolResolver &Resolver;
// Attached RuntimeDyldChecker instance. Null if no instance attached. // Attached RuntimeDyldChecker instance. Null if no instance attached.
RuntimeDyldCheckerImpl *Checker; RuntimeDyldCheckerImpl *Checker;
@ -420,7 +420,7 @@ protected:
public: public:
RuntimeDyldImpl(RuntimeDyld::MemoryManager &MemMgr, RuntimeDyldImpl(RuntimeDyld::MemoryManager &MemMgr,
RuntimeDyld::SymbolResolver &Resolver) JITSymbolResolver &Resolver)
: MemMgr(MemMgr), Resolver(Resolver), Checker(nullptr), : MemMgr(MemMgr), Resolver(Resolver), Checker(nullptr),
ProcessAllSections(false), HasError(false) { ProcessAllSections(false), HasError(false) {
} }
@ -451,7 +451,7 @@ public:
return getSectionAddress(SymInfo.getSectionID()) + SymInfo.getOffset(); return getSectionAddress(SymInfo.getSectionID()) + SymInfo.getOffset();
} }
RuntimeDyld::SymbolInfo getSymbol(StringRef Name) const { JITEvaluatedSymbol getSymbol(StringRef Name) const {
// FIXME: Just look up as a function for now. Overly simple of course. // FIXME: Just look up as a function for now. Overly simple of course.
// Work in progress. // Work in progress.
RTDyldSymbolTable::const_iterator pos = GlobalSymbolTable.find(Name); RTDyldSymbolTable::const_iterator pos = GlobalSymbolTable.find(Name);
@ -462,7 +462,7 @@ public:
if (SymEntry.getSectionID() != AbsoluteSymbolSection) if (SymEntry.getSectionID() != AbsoluteSymbolSection)
SectionAddr = getSectionLoadAddress(SymEntry.getSectionID()); SectionAddr = getSectionLoadAddress(SymEntry.getSectionID());
uint64_t TargetAddr = SectionAddr + SymEntry.getOffset(); uint64_t TargetAddr = SectionAddr + SymEntry.getOffset();
return RuntimeDyld::SymbolInfo(TargetAddr, SymEntry.getFlags()); return JITEvaluatedSymbol(TargetAddr, SymEntry.getFlags());
} }
void resolveRelocations(); void resolveRelocations();

View File

@ -343,7 +343,7 @@ void RuntimeDyldMachOCRTPBase<Impl>::registerEHFrames() {
std::unique_ptr<RuntimeDyldMachO> std::unique_ptr<RuntimeDyldMachO>
RuntimeDyldMachO::create(Triple::ArchType Arch, RuntimeDyldMachO::create(Triple::ArchType Arch,
RuntimeDyld::MemoryManager &MemMgr, RuntimeDyld::MemoryManager &MemMgr,
RuntimeDyld::SymbolResolver &Resolver) { JITSymbolResolver &Resolver) {
switch (Arch) { switch (Arch) {
default: default:
llvm_unreachable("Unsupported target for RuntimeDyldMachO."); llvm_unreachable("Unsupported target for RuntimeDyldMachO.");

View File

@ -50,7 +50,7 @@ protected:
SmallVector<EHFrameRelatedSections, 2> UnregisteredEHFrameSections; SmallVector<EHFrameRelatedSections, 2> UnregisteredEHFrameSections;
RuntimeDyldMachO(RuntimeDyld::MemoryManager &MemMgr, RuntimeDyldMachO(RuntimeDyld::MemoryManager &MemMgr,
RuntimeDyld::SymbolResolver &Resolver) JITSymbolResolver &Resolver)
: RuntimeDyldImpl(MemMgr, Resolver) {} : RuntimeDyldImpl(MemMgr, Resolver) {}
/// This convenience method uses memcpy to extract a contiguous addend (the /// This convenience method uses memcpy to extract a contiguous addend (the
@ -124,7 +124,7 @@ public:
static std::unique_ptr<RuntimeDyldMachO> static std::unique_ptr<RuntimeDyldMachO>
create(Triple::ArchType Arch, create(Triple::ArchType Arch,
RuntimeDyld::MemoryManager &MemMgr, RuntimeDyld::MemoryManager &MemMgr,
RuntimeDyld::SymbolResolver &Resolver); JITSymbolResolver &Resolver);
std::unique_ptr<RuntimeDyld::LoadedObjectInfo> std::unique_ptr<RuntimeDyld::LoadedObjectInfo>
loadObject(const object::ObjectFile &O) override; loadObject(const object::ObjectFile &O) override;
@ -152,7 +152,7 @@ private:
public: public:
RuntimeDyldMachOCRTPBase(RuntimeDyld::MemoryManager &MemMgr, RuntimeDyldMachOCRTPBase(RuntimeDyld::MemoryManager &MemMgr,
RuntimeDyld::SymbolResolver &Resolver) JITSymbolResolver &Resolver)
: RuntimeDyldMachO(MemMgr, Resolver) {} : RuntimeDyldMachO(MemMgr, Resolver) {}
Error finalizeLoad(const ObjectFile &Obj, Error finalizeLoad(const ObjectFile &Obj,

View File

@ -25,7 +25,7 @@ namespace llvm {
class RuntimeDyldCOFFI386 : public RuntimeDyldCOFF { class RuntimeDyldCOFFI386 : public RuntimeDyldCOFF {
public: public:
RuntimeDyldCOFFI386(RuntimeDyld::MemoryManager &MM, RuntimeDyldCOFFI386(RuntimeDyld::MemoryManager &MM,
RuntimeDyld::SymbolResolver &Resolver) JITSymbolResolver &Resolver)
: RuntimeDyldCOFF(MM, Resolver) {} : RuntimeDyldCOFF(MM, Resolver) {}
unsigned getMaxStubSize() override { unsigned getMaxStubSize() override {

View File

@ -25,7 +25,7 @@ namespace llvm {
class RuntimeDyldCOFFThumb : public RuntimeDyldCOFF { class RuntimeDyldCOFFThumb : public RuntimeDyldCOFF {
public: public:
RuntimeDyldCOFFThumb(RuntimeDyld::MemoryManager &MM, RuntimeDyldCOFFThumb(RuntimeDyld::MemoryManager &MM,
RuntimeDyld::SymbolResolver &Resolver) JITSymbolResolver &Resolver)
: RuntimeDyldCOFF(MM, Resolver) {} : RuntimeDyldCOFF(MM, Resolver) {}
unsigned getMaxStubSize() override { unsigned getMaxStubSize() override {

View File

@ -33,7 +33,7 @@ private:
public: public:
RuntimeDyldCOFFX86_64(RuntimeDyld::MemoryManager &MM, RuntimeDyldCOFFX86_64(RuntimeDyld::MemoryManager &MM,
RuntimeDyld::SymbolResolver &Resolver) JITSymbolResolver &Resolver)
: RuntimeDyldCOFF(MM, Resolver) {} : RuntimeDyldCOFF(MM, Resolver) {}
unsigned getMaxStubSize() override { unsigned getMaxStubSize() override {

View File

@ -24,7 +24,7 @@ public:
typedef uint64_t TargetPtrT; typedef uint64_t TargetPtrT;
RuntimeDyldMachOAArch64(RuntimeDyld::MemoryManager &MM, RuntimeDyldMachOAArch64(RuntimeDyld::MemoryManager &MM,
RuntimeDyld::SymbolResolver &Resolver) JITSymbolResolver &Resolver)
: RuntimeDyldMachOCRTPBase(MM, Resolver) {} : RuntimeDyldMachOCRTPBase(MM, Resolver) {}
unsigned getMaxStubSize() override { return 8; } unsigned getMaxStubSize() override { return 8; }

View File

@ -27,7 +27,7 @@ public:
typedef uint32_t TargetPtrT; typedef uint32_t TargetPtrT;
RuntimeDyldMachOARM(RuntimeDyld::MemoryManager &MM, RuntimeDyldMachOARM(RuntimeDyld::MemoryManager &MM,
RuntimeDyld::SymbolResolver &Resolver) JITSymbolResolver &Resolver)
: RuntimeDyldMachOCRTPBase(MM, Resolver) {} : RuntimeDyldMachOCRTPBase(MM, Resolver) {}
unsigned getMaxStubSize() override { return 8; } unsigned getMaxStubSize() override { return 8; }

View File

@ -24,7 +24,7 @@ public:
typedef uint32_t TargetPtrT; typedef uint32_t TargetPtrT;
RuntimeDyldMachOI386(RuntimeDyld::MemoryManager &MM, RuntimeDyldMachOI386(RuntimeDyld::MemoryManager &MM,
RuntimeDyld::SymbolResolver &Resolver) JITSymbolResolver &Resolver)
: RuntimeDyldMachOCRTPBase(MM, Resolver) {} : RuntimeDyldMachOCRTPBase(MM, Resolver) {}
unsigned getMaxStubSize() override { return 0; } unsigned getMaxStubSize() override { return 0; }

View File

@ -24,7 +24,7 @@ public:
typedef uint64_t TargetPtrT; typedef uint64_t TargetPtrT;
RuntimeDyldMachOX86_64(RuntimeDyld::MemoryManager &MM, RuntimeDyldMachOX86_64(RuntimeDyld::MemoryManager &MM,
RuntimeDyld::SymbolResolver &Resolver) JITSymbolResolver &Resolver)
: RuntimeDyldMachOCRTPBase(MM, Resolver) {} : RuntimeDyldMachOCRTPBase(MM, Resolver) {}
unsigned getMaxStubSize() override { return 8; } unsigned getMaxStubSize() override { return 8; }

View File

@ -101,7 +101,7 @@ CodeGenOpt::Level getOptLevel();
template <typename PtrTy> template <typename PtrTy>
static PtrTy fromTargetAddress(orc::TargetAddress Addr) { static PtrTy fromTargetAddress(JITTargetAddress Addr) {
return reinterpret_cast<PtrTy>(static_cast<uintptr_t>(Addr)); return reinterpret_cast<PtrTy>(static_cast<uintptr_t>(Addr));
} }

View File

@ -81,20 +81,20 @@ public:
// 3) Search the host process (LLI)'s symbol table. // 3) Search the host process (LLI)'s symbol table.
auto Resolver = auto Resolver =
orc::createLambdaResolver( orc::createLambdaResolver(
[this](const std::string &Name) { [this](const std::string &Name) -> JITSymbol {
if (auto Sym = CODLayer.findSymbol(Name, true)) if (auto Sym = CODLayer.findSymbol(Name, true))
return Sym.toRuntimeDyldSymbol(); return Sym;
if (auto Sym = CXXRuntimeOverrides.searchOverrides(Name)) if (auto Sym = CXXRuntimeOverrides.searchOverrides(Name))
return Sym; return Sym;
if (auto Addr = if (auto Addr =
RTDyldMemoryManager::getSymbolAddressInProcess(Name)) RTDyldMemoryManager::getSymbolAddressInProcess(Name))
return RuntimeDyld::SymbolInfo(Addr, JITSymbolFlags::Exported); return JITSymbol(Addr, JITSymbolFlags::Exported);
return RuntimeDyld::SymbolInfo(nullptr); return JITSymbol(nullptr);
}, },
[](const std::string &Name) { [](const std::string &Name) {
return RuntimeDyld::SymbolInfo(nullptr); return JITSymbol(nullptr);
} }
); );
@ -115,11 +115,11 @@ public:
return H; return H;
} }
orc::JITSymbol findSymbol(const std::string &Name) { JITSymbol findSymbol(const std::string &Name) {
return CODLayer.findSymbol(mangle(Name), true); return CODLayer.findSymbol(mangle(Name), true);
} }
orc::JITSymbol findSymbolIn(ModuleHandleT H, const std::string &Name) { JITSymbol findSymbolIn(ModuleHandleT H, const std::string &Name) {
return CODLayer.findSymbolIn(H, mangle(Name), true); return CODLayer.findSymbolIn(H, mangle(Name), true);
} }

View File

@ -83,7 +83,7 @@ public:
this->MemMgr = std::move(MemMgr); this->MemMgr = std::move(MemMgr);
} }
void setResolver(std::unique_ptr<RuntimeDyld::SymbolResolver> Resolver) { void setResolver(std::unique_ptr<JITSymbolResolver> Resolver) {
this->Resolver = std::move(Resolver); this->Resolver = std::move(Resolver);
} }
@ -134,18 +134,18 @@ public:
// Don't hide the sibling notifyObjectLoaded from RTDyldMemoryManager. // Don't hide the sibling notifyObjectLoaded from RTDyldMemoryManager.
using RTDyldMemoryManager::notifyObjectLoaded; using RTDyldMemoryManager::notifyObjectLoaded;
RuntimeDyld::SymbolInfo findSymbol(const std::string &Name) override { JITSymbol findSymbol(const std::string &Name) override {
return Resolver->findSymbol(Name); return Resolver->findSymbol(Name);
} }
RuntimeDyld::SymbolInfo JITSymbol
findSymbolInLogicalDylib(const std::string &Name) override { findSymbolInLogicalDylib(const std::string &Name) override {
return Resolver->findSymbolInLogicalDylib(Name); return Resolver->findSymbolInLogicalDylib(Name);
} }
private: private:
std::unique_ptr<RuntimeDyld::MemoryManager> MemMgr; std::unique_ptr<RuntimeDyld::MemoryManager> MemMgr;
std::unique_ptr<RuntimeDyld::SymbolResolver> Resolver; std::unique_ptr<JITSymbolResolver> Resolver;
}; };
} }

View File

@ -669,15 +669,15 @@ int main(int argc, char **argv, char * const *envp) {
[](const std::string &Name) { return nullptr; }, [](const std::string &Name) { return nullptr; },
[&](const std::string &Name) { [&](const std::string &Name) {
if (auto Addr = ExitOnErr(R.getSymbolAddress(Name))) if (auto Addr = ExitOnErr(R.getSymbolAddress(Name)))
return RuntimeDyld::SymbolInfo(Addr, JITSymbolFlags::Exported); return JITSymbol(Addr, JITSymbolFlags::Exported);
return RuntimeDyld::SymbolInfo(nullptr); return JITSymbol(nullptr);
} }
)); ));
// Grab the target address of the JIT'd main function on the remote and call // Grab the target address of the JIT'd main function on the remote and call
// it. // it.
// FIXME: argv and envp handling. // FIXME: argv and envp handling.
orc::TargetAddress Entry = EE->getFunctionAddress(EntryFn->getName().str()); JITTargetAddress Entry = EE->getFunctionAddress(EntryFn->getName().str());
EE->finalizeObject(); EE->finalizeObject();
DEBUG(dbgs() << "Executing '" << EntryFn->getName() << "' at 0x" DEBUG(dbgs() << "Executing '" << EntryFn->getName() << "' at 0x"
<< format("%llx", Entry) << "\n"); << format("%llx", Entry) << "\n");

View File

@ -165,11 +165,11 @@ public:
DummyExterns[Name] = Addr; DummyExterns[Name] = Addr;
} }
RuntimeDyld::SymbolInfo findSymbol(const std::string &Name) override { JITSymbol findSymbol(const std::string &Name) override {
auto I = DummyExterns.find(Name); auto I = DummyExterns.find(Name);
if (I != DummyExterns.end()) if (I != DummyExterns.end())
return RuntimeDyld::SymbolInfo(I->second, JITSymbolFlags::Exported); return JITSymbol(I->second, JITSymbolFlags::Exported);
return RTDyldMemoryManager::findSymbol(Name); return RTDyldMemoryManager::findSymbol(Name);
} }

View File

@ -26,7 +26,7 @@ public:
class DummyStubsManager : public orc::IndirectStubsManager { class DummyStubsManager : public orc::IndirectStubsManager {
public: public:
Error createStub(StringRef StubName, TargetAddress InitAddr, Error createStub(StringRef StubName, JITTargetAddress InitAddr,
JITSymbolFlags Flags) override { JITSymbolFlags Flags) override {
llvm_unreachable("Not implemented"); llvm_unreachable("Not implemented");
} }
@ -43,7 +43,7 @@ public:
llvm_unreachable("Not implemented"); llvm_unreachable("Not implemented");
} }
Error updatePointer(StringRef Name, TargetAddress NewAddr) override { Error updatePointer(StringRef Name, JITTargetAddress NewAddr) override {
llvm_unreachable("Not implemented"); llvm_unreachable("Not implemented");
} }
}; };

View File

@ -21,7 +21,7 @@ struct MockBaseLayer {
JITSymbol findSymbol(const std::string &Name, bool ExportedSymbolsOnly) { JITSymbol findSymbol(const std::string &Name, bool ExportedSymbolsOnly) {
if (Name == "bar") if (Name == "bar")
return llvm::orc::JITSymbol(0x4567, JITSymbolFlags::Exported); return llvm::JITSymbol(0x4567, JITSymbolFlags::Exported);
return nullptr; return nullptr;
} }
@ -37,13 +37,13 @@ TEST(GlobalMappingLayerTest, Empty) {
// Test fall-through for symbol in base layer. // Test fall-through for symbol in base layer.
auto BarSym = L.findSymbol("bar", true); auto BarSym = L.findSymbol("bar", true);
EXPECT_EQ(BarSym.getAddress(), static_cast<TargetAddress>(0x4567)) EXPECT_EQ(BarSym.getAddress(), static_cast<JITTargetAddress>(0x4567))
<< "Symbol lookup fall-through failed."; << "Symbol lookup fall-through failed.";
// Test setup of a global mapping. // Test setup of a global mapping.
L.setGlobalMapping("foo", 0x0123); L.setGlobalMapping("foo", 0x0123);
auto FooSym2 = L.findSymbol("foo", true); auto FooSym2 = L.findSymbol("foo", true);
EXPECT_EQ(FooSym2.getAddress(), static_cast<TargetAddress>(0x0123)) EXPECT_EQ(FooSym2.getAddress(), static_cast<JITTargetAddress>(0x0123))
<< "Symbol mapping setup failed."; << "Symbol mapping setup failed.";
// Test removal of a global mapping. // Test removal of a global mapping.

View File

@ -7,6 +7,7 @@
// //
//===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===//
#include "llvm/ExecutionEngine/RuntimeDyld.h"
#include "llvm/ExecutionEngine/Orc/LazyEmittingLayer.h" #include "llvm/ExecutionEngine/Orc/LazyEmittingLayer.h"
#include "gtest/gtest.h" #include "gtest/gtest.h"
@ -17,7 +18,7 @@ struct MockBaseLayer {
ModuleSetHandleT addModuleSet( ModuleSetHandleT addModuleSet(
std::list<std::unique_ptr<llvm::Module>>, std::list<std::unique_ptr<llvm::Module>>,
std::unique_ptr<llvm::RuntimeDyld::MemoryManager> MemMgr, std::unique_ptr<llvm::RuntimeDyld::MemoryManager> MemMgr,
std::unique_ptr<llvm::RuntimeDyld::SymbolResolver> Resolver) { std::unique_ptr<llvm::JITSymbolResolver> Resolver) {
EXPECT_FALSE(MemMgr); EXPECT_FALSE(MemMgr);
return 42; return 42;
} }

View File

@ -90,10 +90,10 @@ TEST(ObjectLinkingLayerTest, TestSetProcessAllSections) {
auto Resolver = auto Resolver =
createLambdaResolver( createLambdaResolver(
[](const std::string &Name) { [](const std::string &Name) {
return RuntimeDyld::SymbolInfo(nullptr); return JITSymbol(nullptr);
}, },
[](const std::string &Name) { [](const std::string &Name) {
return RuntimeDyld::SymbolInfo(nullptr); return JITSymbol(nullptr);
}); });
{ {
@ -165,11 +165,11 @@ TEST_F(ObjectLinkingLayerExecutionTest, NoDuplicateFinalization) {
createLambdaResolver( createLambdaResolver(
[&](const std::string &Name) { [&](const std::string &Name) {
if (auto Sym = ObjLayer.findSymbol(Name, true)) if (auto Sym = ObjLayer.findSymbol(Name, true))
return Sym.toRuntimeDyldSymbol(); return Sym;
return RuntimeDyld::SymbolInfo(nullptr); return JITSymbol(nullptr);
}, },
[](const std::string &Name) { [](const std::string &Name) {
return RuntimeDyld::SymbolInfo(nullptr); return JITSymbol(nullptr);
}); });
SectionMemoryManagerWrapper SMMW; SectionMemoryManagerWrapper SMMW;

View File

@ -95,31 +95,32 @@ public:
resetExpectations(); resetExpectations();
} }
JITSymbol findSymbol(const std::string &Name, bool ExportedSymbolsOnly) { llvm::JITSymbol findSymbol(const std::string &Name,
bool ExportedSymbolsOnly) {
EXPECT_EQ(MockName, Name) << "Name should pass through"; EXPECT_EQ(MockName, Name) << "Name should pass through";
EXPECT_EQ(MockBool, ExportedSymbolsOnly) << "Flag should pass through"; EXPECT_EQ(MockBool, ExportedSymbolsOnly) << "Flag should pass through";
LastCalled = "findSymbol"; LastCalled = "findSymbol";
MockSymbol = JITSymbol(122, llvm::JITSymbolFlags::None); MockSymbol = llvm::JITSymbol(122, llvm::JITSymbolFlags::None);
return MockSymbol; return MockSymbol;
} }
void expectFindSymbol(const std::string &Name, bool ExportedSymbolsOnly) { void expectFindSymbol(const std::string &Name, bool ExportedSymbolsOnly) {
MockName = Name; MockName = Name;
MockBool = ExportedSymbolsOnly; MockBool = ExportedSymbolsOnly;
} }
void verifyFindSymbol(llvm::orc::JITSymbol Returned) { void verifyFindSymbol(llvm::JITSymbol Returned) {
EXPECT_EQ("findSymbol", LastCalled); EXPECT_EQ("findSymbol", LastCalled);
EXPECT_EQ(MockSymbol.getAddress(), Returned.getAddress()) EXPECT_EQ(MockSymbol.getAddress(), Returned.getAddress())
<< "Return should pass through"; << "Return should pass through";
resetExpectations(); resetExpectations();
} }
JITSymbol findSymbolIn(ObjSetHandleT H, const std::string &Name, llvm::JITSymbol findSymbolIn(ObjSetHandleT H, const std::string &Name,
bool ExportedSymbolsOnly) { bool ExportedSymbolsOnly) {
EXPECT_EQ(MockObjSetHandle, H) << "Handle should pass through"; EXPECT_EQ(MockObjSetHandle, H) << "Handle should pass through";
EXPECT_EQ(MockName, Name) << "Name should pass through"; EXPECT_EQ(MockName, Name) << "Name should pass through";
EXPECT_EQ(MockBool, ExportedSymbolsOnly) << "Flag should pass through"; EXPECT_EQ(MockBool, ExportedSymbolsOnly) << "Flag should pass through";
LastCalled = "findSymbolIn"; LastCalled = "findSymbolIn";
MockSymbol = JITSymbol(122, llvm::JITSymbolFlags::None); MockSymbol = llvm::JITSymbol(122, llvm::JITSymbolFlags::None);
return MockSymbol; return MockSymbol;
} }
void expectFindSymbolIn(ObjSetHandleT H, const std::string &Name, void expectFindSymbolIn(ObjSetHandleT H, const std::string &Name,
@ -128,7 +129,7 @@ public:
MockName = Name; MockName = Name;
MockBool = ExportedSymbolsOnly; MockBool = ExportedSymbolsOnly;
} }
void verifyFindSymbolIn(llvm::orc::JITSymbol Returned) { void verifyFindSymbolIn(llvm::JITSymbol Returned) {
EXPECT_EQ("findSymbolIn", LastCalled); EXPECT_EQ("findSymbolIn", LastCalled);
EXPECT_EQ(MockSymbol.getAddress(), Returned.getAddress()) EXPECT_EQ(MockSymbol.getAddress(), Returned.getAddress())
<< "Return should pass through"; << "Return should pass through";
@ -146,14 +147,14 @@ public:
} }
void mapSectionAddress(ObjSetHandleT H, const void *LocalAddress, void mapSectionAddress(ObjSetHandleT H, const void *LocalAddress,
TargetAddress TargetAddr) { llvm::JITTargetAddress TargetAddr) {
EXPECT_EQ(MockObjSetHandle, H); EXPECT_EQ(MockObjSetHandle, H);
EXPECT_EQ(MockLocalAddress, LocalAddress); EXPECT_EQ(MockLocalAddress, LocalAddress);
EXPECT_EQ(MockTargetAddress, TargetAddr); EXPECT_EQ(MockTargetAddress, TargetAddr);
LastCalled = "mapSectionAddress"; LastCalled = "mapSectionAddress";
} }
void expectMapSectionAddress(ObjSetHandleT H, const void *LocalAddress, void expectMapSectionAddress(ObjSetHandleT H, const void *LocalAddress,
TargetAddress TargetAddr) { llvm::JITTargetAddress TargetAddr) {
MockObjSetHandle = H; MockObjSetHandle = H;
MockLocalAddress = LocalAddress; MockLocalAddress = LocalAddress;
MockTargetAddress = TargetAddr; MockTargetAddress = TargetAddr;
@ -172,9 +173,9 @@ private:
ObjSetHandleT MockObjSetHandle; ObjSetHandleT MockObjSetHandle;
std::string MockName; std::string MockName;
bool MockBool; bool MockBool;
JITSymbol MockSymbol; llvm::JITSymbol MockSymbol;
const void *MockLocalAddress; const void *MockLocalAddress;
TargetAddress MockTargetAddress; llvm::JITTargetAddress MockTargetAddress;
MockMemoryBufferSet MockBufferSet; MockMemoryBufferSet MockBufferSet;
// Clear remembered parameters between calls // Clear remembered parameters between calls
@ -185,7 +186,7 @@ private:
MockObjects.clear(); MockObjects.clear();
MockObjSetHandle = 0; MockObjSetHandle = 0;
MockName = "bogus"; MockName = "bogus";
MockSymbol = JITSymbol(nullptr); MockSymbol = llvm::JITSymbol(nullptr);
MockLocalAddress = nullptr; MockLocalAddress = nullptr;
MockTargetAddress = 0; MockTargetAddress = 0;
MockBufferSet = 0; MockBufferSet = 0;
@ -245,7 +246,7 @@ TEST(ObjectTransformLayerTest, Main) {
std::string Name = "foo"; std::string Name = "foo";
bool ExportedOnly = true; bool ExportedOnly = true;
M.expectFindSymbol(Name, ExportedOnly); M.expectFindSymbol(Name, ExportedOnly);
JITSymbol Symbol = T2.findSymbol(Name, ExportedOnly); llvm::JITSymbol Symbol = T2.findSymbol(Name, ExportedOnly);
M.verifyFindSymbol(Symbol); M.verifyFindSymbol(Symbol);
// Test findSymbolIn // Test findSymbolIn
@ -262,7 +263,7 @@ TEST(ObjectTransformLayerTest, Main) {
// Test mapSectionAddress // Test mapSectionAddress
char Buffer[24]; char Buffer[24];
TargetAddress MockAddress = 255; llvm::JITTargetAddress MockAddress = 255;
M.expectMapSectionAddress(H, Buffer, MockAddress); M.expectMapSectionAddress(H, Buffer, MockAddress);
T1.mapSectionAddress(H, Buffer, MockAddress); T1.mapSectionAddress(H, Buffer, MockAddress);
M.verifyMapSectionAddress(); M.verifyMapSectionAddress();

View File

@ -22,7 +22,7 @@
#include "llvm/IR/TypeBuilder.h" #include "llvm/IR/TypeBuilder.h"
#include "llvm/Object/ObjectFile.h" #include "llvm/Object/ObjectFile.h"
#include "llvm/ExecutionEngine/ExecutionEngine.h" #include "llvm/ExecutionEngine/ExecutionEngine.h"
#include "llvm/ExecutionEngine/Orc/JITSymbol.h" #include "llvm/ExecutionEngine/JITSymbol.h"
#include "llvm/Support/TargetSelect.h" #include "llvm/Support/TargetSelect.h"
#include <memory> #include <memory>
@ -124,11 +124,11 @@ public:
RemoveModuleSet(H); RemoveModuleSet(H);
} }
orc::JITSymbol findSymbol(const std::string &Name, bool ExportedSymbolsOnly) { JITSymbol findSymbol(const std::string &Name, bool ExportedSymbolsOnly) {
return FindSymbol(Name, ExportedSymbolsOnly); return FindSymbol(Name, ExportedSymbolsOnly);
} }
orc::JITSymbol findSymbolIn(ModuleSetHandleT H, const std::string &Name, JITSymbol findSymbolIn(ModuleSetHandleT H, const std::string &Name,
bool ExportedSymbolsOnly) { bool ExportedSymbolsOnly) {
return FindSymbolIn(H, Name, ExportedSymbolsOnly); return FindSymbolIn(H, Name, ExportedSymbolsOnly);
} }