summaryrefslogtreecommitdiffstats
path: root/llvm/include
diff options
context:
space:
mode:
Diffstat (limited to 'llvm/include')
-rw-r--r--llvm/include/llvm-c/OrcBindings.h32
-rw-r--r--llvm/include/llvm/ExecutionEngine/Orc/CompileOnDemandLayer.h10
-rw-r--r--llvm/include/llvm/ExecutionEngine/Orc/IRCompileLayer.h24
-rw-r--r--llvm/include/llvm/ExecutionEngine/Orc/IRTransformLayer.h2
-rw-r--r--llvm/include/llvm/ExecutionEngine/Orc/LazyEmittingLayer.h7
5 files changed, 32 insertions, 43 deletions
diff --git a/llvm/include/llvm-c/OrcBindings.h b/llvm/include/llvm-c/OrcBindings.h
index 95bdef81593..fda43edd7bb 100644
--- a/llvm/include/llvm-c/OrcBindings.h
+++ b/llvm/include/llvm-c/OrcBindings.h
@@ -29,7 +29,6 @@
extern "C" {
#endif
-typedef struct LLVMOpaqueSharedModule *LLVMSharedModuleRef;
typedef struct LLVMOrcOpaqueJITStack *LLVMOrcJITStackRef;
typedef uint64_t LLVMOrcModuleHandle;
typedef uint64_t LLVMOrcTargetAddress;
@@ -40,33 +39,6 @@ typedef uint64_t (*LLVMOrcLazyCompileCallbackFn)(LLVMOrcJITStackRef JITStack,
typedef enum { LLVMOrcErrSuccess = 0, LLVMOrcErrGeneric } LLVMOrcErrorCode;
/**
- * Turn an LLVMModuleRef into an LLVMSharedModuleRef.
- *
- * The JIT uses shared ownership for LLVM modules, since it is generally
- * difficult to know when the JIT will be finished with a module (and the JIT
- * has no way of knowing when a user may be finished with one).
- *
- * Calling this method with an LLVMModuleRef creates a shared-pointer to the
- * module, and returns a reference to this shared pointer.
- *
- * The shared module should be disposed when finished with by calling
- * LLVMOrcDisposeSharedModule (not LLVMDisposeModule). The Module will be
- * deleted when the last shared pointer owner relinquishes it.
- */
-
-LLVMSharedModuleRef LLVMOrcMakeSharedModule(LLVMModuleRef Mod);
-
-/**
- * Dispose of a shared module.
- *
- * The module should not be accessed after this call. The module will be
- * deleted once all clients (including the JIT itself) have released their
- * shared pointers.
- */
-
-void LLVMOrcDisposeSharedModuleRef(LLVMSharedModuleRef SharedMod);
-
-/**
* Create an ORC JIT stack.
*
* The client owns the resulting stack, and must call OrcDisposeInstance(...)
@@ -126,7 +98,7 @@ LLVMOrcErrorCode LLVMOrcSetIndirectStubPointer(LLVMOrcJITStackRef JITStack,
LLVMOrcErrorCode
LLVMOrcAddEagerlyCompiledIR(LLVMOrcJITStackRef JITStack,
LLVMOrcModuleHandle *RetHandle,
- LLVMSharedModuleRef Mod,
+ LLVMModuleRef Mod,
LLVMOrcSymbolResolverFn SymbolResolver,
void *SymbolResolverCtx);
@@ -136,7 +108,7 @@ LLVMOrcAddEagerlyCompiledIR(LLVMOrcJITStackRef JITStack,
LLVMOrcErrorCode
LLVMOrcAddLazilyCompiledIR(LLVMOrcJITStackRef JITStack,
LLVMOrcModuleHandle *RetHandle,
- LLVMSharedModuleRef Mod,
+ LLVMModuleRef Mod,
LLVMOrcSymbolResolverFn SymbolResolver,
void *SymbolResolverCtx);
diff --git a/llvm/include/llvm/ExecutionEngine/Orc/CompileOnDemandLayer.h b/llvm/include/llvm/ExecutionEngine/Orc/CompileOnDemandLayer.h
index f0e9be9fd28..b393c66d842 100644
--- a/llvm/include/llvm/ExecutionEngine/Orc/CompileOnDemandLayer.h
+++ b/llvm/include/llvm/ExecutionEngine/Orc/CompileOnDemandLayer.h
@@ -138,7 +138,7 @@ private:
struct LogicalDylib {
struct SourceModuleEntry {
- std::shared_ptr<Module> SourceMod;
+ std::unique_ptr<Module> SourceMod;
std::set<Function*> StubsToClone;
};
@@ -153,7 +153,7 @@ private:
StubsMgr(std::move(StubsMgr)) {}
SourceModuleHandle
- addSourceModule(std::shared_ptr<Module> M) {
+ addSourceModule(std::unique_ptr<Module> M) {
SourceModuleHandle H = SourceModules.size();
SourceModules.push_back(SourceModuleEntry());
SourceModules.back().SourceMod = std::move(M);
@@ -232,7 +232,7 @@ public:
}
/// @brief Add a module to the compile-on-demand layer.
- Error addModule(VModuleKey K, std::shared_ptr<Module> M) {
+ Error addModule(VModuleKey K, std::unique_ptr<Module> M) {
assert(!LogicalDylibs.count(K) && "VModuleKey K already in use");
auto I = LogicalDylibs.insert(
@@ -244,7 +244,7 @@ public:
}
/// @brief Add extra modules to an existing logical module.
- Error addExtraModule(VModuleKey K, std::shared_ptr<Module> M) {
+ Error addExtraModule(VModuleKey K, std::unique_ptr<Module> M) {
return addLogicalModule(LogicalDylibs[K], std::move(M));
}
@@ -311,7 +311,7 @@ public:
private:
- Error addLogicalModule(LogicalDylib &LD, std::shared_ptr<Module> SrcMPtr) {
+ Error addLogicalModule(LogicalDylib &LD, std::unique_ptr<Module> SrcMPtr) {
// Rename all static functions / globals to $static.X :
// This will unique the names across all modules in the logical dylib,
diff --git a/llvm/include/llvm/ExecutionEngine/Orc/IRCompileLayer.h b/llvm/include/llvm/ExecutionEngine/Orc/IRCompileLayer.h
index 045dfc16b74..56ad57b0176 100644
--- a/llvm/include/llvm/ExecutionEngine/Orc/IRCompileLayer.h
+++ b/llvm/include/llvm/ExecutionEngine/Orc/IRCompileLayer.h
@@ -36,18 +36,33 @@ template <typename BaseLayerT, typename CompileFtor>
class IRCompileLayer {
public:
+ /// @brief Callback type for notifications when modules are compiled.
+ using NotifyCompiledCallback = std::function<void(VModuleKey K,
+ std::unique_ptr<Module>)>;
+
/// @brief Construct an IRCompileLayer with the given BaseLayer, which must
/// implement the ObjectLayer concept.
- IRCompileLayer(BaseLayerT &BaseLayer, CompileFtor Compile)
- : BaseLayer(BaseLayer), Compile(std::move(Compile)) {}
+ IRCompileLayer(BaseLayerT &BaseLayer, CompileFtor Compile,
+ NotifyCompiledCallback NotifyCompiled = NotifyCompiledCallback())
+ : BaseLayer(BaseLayer), Compile(std::move(Compile)),
+ NotifyCompiled(std::move(NotifyCompiled)) {}
/// @brief Get a reference to the compiler functor.
CompileFtor& getCompiler() { return Compile; }
+ /// @brief (Re)set the NotifyCompiled callback.
+ void setNotifyCompiled(NotifyCompiledCallback NotifyCompiled) {
+ this->NotifyCompiled = std::move(NotifyCompiled);
+ }
+
/// @brief Compile the module, and add the resulting object to the base layer
/// along with the given memory manager and symbol resolver.
- Error addModule(VModuleKey K, std::shared_ptr<Module> M) {
- return BaseLayer.addObject(std::move(K), Compile(*M));
+ Error addModule(VModuleKey K, std::unique_ptr<Module> M) {
+ if (auto Err = BaseLayer.addObject(std::move(K), Compile(*M)))
+ return Err;
+ if (NotifyCompiled)
+ NotifyCompiled(std::move(K), std::move(M));
+ return Error::success();
}
/// @brief Remove the module associated with the VModuleKey K.
@@ -82,6 +97,7 @@ public:
private:
BaseLayerT &BaseLayer;
CompileFtor Compile;
+ NotifyCompiledCallback NotifyCompiled;
};
} // end namespace orc
diff --git a/llvm/include/llvm/ExecutionEngine/Orc/IRTransformLayer.h b/llvm/include/llvm/ExecutionEngine/Orc/IRTransformLayer.h
index 2158ca9ac4c..4f1fe7ba0f5 100644
--- a/llvm/include/llvm/ExecutionEngine/Orc/IRTransformLayer.h
+++ b/llvm/include/llvm/ExecutionEngine/Orc/IRTransformLayer.h
@@ -40,7 +40,7 @@ public:
/// the layer below, along with the memory manager and symbol resolver.
///
/// @return A handle for the added modules.
- Error addModule(VModuleKey K, std::shared_ptr<Module> M) {
+ Error addModule(VModuleKey K, std::unique_ptr<Module> M) {
return BaseLayer.addModule(std::move(K), Transform(std::move(M)));
}
diff --git a/llvm/include/llvm/ExecutionEngine/Orc/LazyEmittingLayer.h b/llvm/include/llvm/ExecutionEngine/Orc/LazyEmittingLayer.h
index 35792eab6f9..d218b0542ce 100644
--- a/llvm/include/llvm/ExecutionEngine/Orc/LazyEmittingLayer.h
+++ b/llvm/include/llvm/ExecutionEngine/Orc/LazyEmittingLayer.h
@@ -41,9 +41,10 @@ namespace orc {
/// JITSymbol::getAddress) for a symbol contained in this layer.
template <typename BaseLayerT> class LazyEmittingLayer {
private:
+
class EmissionDeferredModule {
public:
- EmissionDeferredModule(VModuleKey K, std::shared_ptr<Module> M)
+ EmissionDeferredModule(VModuleKey K, std::unique_ptr<Module> M)
: K(std::move(K)), M(std::move(M)) {}
JITSymbol find(StringRef Name, bool ExportedSymbolsOnly, BaseLayerT &B) {
@@ -187,7 +188,7 @@ private:
enum { NotEmitted, Emitting, Emitted } EmitState = NotEmitted;
VModuleKey K;
- std::shared_ptr<Module> M;
+ std::unique_ptr<Module> M;
mutable std::unique_ptr<StringMap<const GlobalValue*>> MangledSymbols;
};
@@ -200,7 +201,7 @@ public:
LazyEmittingLayer(BaseLayerT &BaseLayer) : BaseLayer(BaseLayer) {}
/// @brief Add the given module to the lazy emitting layer.
- Error addModule(VModuleKey K, std::shared_ptr<Module> M) {
+ Error addModule(VModuleKey K, std::unique_ptr<Module> M) {
assert(!ModuleMap.count(K) && "VModuleKey K already in use");
ModuleMap[K] =
llvm::make_unique<EmissionDeferredModule>(std::move(K), std::move(M));
OpenPOWER on IntegriCloud