Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
66 changes: 25 additions & 41 deletions llvm/include/llvm/ExecutionEngine/Orc/Core.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
#include "llvm/ExecutionEngine/Orc/Shared/ExecutorSymbolDef.h"
#include "llvm/ExecutionEngine/Orc/Shared/WrapperFunctionUtils.h"
#include "llvm/ExecutionEngine/Orc/TaskDispatch.h"
#include "llvm/ExecutionEngine/Orc/WaitingOnGraph.h"
#include "llvm/Support/Compiler.h"
#include "llvm/Support/Debug.h"
#include "llvm/Support/ExtensibleRTTI.h"
Expand All @@ -49,6 +50,9 @@ class InProgressLookupState;

enum class SymbolState : uint8_t;

using WaitingOnGraph =
detail::WaitingOnGraph<JITDylib *, NonOwningSymbolStringPtr>;

using ResourceTrackerSP = IntrusiveRefCntPtr<ResourceTracker>;
using JITDylibSP = IntrusiveRefCntPtr<JITDylib>;

Expand Down Expand Up @@ -1131,20 +1135,6 @@ class JITDylib : public ThreadSafeRefCountedBase<JITDylib>,
using UnmaterializedInfosList =
std::vector<std::shared_ptr<UnmaterializedInfo>>;

struct EmissionDepUnit {
EmissionDepUnit(JITDylib &JD) : JD(&JD) {}

JITDylib *JD = nullptr;
DenseMap<NonOwningSymbolStringPtr, JITSymbolFlags> Symbols;
DenseMap<JITDylib *, DenseSet<NonOwningSymbolStringPtr>> Dependencies;
};

struct EmissionDepUnitInfo {
std::shared_ptr<EmissionDepUnit> EDU;
DenseSet<EmissionDepUnit *> IntraEmitUsers;
DenseMap<JITDylib *, DenseSet<NonOwningSymbolStringPtr>> NewDeps;
};

