1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2025-01-31 20:51:52 +01:00

[ORC] Create a new SymbolStringPool by default in ExecutionSession constructor.

This makes the common case of constructing an ExecutionSession tidier.

llvm-svn: 329013
This commit is contained in:
Lang Hames 2018-04-02 20:57:56 +00:00
parent da573c6edd
commit 9f659ebeb6
16 changed files with 29 additions and 57 deletions

View File

@ -38,7 +38,6 @@ namespace orc {
class KaleidoscopeJIT {
private:
SymbolStringPool SSP;
ExecutionSession ES;
std::shared_ptr<SymbolResolver> Resolver;
std::unique_ptr<TargetMachine> TM;
@ -48,8 +47,7 @@ private:
public:
KaleidoscopeJIT()
: ES(SSP),
Resolver(createLegacyLookupResolver(
: Resolver(createLegacyLookupResolver(
[this](const std::string &Name) -> JITSymbol {
if (auto Sym = CompileLayer.findSymbol(Name, false))
return Sym;

View File

@ -42,7 +42,6 @@ namespace orc {
class KaleidoscopeJIT {
private:
SymbolStringPool SSP;
ExecutionSession ES;
std::shared_ptr<SymbolResolver> Resolver;
std::unique_ptr<TargetMachine> TM;
@ -57,8 +56,7 @@ private:
public:
KaleidoscopeJIT()
: ES(SSP),
Resolver(createLegacyLookupResolver(
: Resolver(createLegacyLookupResolver(
[this](const std::string &Name) -> JITSymbol {
if (auto Sym = OptimizeLayer.findSymbol(Name, false))
return Sym;

View File

@ -46,7 +46,6 @@ namespace orc {
class KaleidoscopeJIT {
private:
SymbolStringPool SSP;
ExecutionSession ES;
std::map<VModuleKey, std::shared_ptr<SymbolResolver>> Resolvers;
std::unique_ptr<TargetMachine> TM;
@ -64,7 +63,7 @@ private:
public:
KaleidoscopeJIT()
: ES(SSP), TM(EngineBuilder().selectTarget()), DL(TM->createDataLayout()),
: TM(EngineBuilder().selectTarget()), DL(TM->createDataLayout()),
ObjectLayer(ES,
[this](VModuleKey K) {
return RTDyldObjectLinkingLayer::Resources{

View File

@ -72,7 +72,6 @@ namespace orc {
class KaleidoscopeJIT {
private:
SymbolStringPool SSP;
ExecutionSession ES;
std::shared_ptr<SymbolResolver> Resolver;
std::unique_ptr<TargetMachine> TM;
@ -90,8 +89,7 @@ private:
public:
KaleidoscopeJIT()
: ES(SSP),
Resolver(createLegacyLookupResolver(
: Resolver(createLegacyLookupResolver(
[this](const std::string &Name) -> JITSymbol {
if (auto Sym = IndirectStubsMgr->findStub(Name, false))
return Sym;

View File

@ -77,7 +77,6 @@ using MyRemote = remote::OrcRemoteTargetClient;
class KaleidoscopeJIT {
private:
SymbolStringPool SSP;
ExecutionSession ES;
std::shared_ptr<SymbolResolver> Resolver;
std::unique_ptr<TargetMachine> TM;
@ -96,8 +95,7 @@ private:
public:
KaleidoscopeJIT(MyRemote &Remote)
: ES(SSP),
Resolver(createLegacyLookupResolver(
: Resolver(createLegacyLookupResolver(
[this](const std::string &Name) -> JITSymbol {
if (auto Sym = IndirectStubsMgr->findStub(Name, false))
return Sym;

View File

@ -44,8 +44,7 @@ public:
using CompileLayerT = IRCompileLayer<ObjLayerT, SimpleCompiler>;
KaleidoscopeJIT()
: ES(SSP),
Resolver(createLegacyLookupResolver(
: Resolver(createLegacyLookupResolver(
[this](const std::string &Name) {
return ObjectLayer.findSymbol(Name, true);
},
@ -126,7 +125,6 @@ private:
return nullptr;
}
SymbolStringPool SSP;
ExecutionSession ES;
std::shared_ptr<SymbolResolver> Resolver;
std::unique_ptr<TargetMachine> TM;

View File

@ -327,10 +327,11 @@ public:
/// @brief Construct an ExecutionEngine.
///
/// SymbolStringPools may be shared between ExecutionSessions.
ExecutionSession(SymbolStringPool &SSP);
ExecutionSession(std::shared_ptr<SymbolStringPool> SSP = nullptr)
: SSP(std::move(SSP)) {}
/// @brief Returns the SymbolStringPool for this ExecutionSession.
SymbolStringPool &getSymbolStringPool() const { return SSP; }
SymbolStringPool &getSymbolStringPool() const { return *SSP; }
/// @brief Set the error reporter function.
void setErrorReporter(ErrorReporter ReportError) {
@ -343,17 +344,17 @@ public:
void reportError(Error Err) { ReportError(std::move(Err)); }
/// @brief Allocate a module key for a new module to add to the JIT.
VModuleKey allocateVModule();
VModuleKey allocateVModule() { return ++LastKey; }
/// @brief Return a module key to the ExecutionSession so that it can be
/// re-used. This should only be done once all resources associated
//// with the original key have been released.
void releaseVModule(VModuleKey Key);
void releaseVModule(VModuleKey Key) { /* FIXME: Recycle keys */ }
public:
static void logErrorsToStdErr(Error Err);
SymbolStringPool &SSP;
std::shared_ptr<SymbolStringPool> SSP;
VModuleKey LastKey = 0;
ErrorReporter ReportError = logErrorsToStdErr;
};

View File

@ -526,14 +526,6 @@ lookup(const std::vector<VSO *> VSOs, SymbolStringPtr Name,
return ResultMap.takeError();
}
ExecutionSession::ExecutionSession(SymbolStringPool &SSP) : SSP(SSP) {}
VModuleKey ExecutionSession::allocateVModule() { return ++LastKey; }
void ExecutionSession::releaseVModule(VModuleKey VMod) {
// FIXME: Recycle keys.
}
void ExecutionSession::logErrorsToStdErr(Error Err) {
logAllUnhandledErrors(std::move(Err), errs(), "JIT session error: ");
}

View File

@ -200,7 +200,7 @@ public:
OrcCBindingsStack(TargetMachine &TM,
std::unique_ptr<CompileCallbackMgr> CCMgr,
IndirectStubsManagerBuilder IndirectStubsMgrBuilder)
: ES(SSP), DL(TM.createDataLayout()),
: DL(TM.createDataLayout()),
IndirectStubsMgr(IndirectStubsMgrBuilder()), CCMgr(std::move(CCMgr)),
ObjectLayer(ES,
[this](orc::VModuleKey K) {
@ -421,7 +421,6 @@ private:
logAllUnhandledErrors(std::move(Err), errs(), "ORC error: ");
};
orc::SymbolStringPool SSP;
orc::ExecutionSession ES;
DataLayout DL;

View File

@ -225,7 +225,8 @@ public:
OrcMCJITReplacement(std::shared_ptr<MCJITMemoryManager> MemMgr,
std::shared_ptr<LegacyJITSymbolResolver> ClientResolver,
std::unique_ptr<TargetMachine> TM)
: ExecutionEngine(TM->createDataLayout()), ES(SSP), TM(std::move(TM)),
: ExecutionEngine(TM->createDataLayout()),
TM(std::move(TM)),
MemMgr(
std::make_shared<MCJITReplacementMemMgr>(*this, std::move(MemMgr))),
Resolver(std::make_shared<LinkingORCResolver>(*this)),
@ -450,7 +451,6 @@ private:
using CompileLayerT = IRCompileLayer<ObjectLayerT, orc::SimpleCompiler>;
using LazyEmitLayerT = LazyEmittingLayer<CompileLayerT>;
SymbolStringPool SSP;
ExecutionSession ES;
std::unique_ptr<TargetMachine> TM;

View File

@ -60,7 +60,8 @@ public:
std::unique_ptr<CompileCallbackMgr> CCMgr,
IndirectStubsManagerBuilder IndirectStubsMgrBuilder,
bool InlineStubs)
: ES(SSP), TM(std::move(TM)), DL(this->TM->createDataLayout()),
: TM(std::move(TM)),
DL(this->TM->createDataLayout()),
CCMgr(std::move(CCMgr)),
ObjectLayer(ES,
[this](orc::VModuleKey K) {

View File

@ -59,8 +59,7 @@ TEST(CompileOnDemandLayerTest, FindSymbol) {
DummyCallbackManager CallbackMgr;
SymbolStringPool SSP;
ExecutionSession ES(SSP);
ExecutionSession ES(std::make_shared<SymbolStringPool>());
auto GetResolver =
[](orc::VModuleKey) -> std::shared_ptr<llvm::orc::SymbolResolver> {

View File

@ -335,8 +335,8 @@ TEST(CoreAPIsTest, TestLookupWithUnthreadedMaterialization) {
constexpr JITTargetAddress FakeFooAddr = 0xdeadbeef;
JITEvaluatedSymbol FooSym(FakeFooAddr, JITSymbolFlags::Exported);
SymbolStringPool SSP;
auto Foo = SSP.intern("foo");
ExecutionSession ES(std::make_shared<SymbolStringPool>());
auto Foo = ES.getSymbolStringPool().intern("foo");
auto MU = llvm::make_unique<SimpleMaterializationUnit>(
[=]() {
@ -355,7 +355,6 @@ TEST(CoreAPIsTest, TestLookupWithUnthreadedMaterialization) {
cantFail(V.defineLazy(std::move(MU)));
ExecutionSession ES(SSP);
auto FooLookupResult =
cantFail(lookup({&V}, Foo, MaterializeOnCurrentThread(ES)));
@ -370,8 +369,8 @@ TEST(CoreAPIsTest, TestLookupWithThreadedMaterialization) {
constexpr JITTargetAddress FakeFooAddr = 0xdeadbeef;
JITEvaluatedSymbol FooSym(FakeFooAddr, JITSymbolFlags::Exported);
SymbolStringPool SSP;
auto Foo = SSP.intern("foo");
ExecutionSession ES(std::make_shared<SymbolStringPool>());
auto Foo = ES.getSymbolStringPool().intern("foo");
auto MU = llvm::make_unique<SimpleMaterializationUnit>(
[=]() {
@ -390,8 +389,6 @@ TEST(CoreAPIsTest, TestLookupWithThreadedMaterialization) {
cantFail(V.defineLazy(std::move(MU)));
ExecutionSession ES(SSP);
std::thread MaterializationThread;
auto MaterializeOnNewThread = [&](VSO &V,
std::unique_ptr<MaterializationUnit> MU) {

View File

@ -18,9 +18,8 @@ namespace {
TEST(LegacyAPIInteropTest, QueryAgainstVSO) {
SymbolStringPool SP;
ExecutionSession ES(SP);
auto Foo = SP.intern("foo");
ExecutionSession ES(std::make_shared<SymbolStringPool>());
auto Foo = ES.getSymbolStringPool().intern("foo");
VSO V;
SymbolMap Defs;

View File

@ -179,8 +179,7 @@ private:
TEST(ObjectTransformLayerTest, Main) {
MockBaseLayer M;
SymbolStringPool SSP;
ExecutionSession ES(SSP);
ExecutionSession ES(std::make_shared<SymbolStringPool>());
// Create one object transform layer using a transform (as a functor)
// that allocates new objects, and deals in unique pointers.

View File

@ -67,8 +67,7 @@ TEST(RTDyldObjectLinkingLayerTest, TestSetProcessAllSections) {
bool DebugSectionSeen = false;
auto MM = std::make_shared<MemoryManagerWrapper>(DebugSectionSeen);
SymbolStringPool SSP;
ExecutionSession ES(SSP);
ExecutionSession ES(std::make_shared<SymbolStringPool>());
RTDyldObjectLinkingLayer ObjLayer(ES, [&MM](VModuleKey) {
return RTDyldObjectLinkingLayer::Resources{
@ -124,8 +123,7 @@ TEST_F(RTDyldObjectLinkingLayerExecutionTest, NoDuplicateFinalization) {
if (!SupportsJIT)
return;
SymbolStringPool SSP;
ExecutionSession ES(SSP);
ExecutionSession ES(std::make_shared<SymbolStringPool>());
auto MM = std::make_shared<SectionMemoryManagerWrapper>();
@ -209,8 +207,7 @@ TEST_F(RTDyldObjectLinkingLayerExecutionTest, NoPrematureAllocation) {
if (!SupportsJIT)
return;
SymbolStringPool SSP;
ExecutionSession ES(SSP);
ExecutionSession ES(std::make_shared<SymbolStringPool>());
auto MM = std::make_shared<SectionMemoryManagerWrapper>();
@ -271,8 +268,7 @@ TEST_F(RTDyldObjectLinkingLayerExecutionTest, NoPrematureAllocation) {
}
TEST_F(RTDyldObjectLinkingLayerExecutionTest, TestNotifyLoadedSignature) {
SymbolStringPool SSP;
ExecutionSession ES(SSP);
ExecutionSession ES(std::make_shared<SymbolStringPool>());
RTDyldObjectLinkingLayer ObjLayer(
ES,
[](VModuleKey) {