[llvm] r322914 - [ORC] Revert r322913 while I investigate an ASan failure.
Lang Hames via llvm-commits
llvm-commits at lists.llvm.org
Thu Jan 18 17:40:26 PST 2018
Author: lhames
Date: Thu Jan 18 17:40:26 2018
New Revision: 322914
URL: http://llvm.org/viewvc/llvm-project?rev=322914&view=rev
Log:
[ORC] Revert r322913 while I investigate an ASan failure.
Modified:
llvm/trunk/include/llvm/ExecutionEngine/ExecutionEngine.h
llvm/trunk/include/llvm/ExecutionEngine/JITSymbol.h
llvm/trunk/include/llvm/ExecutionEngine/Orc/CompileOnDemandLayer.h
llvm/trunk/include/llvm/ExecutionEngine/Orc/LambdaResolver.h
llvm/trunk/include/llvm/ExecutionEngine/Orc/NullResolver.h
llvm/trunk/include/llvm/ExecutionEngine/Orc/RemoteObjectLayer.h
llvm/trunk/include/llvm/ExecutionEngine/RTDyldMemoryManager.h
llvm/trunk/lib/ExecutionEngine/ExecutionEngine.cpp
llvm/trunk/lib/ExecutionEngine/MCJIT/MCJIT.cpp
llvm/trunk/lib/ExecutionEngine/MCJIT/MCJIT.h
llvm/trunk/lib/ExecutionEngine/Orc/OrcCBindingsStack.h
llvm/trunk/lib/ExecutionEngine/Orc/OrcMCJITReplacement.h
llvm/trunk/lib/ExecutionEngine/RuntimeDyld/JITSymbol.cpp
llvm/trunk/lib/ExecutionEngine/RuntimeDyld/RuntimeDyld.cpp
llvm/trunk/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldChecker.cpp
llvm/trunk/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldImpl.h
llvm/trunk/tools/lli/RemoteJITUtils.h
Modified: llvm/trunk/include/llvm/ExecutionEngine/ExecutionEngine.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/ExecutionEngine/ExecutionEngine.h?rev=322914&r1=322913&r2=322914&view=diff
==============================================================================
--- llvm/trunk/include/llvm/ExecutionEngine/ExecutionEngine.h (original)
+++ llvm/trunk/include/llvm/ExecutionEngine/ExecutionEngine.h Thu Jan 18 17:40:26 2018
@@ -137,15 +137,17 @@ protected:
virtual char *getMemoryForGV(const GlobalVariable *GV);
static ExecutionEngine *(*MCJITCtor)(
- std::unique_ptr<Module> M, std::string *ErrorStr,
- std::shared_ptr<MCJITMemoryManager> MM,
- std::shared_ptr<LegacyJITSymbolResolver> SR,
- std::unique_ptr<TargetMachine> TM);
+ std::unique_ptr<Module> M,
+ std::string *ErrorStr,
+ std::shared_ptr<MCJITMemoryManager> MM,
+ std::shared_ptr<JITSymbolResolver> SR,
+ std::unique_ptr<TargetMachine> TM);
static ExecutionEngine *(*OrcMCJITReplacementCtor)(
- std::string *ErrorStr, std::shared_ptr<MCJITMemoryManager> MM,
- std::shared_ptr<LegacyJITSymbolResolver> SR,
- std::unique_ptr<TargetMachine> TM);
+ std::string *ErrorStr,
+ std::shared_ptr<MCJITMemoryManager> MM,
+ std::shared_ptr<JITSymbolResolver> SR,
+ std::unique_ptr<TargetMachine> TM);
static ExecutionEngine *(*InterpCtor)(std::unique_ptr<Module> M,
std::string *ErrorStr);
@@ -530,7 +532,7 @@ private:
std::string *ErrorStr;
CodeGenOpt::Level OptLevel;
std::shared_ptr<MCJITMemoryManager> MemMgr;
- std::shared_ptr<LegacyJITSymbolResolver> Resolver;
+ std::shared_ptr<JITSymbolResolver> Resolver;
TargetOptions Options;
Optional<Reloc::Model> RelocModel;
Optional<CodeModel::Model> CMModel;
@@ -569,7 +571,8 @@ public:
EngineBuilder&
setMemoryManager(std::unique_ptr<MCJITMemoryManager> MM);
- EngineBuilder &setSymbolResolver(std::unique_ptr<LegacyJITSymbolResolver> SR);
+ EngineBuilder&
+ setSymbolResolver(std::unique_ptr<JITSymbolResolver> SR);
/// setErrorStr - Set the error string to write to on error. This option
/// defaults to NULL.
Modified: llvm/trunk/include/llvm/ExecutionEngine/JITSymbol.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/ExecutionEngine/JITSymbol.h?rev=322914&r1=322913&r2=322914&view=diff
==============================================================================
--- llvm/trunk/include/llvm/ExecutionEngine/JITSymbol.h (original)
+++ llvm/trunk/include/llvm/ExecutionEngine/JITSymbol.h Thu Jan 18 17:40:26 2018
@@ -19,11 +19,8 @@
#include <cstddef>
#include <cstdint>
#include <functional>
-#include <map>
-#include <set>
#include <string>
-#include "llvm/ADT/StringRef.h"
#include "llvm/Support/Error.h"
namespace llvm {
@@ -272,50 +269,11 @@ private:
JITSymbolFlags Flags;
};
-/// @brief Symbol resolution interface.
-///
-/// Allows symbol flags and addresses to be looked up by name.
-/// Symbol queries are done in bulk (i.e. you request resolution of a set of
-/// symbols, rather than a single one) to reduce IPC overhead in the case of
-/// remote JITing, and expose opportunities for parallel compilation.
+/// \brief Symbol resolution.
class JITSymbolResolver {
public:
- using SymbolNameSet = std::set<StringRef>;
- using LookupResult = std::map<StringRef, JITEvaluatedSymbol>;
- using LookupFlagsResult = std::map<StringRef, JITSymbolFlags>;
-
virtual ~JITSymbolResolver() = default;
- /// @brief Returns the fully resolved address and flags for each of the given
- /// symbols.
- ///
- /// This method will return an error if any of the given symbols can not be
- /// resolved, or if the resolution process itself triggers an error.
- virtual Expected<LookupResult> lookup(const SymbolNameSet &Symbols) = 0;
-
- /// @brief Returns the symbol flags for each of the given symbols.
- ///
- /// This method does NOT return an error if any of the given symbols is
- /// missing. Instead, that symbol will be left out of the result map.
- virtual Expected<LookupFlagsResult>
- lookupFlags(const SymbolNameSet &Symbols) = 0;
-
-private:
- virtual void anchor();
-};
-
-/// \brief Legacy symbol resolution interface.
-class LegacyJITSymbolResolver : public JITSymbolResolver {
-public:
- /// @brief Performs lookup by, for each symbol, first calling
- /// findSymbolInLogicalDylib and if that fails calling
- /// findSymbol.
- Expected<LookupResult> lookup(const SymbolNameSet &Symbols) final;
-
- /// @brief Performs flags lookup by calling findSymbolInLogicalDylib and
- /// returning the flags value for that symbol.
- Expected<LookupFlagsResult> lookupFlags(const SymbolNameSet &Symbols) final;
-
/// 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
Modified: llvm/trunk/include/llvm/ExecutionEngine/Orc/CompileOnDemandLayer.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/ExecutionEngine/Orc/CompileOnDemandLayer.h?rev=322914&r1=322913&r2=322914&view=diff
==============================================================================
--- llvm/trunk/include/llvm/ExecutionEngine/Orc/CompileOnDemandLayer.h (original)
+++ llvm/trunk/include/llvm/ExecutionEngine/Orc/CompileOnDemandLayer.h Thu Jan 18 17:40:26 2018
@@ -183,7 +183,7 @@ private:
return Error::success();
}
- std::shared_ptr<LegacyJITSymbolResolver> ExternalSymbolResolver;
+ std::shared_ptr<JITSymbolResolver> ExternalSymbolResolver;
std::unique_ptr<IndirectStubsMgrT> StubsMgr;
StaticGlobalRenamer StaticRenamer;
SourceModulesList SourceModules;
@@ -223,7 +223,7 @@ public:
/// @brief Add a module to the compile-on-demand layer.
Expected<ModuleHandleT>
addModule(std::shared_ptr<Module> M,
- std::shared_ptr<LegacyJITSymbolResolver> Resolver) {
+ std::shared_ptr<JITSymbolResolver> Resolver) {
LogicalDylibs.push_back(LogicalDylib());
auto &LD = LogicalDylibs.back();
Modified: llvm/trunk/include/llvm/ExecutionEngine/Orc/LambdaResolver.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/ExecutionEngine/Orc/LambdaResolver.h?rev=322914&r1=322913&r2=322914&view=diff
==============================================================================
--- llvm/trunk/include/llvm/ExecutionEngine/Orc/LambdaResolver.h (original)
+++ llvm/trunk/include/llvm/ExecutionEngine/Orc/LambdaResolver.h Thu Jan 18 17:40:26 2018
@@ -23,7 +23,7 @@ namespace llvm {
namespace orc {
template <typename DylibLookupFtorT, typename ExternalLookupFtorT>
-class LambdaResolver : public LegacyJITSymbolResolver {
+class LambdaResolver : public JITSymbolResolver {
public:
LambdaResolver(DylibLookupFtorT DylibLookupFtor,
ExternalLookupFtorT ExternalLookupFtor)
Modified: llvm/trunk/include/llvm/ExecutionEngine/Orc/NullResolver.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/ExecutionEngine/Orc/NullResolver.h?rev=322914&r1=322913&r2=322914&view=diff
==============================================================================
--- llvm/trunk/include/llvm/ExecutionEngine/Orc/NullResolver.h (original)
+++ llvm/trunk/include/llvm/ExecutionEngine/Orc/NullResolver.h Thu Jan 18 17:40:26 2018
@@ -22,7 +22,7 @@ namespace orc {
/// SymbolResolver impliementation that rejects all resolution requests.
/// Useful for clients that have no cross-object fixups.
-class NullResolver : public LegacyJITSymbolResolver {
+class NullResolver : public JITSymbolResolver {
public:
JITSymbol findSymbol(const std::string &Name) final;
Modified: llvm/trunk/include/llvm/ExecutionEngine/Orc/RemoteObjectLayer.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/ExecutionEngine/Orc/RemoteObjectLayer.h?rev=322914&r1=322913&r2=322914&view=diff
==============================================================================
--- llvm/trunk/include/llvm/ExecutionEngine/Orc/RemoteObjectLayer.h (original)
+++ llvm/trunk/include/llvm/ExecutionEngine/Orc/RemoteObjectLayer.h Thu Jan 18 17:40:26 2018
@@ -328,8 +328,7 @@ public:
/// @return A handle that can be used to refer to the loaded object (for
/// symbol searching, finalization, freeing memory, etc.).
Expected<ObjHandleT>
- addObject(ObjectPtr Object,
- std::shared_ptr<LegacyJITSymbolResolver> Resolver) {
+ addObject(ObjectPtr Object, std::shared_ptr<JITSymbolResolver> Resolver) {
StringRef ObjBuffer = Object->getBinary()->getData();
if (auto HandleOrErr =
this->Remote.template callB<AddObject>(ObjBuffer)) {
@@ -387,8 +386,7 @@ private:
}
std::map<remote::ResourceIdMgr::ResourceId,
- std::shared_ptr<LegacyJITSymbolResolver>>
- Resolvers;
+ std::shared_ptr<JITSymbolResolver>> Resolvers;
};
/// RemoteObjectServerLayer acts as a server and handling RPC calls for the
Modified: llvm/trunk/include/llvm/ExecutionEngine/RTDyldMemoryManager.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/ExecutionEngine/RTDyldMemoryManager.h?rev=322914&r1=322913&r2=322914&view=diff
==============================================================================
--- llvm/trunk/include/llvm/ExecutionEngine/RTDyldMemoryManager.h (original)
+++ llvm/trunk/include/llvm/ExecutionEngine/RTDyldMemoryManager.h Thu Jan 18 17:40:26 2018
@@ -56,7 +56,7 @@ public:
// FIXME: As the RuntimeDyld fills out, additional routines will be needed
// for the varying types of objects to be allocated.
class RTDyldMemoryManager : public MCJITMemoryManager,
- public LegacyJITSymbolResolver {
+ public JITSymbolResolver {
public:
RTDyldMemoryManager() = default;
RTDyldMemoryManager(const RTDyldMemoryManager&) = delete;
Modified: llvm/trunk/lib/ExecutionEngine/ExecutionEngine.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/ExecutionEngine/ExecutionEngine.cpp?rev=322914&r1=322913&r2=322914&view=diff
==============================================================================
--- llvm/trunk/lib/ExecutionEngine/ExecutionEngine.cpp (original)
+++ llvm/trunk/lib/ExecutionEngine/ExecutionEngine.cpp Thu Jan 18 17:40:26 2018
@@ -49,13 +49,14 @@ STATISTIC(NumGlobals , "Number of globa
ExecutionEngine *(*ExecutionEngine::MCJITCtor)(
std::unique_ptr<Module> M, std::string *ErrorStr,
std::shared_ptr<MCJITMemoryManager> MemMgr,
- std::shared_ptr<LegacyJITSymbolResolver> Resolver,
+
+ std::shared_ptr<JITSymbolResolver> Resolver,
std::unique_ptr<TargetMachine> TM) = nullptr;
ExecutionEngine *(*ExecutionEngine::OrcMCJITReplacementCtor)(
- std::string *ErrorStr, std::shared_ptr<MCJITMemoryManager> MemMgr,
- std::shared_ptr<LegacyJITSymbolResolver> Resolver,
- std::unique_ptr<TargetMachine> TM) = nullptr;
+ std::string *ErrorStr, std::shared_ptr<MCJITMemoryManager> MemMgr,
+ std::shared_ptr<JITSymbolResolver> Resolver,
+ std::unique_ptr<TargetMachine> TM) = nullptr;
ExecutionEngine *(*ExecutionEngine::InterpCtor)(std::unique_ptr<Module> M,
std::string *ErrorStr) =nullptr;
@@ -501,9 +502,9 @@ EngineBuilder::setMemoryManager(std::uni
return *this;
}
-EngineBuilder &
-EngineBuilder::setSymbolResolver(std::unique_ptr<LegacyJITSymbolResolver> SR) {
- Resolver = std::shared_ptr<LegacyJITSymbolResolver>(std::move(SR));
+EngineBuilder&
+EngineBuilder::setSymbolResolver(std::unique_ptr<JITSymbolResolver> SR) {
+ Resolver = std::shared_ptr<JITSymbolResolver>(std::move(SR));
return *this;
}
Modified: llvm/trunk/lib/ExecutionEngine/MCJIT/MCJIT.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/ExecutionEngine/MCJIT/MCJIT.cpp?rev=322914&r1=322913&r2=322914&view=diff
==============================================================================
--- llvm/trunk/lib/ExecutionEngine/MCJIT/MCJIT.cpp (original)
+++ llvm/trunk/lib/ExecutionEngine/MCJIT/MCJIT.cpp Thu Jan 18 17:40:26 2018
@@ -39,10 +39,11 @@ static struct RegisterJIT {
extern "C" void LLVMLinkInMCJIT() {
}
-ExecutionEngine *
-MCJIT::createJIT(std::unique_ptr<Module> M, std::string *ErrorStr,
+ExecutionEngine*
+MCJIT::createJIT(std::unique_ptr<Module> M,
+ std::string *ErrorStr,
std::shared_ptr<MCJITMemoryManager> MemMgr,
- std::shared_ptr<LegacyJITSymbolResolver> Resolver,
+ std::shared_ptr<JITSymbolResolver> Resolver,
std::unique_ptr<TargetMachine> TM) {
// Try to register the program as a source of symbols to resolve against.
//
@@ -63,7 +64,7 @@ MCJIT::createJIT(std::unique_ptr<Module>
MCJIT::MCJIT(std::unique_ptr<Module> M, std::unique_ptr<TargetMachine> TM,
std::shared_ptr<MCJITMemoryManager> MemMgr,
- std::shared_ptr<LegacyJITSymbolResolver> Resolver)
+ std::shared_ptr<JITSymbolResolver> Resolver)
: ExecutionEngine(TM->createDataLayout(), std::move(M)), TM(std::move(TM)),
Ctx(nullptr), MemMgr(std::move(MemMgr)),
Resolver(*this, std::move(Resolver)), Dyld(*this->MemMgr, this->Resolver),
Modified: llvm/trunk/lib/ExecutionEngine/MCJIT/MCJIT.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/ExecutionEngine/MCJIT/MCJIT.h?rev=322914&r1=322913&r2=322914&view=diff
==============================================================================
--- llvm/trunk/lib/ExecutionEngine/MCJIT/MCJIT.h (original)
+++ llvm/trunk/lib/ExecutionEngine/MCJIT/MCJIT.h Thu Jan 18 17:40:26 2018
@@ -26,11 +26,11 @@ class MCJIT;
// functions across modules that it owns. It aggregates the memory manager
// that is passed in to the MCJIT constructor and defers most functionality
// to that object.
-class LinkingSymbolResolver : public LegacyJITSymbolResolver {
+class LinkingSymbolResolver : public JITSymbolResolver {
public:
LinkingSymbolResolver(MCJIT &Parent,
- std::shared_ptr<LegacyJITSymbolResolver> Resolver)
- : ParentEngine(Parent), ClientResolver(std::move(Resolver)) {}
+ std::shared_ptr<JITSymbolResolver> Resolver)
+ : ParentEngine(Parent), ClientResolver(std::move(Resolver)) {}
JITSymbol findSymbol(const std::string &Name) override;
@@ -41,7 +41,7 @@ public:
private:
MCJIT &ParentEngine;
- std::shared_ptr<LegacyJITSymbolResolver> ClientResolver;
+ std::shared_ptr<JITSymbolResolver> ClientResolver;
};
// About Module states: added->loaded->finalized.
@@ -67,7 +67,7 @@ private:
class MCJIT : public ExecutionEngine {
MCJIT(std::unique_ptr<Module> M, std::unique_ptr<TargetMachine> tm,
std::shared_ptr<MCJITMemoryManager> MemMgr,
- std::shared_ptr<LegacyJITSymbolResolver> Resolver);
+ std::shared_ptr<JITSymbolResolver> Resolver);
typedef llvm::SmallPtrSet<Module *, 4> ModulePtrSet;
@@ -300,10 +300,11 @@ public:
MCJITCtor = createJIT;
}
- static ExecutionEngine *
- createJIT(std::unique_ptr<Module> M, std::string *ErrorStr,
+ static ExecutionEngine*
+ createJIT(std::unique_ptr<Module> M,
+ std::string *ErrorStr,
std::shared_ptr<MCJITMemoryManager> MemMgr,
- std::shared_ptr<LegacyJITSymbolResolver> Resolver,
+ std::shared_ptr<JITSymbolResolver> Resolver,
std::unique_ptr<TargetMachine> TM);
// @}
Modified: llvm/trunk/lib/ExecutionEngine/Orc/OrcCBindingsStack.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/ExecutionEngine/Orc/OrcCBindingsStack.h?rev=322914&r1=322913&r2=322914&view=diff
==============================================================================
--- llvm/trunk/lib/ExecutionEngine/Orc/OrcCBindingsStack.h (original)
+++ llvm/trunk/lib/ExecutionEngine/Orc/OrcCBindingsStack.h Thu Jan 18 17:40:26 2018
@@ -196,7 +196,7 @@ public:
return mapError(IndirectStubsMgr->updatePointer(Name, Addr));
}
- std::shared_ptr<LegacyJITSymbolResolver>
+ std::shared_ptr<JITSymbolResolver>
createResolver(LLVMOrcSymbolResolverFn ExternalResolver,
void *ExternalResolverCtx) {
return orc::createLambdaResolver(
Modified: llvm/trunk/lib/ExecutionEngine/Orc/OrcMCJITReplacement.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/ExecutionEngine/Orc/OrcMCJITReplacement.h?rev=322914&r1=322913&r2=322914&view=diff
==============================================================================
--- llvm/trunk/lib/ExecutionEngine/Orc/OrcMCJITReplacement.h (original)
+++ llvm/trunk/lib/ExecutionEngine/Orc/OrcMCJITReplacement.h Thu Jan 18 17:40:26 2018
@@ -138,7 +138,7 @@ class OrcMCJITReplacement : public Execu
std::shared_ptr<MCJITMemoryManager> ClientMM;
};
- class LinkingResolver : public LegacyJITSymbolResolver {
+ class LinkingResolver : public JITSymbolResolver {
public:
LinkingResolver(OrcMCJITReplacement &M) : M(M) {}
@@ -160,19 +160,20 @@ private:
static ExecutionEngine *
createOrcMCJITReplacement(std::string *ErrorMsg,
std::shared_ptr<MCJITMemoryManager> MemMgr,
- std::shared_ptr<LegacyJITSymbolResolver> Resolver,
+ std::shared_ptr<JITSymbolResolver> Resolver,
std::unique_ptr<TargetMachine> TM) {
return new OrcMCJITReplacement(std::move(MemMgr), std::move(Resolver),
std::move(TM));
}
public:
- OrcMCJITReplacement(std::shared_ptr<MCJITMemoryManager> MemMgr,
- std::shared_ptr<LegacyJITSymbolResolver> ClientResolver,
- std::unique_ptr<TargetMachine> TM)
+ OrcMCJITReplacement(
+ std::shared_ptr<MCJITMemoryManager> MemMgr,
+ std::shared_ptr<JITSymbolResolver> ClientResolver,
+ std::unique_ptr<TargetMachine> TM)
: ExecutionEngine(TM->createDataLayout()), TM(std::move(TM)),
- MemMgr(
- std::make_shared<MCJITReplacementMemMgr>(*this, std::move(MemMgr))),
+ MemMgr(std::make_shared<MCJITReplacementMemMgr>(*this,
+ std::move(MemMgr))),
Resolver(std::make_shared<LinkingResolver>(*this)),
ClientResolver(std::move(ClientResolver)), NotifyObjectLoaded(*this),
NotifyFinalized(*this),
@@ -377,7 +378,7 @@ private:
std::unique_ptr<TargetMachine> TM;
std::shared_ptr<MCJITReplacementMemMgr> MemMgr;
std::shared_ptr<LinkingResolver> Resolver;
- std::shared_ptr<LegacyJITSymbolResolver> ClientResolver;
+ std::shared_ptr<JITSymbolResolver> ClientResolver;
Mangler Mang;
// IMPORTANT: ShouldDelete *must* come before LocalModules: The shared_ptr
Modified: llvm/trunk/lib/ExecutionEngine/RuntimeDyld/JITSymbol.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/ExecutionEngine/RuntimeDyld/JITSymbol.cpp?rev=322914&r1=322913&r2=322914&view=diff
==============================================================================
--- llvm/trunk/lib/ExecutionEngine/RuntimeDyld/JITSymbol.cpp (original)
+++ llvm/trunk/lib/ExecutionEngine/RuntimeDyld/JITSymbol.cpp Thu Jan 18 17:40:26 2018
@@ -47,53 +47,3 @@ ARMJITSymbolFlags llvm::ARMJITSymbolFlag
Flags |= ARMJITSymbolFlags::Thumb;
return Flags;
}
-
-/// @brief Performs lookup by, for each symbol, first calling
-/// findSymbolInLogicalDylib and if that fails calling
-/// findSymbol.
-Expected<JITSymbolResolver::LookupResult>
-LegacyJITSymbolResolver::lookup(const SymbolNameSet &Symbols) {
- JITSymbolResolver::LookupResult Result;
- for (auto &Symbol : Symbols) {
- std::string SymName = Symbol.str();
- if (auto Sym = findSymbolInLogicalDylib(SymName)) {
- if (auto AddrOrErr = Sym.getAddress())
- Result[Symbol] = JITEvaluatedSymbol(*AddrOrErr, Sym.getFlags());
- else
- return AddrOrErr.takeError();
- } else if (auto Err = Sym.takeError())
- return std::move(Err);
- else {
- // findSymbolInLogicalDylib failed. Lets try findSymbol.
- if (auto Sym = findSymbol(SymName)) {
- if (auto AddrOrErr = Sym.getAddress())
- Result[Symbol] = JITEvaluatedSymbol(*AddrOrErr, Sym.getFlags());
- else
- return AddrOrErr.takeError();
- } else if (auto Err = Sym.takeError())
- return std::move(Err);
- else
- return make_error<StringError>("Symbol not found: " + Symbol,
- inconvertibleErrorCode());
- }
- }
-
- return std::move(Result);
-}
-
-/// @brief Performs flags lookup by calling findSymbolInLogicalDylib and
-/// returning the flags value for that symbol.
-Expected<JITSymbolResolver::LookupFlagsResult>
-LegacyJITSymbolResolver::lookupFlags(const SymbolNameSet &Symbols) {
- JITSymbolResolver::LookupFlagsResult Result;
-
- for (auto &Symbol : Symbols) {
- std::string SymName = Symbol.str();
- if (auto Sym = findSymbolInLogicalDylib(SymName))
- Result[Symbol] = Sym.getFlags();
- else if (auto Err = Sym.takeError())
- return std::move(Err);
- }
-
- return std::move(Result);
-}
Modified: llvm/trunk/lib/ExecutionEngine/RuntimeDyld/RuntimeDyld.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/ExecutionEngine/RuntimeDyld/RuntimeDyld.cpp?rev=322914&r1=322913&r2=322914&view=diff
==============================================================================
--- llvm/trunk/lib/ExecutionEngine/RuntimeDyld/RuntimeDyld.cpp (original)
+++ llvm/trunk/lib/ExecutionEngine/RuntimeDyld/RuntimeDyld.cpp Thu Jan 18 17:40:26 2018
@@ -202,33 +202,7 @@ RuntimeDyldImpl::loadObjectImpl(const ob
ObjSectionToIDMap LocalSections;
// Common symbols requiring allocation, with their sizes and alignments
- CommonSymbolList CommonSymbolsToAllocate;
-
- uint64_t CommonSize = 0;
- uint32_t CommonAlign = 0;
-
- // First, collect all weak and common symbols. We need to know if stronger
- // definitions occur elsewhere.
- JITSymbolResolver::LookupFlagsResult SymbolFlags;
- {
- JITSymbolResolver::SymbolNameSet Symbols;
- for (auto &Sym : Obj.symbols()) {
- uint32_t Flags = Sym.getFlags();
- if ((Flags & SymbolRef::SF_Common) || (Flags & SymbolRef::SF_Weak)) {
- // Get symbol name.
- StringRef Name;
- if (auto NameOrErr = Sym.getName())
- Symbols.insert(*NameOrErr);
- else
- return NameOrErr.takeError();
- }
- }
-
- if (auto FlagsResultOrErr = Resolver.lookupFlags(Symbols))
- SymbolFlags = std::move(*FlagsResultOrErr);
- else
- return FlagsResultOrErr.takeError();
- }
+ CommonSymbolList CommonSymbols;
// Parse symbols
DEBUG(dbgs() << "Parse symbols:\n");
@@ -240,108 +214,102 @@ RuntimeDyldImpl::loadObjectImpl(const ob
if (Flags & SymbolRef::SF_Undefined)
continue;
- // Get the symbol type.
- object::SymbolRef::Type SymType;
- if (auto SymTypeOrErr = I->getType())
- SymType = *SymTypeOrErr;
- else
- return SymTypeOrErr.takeError();
-
- // Get symbol name.
- StringRef Name;
- if (auto NameOrErr = I->getName())
- Name = *NameOrErr;
- else
- return NameOrErr.takeError();
+ if (Flags & SymbolRef::SF_Common)
+ CommonSymbols.push_back(*I);
+ else {
+
+ // Get the symbol type.
+ object::SymbolRef::Type SymType;
+ if (auto SymTypeOrErr = I->getType())
+ SymType = *SymTypeOrErr;
+ else
+ return SymTypeOrErr.takeError();
- // Compute JIT symbol flags.
- JITSymbolFlags JITSymFlags = getJITSymbolFlags(*I);
+ // Get symbol name.
+ StringRef Name;
+ if (auto NameOrErr = I->getName())
+ Name = *NameOrErr;
+ else
+ return NameOrErr.takeError();
- // If this is a weak definition, check to see if there's a strong one.
- // If there is, skip this symbol (we won't be providing it: the strong
- // definition will). If there's no strong definition, make this definition
- // strong.
- if (JITSymFlags.isWeak() || JITSymFlags.isCommon()) {
- // First check whether there's already a definition in this instance.
- // FIXME: Override existing weak definitions with strong ones.
- if (GlobalSymbolTable.count(Name))
- continue;
+ // Compute JIT symbol flags.
+ JITSymbolFlags JITSymFlags = getJITSymbolFlags(*I);
- // Then check whether we found flags for an existing symbol during the
- // flags lookup earlier.
- auto FlagsI = SymbolFlags.find(Name);
- if (FlagsI == SymbolFlags.end() ||
- (JITSymFlags.isWeak() && !FlagsI->second.isStrong()) ||
- (JITSymFlags.isCommon() && FlagsI->second.isCommon())) {
- if (JITSymFlags.isWeak())
- JITSymFlags &= ~JITSymbolFlags::Weak;
- if (JITSymFlags.isCommon()) {
- JITSymFlags &= ~JITSymbolFlags::Common;
- uint32_t Align = I->getAlignment();
- uint64_t Size = I->getCommonSize();
- if (!CommonAlign)
- CommonAlign = Align;
- CommonSize += alignTo(CommonSize, Align) + Size;
- CommonSymbolsToAllocate.push_back(*I);
- }
- } else
- continue;
- }
+ // If this is a weak definition, check to see if there's a strong one.
+ // If there is, skip this symbol (we won't be providing it: the strong
+ // definition will). If there's no strong definition, make this definition
+ // strong.
+ if (JITSymFlags.isWeak()) {
+ // First check whether there's already a definition in this instance.
+ // FIXME: Override existing weak definitions with strong ones.
+ if (GlobalSymbolTable.count(Name))
+ continue;
+ // Then check the symbol resolver to see if there's a definition
+ // elsewhere in this logical dylib.
+ if (auto Sym = Resolver.findSymbolInLogicalDylib(Name)) {
+ if (Sym.getFlags().isStrong())
+ continue;
+ } else if (auto Err = Sym.takeError())
+ return std::move(Err);
+ // else
+ JITSymFlags &= ~JITSymbolFlags::Weak;
+ }
- if (Flags & SymbolRef::SF_Absolute &&
- SymType != object::SymbolRef::ST_File) {
- uint64_t Addr = 0;
- if (auto AddrOrErr = I->getAddress())
- Addr = *AddrOrErr;
- else
- return AddrOrErr.takeError();
+ if (Flags & SymbolRef::SF_Absolute &&
+ SymType != object::SymbolRef::ST_File) {
+ uint64_t Addr = 0;
+ if (auto AddrOrErr = I->getAddress())
+ Addr = *AddrOrErr;
+ else
+ return AddrOrErr.takeError();
- unsigned SectionID = AbsoluteSymbolSection;
+ unsigned SectionID = AbsoluteSymbolSection;
- DEBUG(dbgs() << "\tType: " << SymType << " (absolute) Name: " << Name
- << " SID: " << SectionID
- << " Offset: " << format("%p", (uintptr_t)Addr)
- << " flags: " << Flags << "\n");
- GlobalSymbolTable[Name] = SymbolTableEntry(SectionID, Addr, JITSymFlags);
- } else if (SymType == object::SymbolRef::ST_Function ||
- SymType == object::SymbolRef::ST_Data ||
- SymType == object::SymbolRef::ST_Unknown ||
- SymType == object::SymbolRef::ST_Other) {
-
- section_iterator SI = Obj.section_end();
- if (auto SIOrErr = I->getSection())
- SI = *SIOrErr;
- else
- return SIOrErr.takeError();
+ DEBUG(dbgs() << "\tType: " << SymType << " (absolute) Name: " << Name
+ << " SID: " << SectionID << " Offset: "
+ << format("%p", (uintptr_t)Addr)
+ << " flags: " << Flags << "\n");
+ GlobalSymbolTable[Name] =
+ SymbolTableEntry(SectionID, Addr, JITSymFlags);
+ } else if (SymType == object::SymbolRef::ST_Function ||
+ SymType == object::SymbolRef::ST_Data ||
+ SymType == object::SymbolRef::ST_Unknown ||
+ SymType == object::SymbolRef::ST_Other) {
+
+ section_iterator SI = Obj.section_end();
+ if (auto SIOrErr = I->getSection())
+ SI = *SIOrErr;
+ else
+ return SIOrErr.takeError();
- if (SI == Obj.section_end())
- continue;
+ if (SI == Obj.section_end())
+ continue;
- // Get symbol offset.
- uint64_t SectOffset;
- if (auto Err = getOffset(*I, *SI, SectOffset))
- return std::move(Err);
-
- bool IsCode = SI->isText();
- unsigned SectionID;
- if (auto SectionIDOrErr =
- findOrEmitSection(Obj, *SI, IsCode, LocalSections))
- SectionID = *SectionIDOrErr;
- else
- return SectionIDOrErr.takeError();
+ // Get symbol offset.
+ uint64_t SectOffset;
+ if (auto Err = getOffset(*I, *SI, SectOffset))
+ return std::move(Err);
+
+ bool IsCode = SI->isText();
+ unsigned SectionID;
+ if (auto SectionIDOrErr = findOrEmitSection(Obj, *SI, IsCode,
+ LocalSections))
+ SectionID = *SectionIDOrErr;
+ else
+ return SectionIDOrErr.takeError();
- DEBUG(dbgs() << "\tType: " << SymType << " Name: " << Name
- << " SID: " << SectionID
- << " Offset: " << format("%p", (uintptr_t)SectOffset)
- << " flags: " << Flags << "\n");
- GlobalSymbolTable[Name] =
+ DEBUG(dbgs() << "\tType: " << SymType << " Name: " << Name
+ << " SID: " << SectionID << " Offset: "
+ << format("%p", (uintptr_t)SectOffset)
+ << " flags: " << Flags << "\n");
+ GlobalSymbolTable[Name] =
SymbolTableEntry(SectionID, SectOffset, JITSymFlags);
+ }
}
}
// Allocate common symbols
- if (auto Err = emitCommonSymbols(Obj, CommonSymbolsToAllocate, CommonSize,
- CommonAlign))
+ if (auto Err = emitCommonSymbols(Obj, CommonSymbols))
return std::move(Err);
// Parse and process relocations
@@ -653,12 +621,45 @@ JITSymbolFlags RuntimeDyldImpl::getJITSy
}
Error RuntimeDyldImpl::emitCommonSymbols(const ObjectFile &Obj,
- CommonSymbolList &SymbolsToAllocate,
- uint64_t CommonSize,
- uint32_t CommonAlign) {
- if (SymbolsToAllocate.empty())
+ CommonSymbolList &CommonSymbols) {
+ if (CommonSymbols.empty())
return Error::success();
+ uint64_t CommonSize = 0;
+ uint32_t CommonAlign = CommonSymbols.begin()->getAlignment();
+ CommonSymbolList SymbolsToAllocate;
+
+ DEBUG(dbgs() << "Processing common symbols...\n");
+
+ for (const auto &Sym : CommonSymbols) {
+ StringRef Name;
+ if (auto NameOrErr = Sym.getName())
+ Name = *NameOrErr;
+ else
+ return NameOrErr.takeError();
+
+ // Skip common symbols already elsewhere.
+ if (GlobalSymbolTable.count(Name)) {
+ DEBUG(dbgs() << "\tSkipping already emitted common symbol '" << Name
+ << "'\n");
+ continue;
+ }
+
+ if (auto Sym = Resolver.findSymbolInLogicalDylib(Name)) {
+ if (!Sym.getFlags().isCommon()) {
+ DEBUG(dbgs() << "\tSkipping common symbol '" << Name
+ << "' in favor of stronger definition.\n");
+ continue;
+ }
+ }
+ uint32_t Align = Sym.getAlignment();
+ uint64_t Size = Sym.getCommonSize();
+
+ CommonSize = alignTo(CommonSize, Align) + Size;
+
+ SymbolsToAllocate.push_back(Sym);
+ }
+
// Allocate memory for the section
unsigned SectionID = Sections.size();
uint8_t *Addr = MemMgr.allocateDataSection(CommonSize, CommonAlign, SectionID,
@@ -996,40 +997,7 @@ void RuntimeDyldImpl::resolveRelocationL
}
Error RuntimeDyldImpl::resolveExternalSymbols() {
- JITSymbolResolver::LookupResult ExternalSymbolMap;
-
- // Resolution can trigger emission of more symbols, so iterate until
- // we've resolved *everything*.
- {
- JITSymbolResolver::SymbolNameSet ResolvedSymbols;
-
- while (true) {
- JITSymbolResolver::SymbolNameSet NewSymbols;
-
- for (auto &RelocKV : ExternalSymbolRelocations) {
- StringRef Name = RelocKV.first();
- if (!Name.empty() && !GlobalSymbolTable.count(Name) &&
- !ResolvedSymbols.count(Name))
- NewSymbols.insert(Name);
- }
-
- if (NewSymbols.empty())
- break;
-
- auto NewResolverResults = Resolver.lookup(NewSymbols);
- if (!NewResolverResults)
- return NewResolverResults.takeError();
-
- for (auto &RRKV : *NewResolverResults) {
- assert(!ResolvedSymbols.count(RRKV.first) && "Redundant resolution?");
- ExternalSymbolMap.insert(RRKV);
- ResolvedSymbols.insert(RRKV.first);
- }
- }
- }
-
while (!ExternalSymbolRelocations.empty()) {
-
StringMap<RelocationList>::iterator i = ExternalSymbolRelocations.begin();
StringRef Name = i->first();
@@ -1044,10 +1012,29 @@ Error RuntimeDyldImpl::resolveExternalSy
JITSymbolFlags Flags;
RTDyldSymbolTable::const_iterator Loc = GlobalSymbolTable.find(Name);
if (Loc == GlobalSymbolTable.end()) {
- auto RRI = ExternalSymbolMap.find(Name);
- assert(RRI != ExternalSymbolMap.end() && "No result for symbol");
- Addr = RRI->second.getAddress();
- Flags = RRI->second.getFlags();
+ // This is an external symbol, try to get its address from the symbol
+ // resolver.
+ // First search for the symbol in this logical dylib.
+ if (auto Sym = Resolver.findSymbolInLogicalDylib(Name.data())) {
+ if (auto AddrOrErr = Sym.getAddress()) {
+ Addr = *AddrOrErr;
+ Flags = Sym.getFlags();
+ } else
+ return AddrOrErr.takeError();
+ } else if (auto Err = Sym.takeError())
+ return Err;
+
+ // If that fails, try searching for an external symbol.
+ if (!Addr) {
+ if (auto Sym = Resolver.findSymbol(Name.data())) {
+ if (auto AddrOrErr = Sym.getAddress()) {
+ Addr = *AddrOrErr;
+ Flags = Sym.getFlags();
+ } else
+ return AddrOrErr.takeError();
+ } else if (auto Err = Sym.takeError())
+ return Err;
+ }
// The call to getSymbolAddress may have caused additional modules to
// be loaded, which may have added new entries to the
// ExternalSymbolRelocations map. Consquently, we need to update our
@@ -1108,7 +1095,6 @@ uint64_t RuntimeDyld::LoadedObjectInfo::
void RuntimeDyld::MemoryManager::anchor() {}
void JITSymbolResolver::anchor() {}
-void LegacyJITSymbolResolver::anchor() {}
RuntimeDyld::RuntimeDyld(RuntimeDyld::MemoryManager &MemMgr,
JITSymbolResolver &Resolver)
Modified: llvm/trunk/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldChecker.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldChecker.cpp?rev=322914&r1=322913&r2=322914&view=diff
==============================================================================
--- llvm/trunk/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldChecker.cpp (original)
+++ llvm/trunk/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldChecker.cpp Thu Jan 18 17:40:26 2018
@@ -731,14 +731,7 @@ bool RuntimeDyldCheckerImpl::checkAllRul
bool RuntimeDyldCheckerImpl::isSymbolValid(StringRef Symbol) const {
if (getRTDyld().getSymbol(Symbol))
return true;
- JITSymbolResolver::SymbolNameSet Symbols({Symbol});
- auto Result = getRTDyld().Resolver.lookup(Symbols);
- if (!Result) {
- logAllUnhandledErrors(Result.takeError(), errs(), "RTDyldChecker: ");
- return false;
- }
- assert(Result->count(Symbol) && "Missing symbol result");
- return true;
+ return !!getRTDyld().Resolver.findSymbol(Symbol);
}
uint64_t RuntimeDyldCheckerImpl::getSymbolLocalAddr(StringRef Symbol) const {
@@ -749,16 +742,7 @@ uint64_t RuntimeDyldCheckerImpl::getSymb
uint64_t RuntimeDyldCheckerImpl::getSymbolRemoteAddr(StringRef Symbol) const {
if (auto InternalSymbol = getRTDyld().getSymbol(Symbol))
return InternalSymbol.getAddress();
-
- JITSymbolResolver::SymbolNameSet Symbols({Symbol});
- auto Result = getRTDyld().Resolver.lookup(Symbols);
- if (!Result) {
- logAllUnhandledErrors(Result.takeError(), errs(), "RTDyldChecker: ");
- return 0;
- }
- auto I = Result->find(Symbol);
- assert(I != Result->end() && "Missing symbol result");
- return I->second.getAddress();
+ return cantFail(getRTDyld().Resolver.findSymbol(Symbol).getAddress());
}
uint64_t RuntimeDyldCheckerImpl::readMemoryAtAddr(uint64_t SrcAddr,
Modified: llvm/trunk/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldImpl.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldImpl.h?rev=322914&r1=322913&r2=322914&view=diff
==============================================================================
--- llvm/trunk/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldImpl.h (original)
+++ llvm/trunk/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldImpl.h Thu Jan 18 17:40:26 2018
@@ -385,8 +385,7 @@ protected:
/// new section for them and update the symbol mappings in the object and
/// symbol table.
Error emitCommonSymbols(const ObjectFile &Obj,
- CommonSymbolList &CommonSymbols, uint64_t CommonSize,
- uint32_t CommonAlign);
+ CommonSymbolList &CommonSymbols);
/// \brief Emits section data from the object file to the MemoryManager.
/// \param IsCode if it's true then allocateCodeSection() will be
Modified: llvm/trunk/tools/lli/RemoteJITUtils.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/lli/RemoteJITUtils.h?rev=322914&r1=322913&r2=322914&view=diff
==============================================================================
--- llvm/trunk/tools/lli/RemoteJITUtils.h (original)
+++ llvm/trunk/tools/lli/RemoteJITUtils.h Thu Jan 18 17:40:26 2018
@@ -84,7 +84,7 @@ public:
this->MemMgr = std::move(MemMgr);
}
- void setResolver(std::shared_ptr<LegacyJITSymbolResolver> Resolver) {
+ void setResolver(std::shared_ptr<JITSymbolResolver> Resolver) {
this->Resolver = std::move(Resolver);
}
@@ -145,7 +145,7 @@ public:
private:
std::unique_ptr<RuntimeDyld::MemoryManager> MemMgr;
- std::shared_ptr<LegacyJITSymbolResolver> Resolver;
+ std::shared_ptr<JITSymbolResolver> Resolver;
};
}
More information about the llvm-commits
mailing list