// Information about not-yet-ready symbol.
// * DefiningEDU will point to the EmissionDepUnit that defines the symbol.
// * DependantEDUs will hold pointers to any EmissionDepUnits currently
Expand All @@ -1154,9 +1144,6 @@ class JITDylib : public ThreadSafeRefCountedBase<JITDylib>,
struct MaterializingInfo {
friend class ExecutionSession;

std::shared_ptr<EmissionDepUnit> DefiningEDU;
DenseSet<EmissionDepUnit *> DependantEDUs;

LLVM_ABI void addQuery(std::shared_ptr<AsynchronousSymbolQuery> Q);
LLVM_ABI void removeQuery(const AsynchronousSymbolQuery &Q);
LLVM_ABI AsynchronousSymbolQueryList
Expand Down Expand Up @@ -1778,30 +1765,26 @@ class ExecutionSession {
LLVM_ABI Error OL_notifyResolved(MaterializationResponsibility &MR,
const SymbolMap &Symbols);

using EDUInfosMap =
DenseMap<JITDylib::EmissionDepUnit *, JITDylib::EmissionDepUnitInfo>;

template <typename HandleNewDepFn>
void propagateExtraEmitDeps(std::deque<JITDylib::EmissionDepUnit *> Worklist,
EDUInfosMap &EDUInfos,
HandleNewDepFn HandleNewDep);
EDUInfosMap simplifyDepGroups(MaterializationResponsibility &MR,
ArrayRef<SymbolDependenceGroup> EmittedDeps);
void IL_makeEDUReady(std::shared_ptr<JITDylib::EmissionDepUnit> EDU,
JITDylib::AsynchronousSymbolQuerySet &Queries);
void IL_makeEDUEmitted(std::shared_ptr<JITDylib::EmissionDepUnit> EDU,
JITDylib::AsynchronousSymbolQuerySet &Queries);
bool IL_removeEDUDependence(JITDylib::EmissionDepUnit &EDU, JITDylib &DepJD,
NonOwningSymbolStringPtr DepSym,
EDUInfosMap &EDUInfos);

static Error makeJDClosedError(JITDylib::EmissionDepUnit &EDU,
JITDylib &ClosedJD);
static Error makeUnsatisfiedDepsError(JITDylib::EmissionDepUnit &EDU,
JITDylib &BadJD, SymbolNameSet BadDeps);

Expected<JITDylib::AsynchronousSymbolQuerySet>
IL_emit(MaterializationResponsibility &MR, EDUInfosMap EDUInfos);
// FIXME: We should be able to derive FailedSymsForQuery from each query once
// we fix how the detach operation works.
struct EmitQueries {
JITDylib::AsynchronousSymbolQuerySet Updated;
JITDylib::AsynchronousSymbolQuerySet Failed;
DenseMap<AsynchronousSymbolQuery *, std::shared_ptr<SymbolDependenceMap>>
FailedSymsForQuery;
};

WaitingOnGraph::ExternalState
IL_getSymbolState(JITDylib *JD, NonOwningSymbolStringPtr Name);

template <typename UpdateSymbolFn, typename UpdateQueryFn>
void IL_collectQueries(JITDylib::AsynchronousSymbolQuerySet &Qs,
WaitingOnGraph::ContainerElementsMap &QualifiedSymbols,
UpdateSymbolFn &&UpdateSymbol,
UpdateQueryFn &&UpdateQuery);

Expected<EmitQueries> IL_emit(MaterializationResponsibility &MR,
WaitingOnGraph::SimplifyResult SR);
LLVM_ABI Error OL_notifyEmitted(MaterializationResponsibility &MR,
ArrayRef<SymbolDependenceGroup> EmittedDeps);

Expand Down Expand Up @@ -1830,6 +1813,7 @@ class ExecutionSession {
std::vector<ResourceManager *> ResourceManagers;

std::vector<JITDylibSP> JDs;
WaitingOnGraph G;

// FIXME: Remove this (and runOutstandingMUs) once the linking layer works
// with callbacks from asynchronous queries.
Expand Down
8 changes: 7 additions & 1 deletion llvm/include/llvm/ExecutionEngine/Orc/SymbolStringPool.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
#define LLVM_EXECUTIONENGINE_ORC_SYMBOLSTRINGPOOL_H

#include "llvm/ADT/DenseMap.h"
#include "llvm/ADT/Hashing.h"
#include "llvm/ADT/StringMap.h"
#include "llvm/Support/Compiler.h"
#include <atomic>
Expand Down Expand Up @@ -71,6 +72,7 @@ class SymbolStringPool {
/// from nullptr to enable comparison with these values.
class SymbolStringPtrBase {
friend class SymbolStringPool;
friend class SymbolStringPoolEntryUnsafe;
friend struct DenseMapInfo<SymbolStringPtr>;
friend struct DenseMapInfo<NonOwningSymbolStringPtr>;

Expand Down Expand Up @@ -204,7 +206,7 @@ class SymbolStringPoolEntryUnsafe {
SymbolStringPoolEntryUnsafe(PoolEntry *E) : E(E) {}

/// Create an unsafe pool entry ref without changing the ref-count.
static SymbolStringPoolEntryUnsafe from(const SymbolStringPtr &S) {
static SymbolStringPoolEntryUnsafe from(const SymbolStringPtrBase &S) {
return S.S;
}

Expand Down Expand Up @@ -318,6 +320,10 @@ SymbolStringPool::getRefCount(const SymbolStringPtrBase &S) const {
LLVM_ABI raw_ostream &operator<<(raw_ostream &OS,
const SymbolStringPtrBase &Sym);

inline hash_code hash_value(const orc::NonOwningSymbolStringPtr &S) {
return hash_value(orc::SymbolStringPoolEntryUnsafe::from(S).rawPtr());
}

} // end namespace orc

template <>
Expand Down
Loading
Loading