diff options
author | Lang Hames <lhames@gmail.com> | 2018-10-16 20:13:06 +0000 |
---|---|---|
committer | Lang Hames <lhames@gmail.com> | 2018-10-16 20:13:06 +0000 |
commit | 8b94274f22d8c346103c5682e7899e8b43db16d7 (patch) | |
tree | ab087f3142915bbc8d445561570f4ee30385227d /llvm/include/llvm/ExecutionEngine/Orc/Core.h | |
parent | 4084df00402bc9b69b15b56cbdd8f5f8be81cc0a (diff) | |
download | bcm5719-llvm-8b94274f22d8c346103c5682e7899e8b43db16d7.tar.gz bcm5719-llvm-8b94274f22d8c346103c5682e7899e8b43db16d7.zip |
[ORC] Make the VModuleKey optional, propagate it via MaterializationUnit and
MaterializationResponsibility.
VModuleKeys are intended to enable selective removal of modules from a JIT
session, however for a wide variety of use cases selective removal is not
needed and introduces unnecessary overhead. As of this commit, the default
constructed VModuleKey value is reserved as a "do not track" value, and
becomes the default when adding a new module to the JIT.
This commit also changes the propagation of VModuleKeys. They were passed
alongside the MaterializationResponsibity instance in XXLayer::emit methods,
but are now propagated as part of the MaterializationResponsibility instance
itself (and as part of MaterializationUnit when stored in a JITDylib).
Associating VModuleKeys with MaterializationUnits in this way should allow
for a thread-safe module removal mechanism in the future, even when a module
is in the process of being compiled, by having the
MaterializationResponsibility object check in on its VModuleKey's state
before commiting its results to the JITDylib.
llvm-svn: 344643
Diffstat (limited to 'llvm/include/llvm/ExecutionEngine/Orc/Core.h')
-rw-r--r-- | llvm/include/llvm/ExecutionEngine/Orc/Core.h | 40 |
1 files changed, 25 insertions, 15 deletions
diff --git a/llvm/include/llvm/ExecutionEngine/Orc/Core.h b/llvm/include/llvm/ExecutionEngine/Orc/Core.h index 86c5ebb6d27..2e56854340c 100644 --- a/llvm/include/llvm/ExecutionEngine/Orc/Core.h +++ b/llvm/include/llvm/ExecutionEngine/Orc/Core.h @@ -168,6 +168,9 @@ public: /// into. JITDylib &getTargetJITDylib() const { return JD; } + /// Returns the VModuleKey for this instance. + VModuleKey getVModuleKey() const { return K; } + /// Returns the symbol flags map for this responsibility instance. /// Note: The returned flags may have transient flags (Lazy, Materializing) /// set. These should be stripped with JITSymbolFlags::stripTransientFlags @@ -218,7 +221,8 @@ public: /// Delegates responsibility for the given symbols to the returned /// materialization responsibility. Useful for breaking up work between /// threads, or different kinds of materialization processes. - MaterializationResponsibility delegate(const SymbolNameSet &Symbols); + MaterializationResponsibility delegate(const SymbolNameSet &Symbols, + VModuleKey NewKey = VModuleKey()); void addDependencies(const SymbolStringPtr &Name, const SymbolDependenceMap &Dependencies); @@ -229,10 +233,12 @@ public: private: /// Create a MaterializationResponsibility for the given JITDylib and /// initial symbols. - MaterializationResponsibility(JITDylib &JD, SymbolFlagsMap SymbolFlags); + MaterializationResponsibility(JITDylib &JD, SymbolFlagsMap SymbolFlags, + VModuleKey K); JITDylib &JD; SymbolFlagsMap SymbolFlags; + VModuleKey K; }; /// A MaterializationUnit represents a set of symbol definitions that can @@ -245,8 +251,8 @@ private: /// stronger definition is added or already present. class MaterializationUnit { public: - MaterializationUnit(SymbolFlagsMap InitalSymbolFlags) - : SymbolFlags(std::move(InitalSymbolFlags)) {} + MaterializationUnit(SymbolFlagsMap InitalSymbolFlags, VModuleKey K) + : SymbolFlags(std::move(InitalSymbolFlags)), K(std::move(K)) {} virtual ~MaterializationUnit() {} @@ -261,7 +267,8 @@ public: /// ExecutionSession::DispatchMaterializationFunction) to trigger /// materialization of this MaterializationUnit. void doMaterialize(JITDylib &JD) { - materialize(MaterializationResponsibility(JD, std::move(SymbolFlags))); + materialize(MaterializationResponsibility(JD, std::move(SymbolFlags), + std::move(K))); } /// Called by JITDylibs to notify MaterializationUnits that the given symbol @@ -273,6 +280,7 @@ public: protected: SymbolFlagsMap SymbolFlags; + VModuleKey K; private: virtual void anchor(); @@ -298,7 +306,7 @@ using MaterializationUnitList = /// materialized. class AbsoluteSymbolsMaterializationUnit : public MaterializationUnit { public: - AbsoluteSymbolsMaterializationUnit(SymbolMap Symbols); + AbsoluteSymbolsMaterializationUnit(SymbolMap Symbols, VModuleKey K); StringRef getName() const override; @@ -321,9 +329,9 @@ private: /// \endcode /// inline std::unique_ptr<AbsoluteSymbolsMaterializationUnit> -absoluteSymbols(SymbolMap Symbols) { +absoluteSymbols(SymbolMap Symbols, VModuleKey K = VModuleKey()) { return llvm::make_unique<AbsoluteSymbolsMaterializationUnit>( - std::move(Symbols)); + std::move(Symbols), std::move(K)); } struct SymbolAliasMapEntry { @@ -349,7 +357,8 @@ public: /// Note: Care must be taken that no sets of aliases form a cycle, as such /// a cycle will result in a deadlock when any symbol in the cycle is /// resolved. - ReExportsMaterializationUnit(JITDylib *SourceJD, SymbolAliasMap Aliases); + ReExportsMaterializationUnit(JITDylib *SourceJD, SymbolAliasMap Aliases, + VModuleKey K); StringRef getName() const override; @@ -374,17 +383,18 @@ private: /// return Err; /// \endcode inline std::unique_ptr<ReExportsMaterializationUnit> -symbolAliases(SymbolAliasMap Aliases) { - return llvm::make_unique<ReExportsMaterializationUnit>(nullptr, - std::move(Aliases)); +symbolAliases(SymbolAliasMap Aliases, VModuleKey K = VModuleKey()) { + return llvm::make_unique<ReExportsMaterializationUnit>( + nullptr, std::move(Aliases), std::move(K)); } /// Create a materialization unit for re-exporting symbols from another JITDylib /// with alternative names/flags. inline std::unique_ptr<ReExportsMaterializationUnit> -reexports(JITDylib &SourceJD, SymbolAliasMap Aliases) { - return llvm::make_unique<ReExportsMaterializationUnit>(&SourceJD, - std::move(Aliases)); +reexports(JITDylib &SourceJD, SymbolAliasMap Aliases, + VModuleKey K = VModuleKey()) { + return llvm::make_unique<ReExportsMaterializationUnit>( + &SourceJD, std::move(Aliases), std::move(K)); } /// Build a SymbolAliasMap for the common case where you want to re-export |