[llvm] r229451 - [Orc] Add an emitAndFinalize method to the ObjectLinkingLayer, IRCompileLayer
Lang Hames
lhames at gmail.com
Mon Feb 16 14:36:26 PST 2015
Author: lhames
Date: Mon Feb 16 16:36:25 2015
New Revision: 229451
URL: http://llvm.org/viewvc/llvm-project?rev=229451&view=rev
Log:
[Orc] Add an emitAndFinalize method to the ObjectLinkingLayer, IRCompileLayer
and LazyEmittingLayer of Orc.
This method allows you to immediately emit and finalize a module. It is required
by an upcoming refactor of the indirection utils and the compile-on-demand
layer.
I've filed http://llvm.org/PR22608 to write unit tests for this and other Orc
APIs.
Modified:
llvm/trunk/include/llvm/ExecutionEngine/Orc/IRCompileLayer.h
llvm/trunk/include/llvm/ExecutionEngine/Orc/LazyEmittingLayer.h
llvm/trunk/include/llvm/ExecutionEngine/Orc/ObjectLinkingLayer.h
Modified: llvm/trunk/include/llvm/ExecutionEngine/Orc/IRCompileLayer.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/ExecutionEngine/Orc/IRCompileLayer.h?rev=229451&r1=229450&r2=229451&view=diff
==============================================================================
--- llvm/trunk/include/llvm/ExecutionEngine/Orc/IRCompileLayer.h (original)
+++ llvm/trunk/include/llvm/ExecutionEngine/Orc/IRCompileLayer.h Mon Feb 16 16:36:25 2015
@@ -111,6 +111,13 @@ public:
return BaseLayer.findSymbolIn(H, Name, ExportedSymbolsOnly);
}
+ /// @brief Immediately emit and finalize the moduleOB set represented by the
+ /// given handle.
+ /// @param H Handle for module set to emit/finalize.
+ void emitAndFinalize(ModuleSetHandleT H) {
+ BaseLayer.emitAndFinalize(H);
+ }
+
private:
object::OwningBinary<object::ObjectFile>
tryToLoadFromObjectCache(const Module &M) {
Modified: llvm/trunk/include/llvm/ExecutionEngine/Orc/LazyEmittingLayer.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/ExecutionEngine/Orc/LazyEmittingLayer.h?rev=229451&r1=229450&r2=229451&view=diff
==============================================================================
--- llvm/trunk/include/llvm/ExecutionEngine/Orc/LazyEmittingLayer.h (original)
+++ llvm/trunk/include/llvm/ExecutionEngine/Orc/LazyEmittingLayer.h Mon Feb 16 16:36:25 2015
@@ -53,7 +53,7 @@ private:
return 0;
else if (this->EmitState == NotEmitted) {
this->EmitState = Emitting;
- Handle = this->emit(B);
+ Handle = this->emitToBaseLayer(B);
this->EmitState = Emitted;
}
return B.findSymbolIn(Handle, PName, ExportedSymbolsOnly)
@@ -78,6 +78,17 @@ private:
BaseLayer.removeModuleSet(Handle);
}
+ void emitAndFinalize(BaseLayerT &BaseLayer) {
+ assert(EmitState != Emitting &&
+ "Cannot emitAndFinalize while already emitting");
+ if (EmitState == NotEmitted) {
+ EmitState = Emitting;
+ Handle = emitToBaseLayer(BaseLayer);
+ EmitState = Emitted;
+ }
+ BaseLayer.emitAndFinalize(Handle);
+ }
+
template <typename ModuleSetT>
static std::unique_ptr<EmissionDeferredSet>
create(BaseLayerT &B, ModuleSetT Ms,
@@ -85,7 +96,7 @@ private:
protected:
virtual bool provides(StringRef Name, bool ExportedSymbolsOnly) const = 0;
- virtual BaseLayerHandleT emit(BaseLayerT &BaseLayer) = 0;
+ virtual BaseLayerHandleT emitToBaseLayer(BaseLayerT &BaseLayer) = 0;
private:
enum { NotEmitted, Emitting, Emitted } EmitState;
@@ -100,7 +111,8 @@ private:
: Ms(std::move(Ms)), MM(std::move(MM)) {}
protected:
- BaseLayerHandleT emit(BaseLayerT &BaseLayer) override {
+
+ BaseLayerHandleT emitToBaseLayer(BaseLayerT &BaseLayer) override {
// We don't need the mangled names set any more: Once we've emitted this
// to the base layer we'll just look for symbols there.
MangledNames.reset();
@@ -243,6 +255,14 @@ public:
bool ExportedSymbolsOnly) {
return (*H)->find(Name, ExportedSymbolsOnly, BaseLayer);
}
+
+ /// @brief Immediately emit and finalize the moduleOB set represented by the
+ /// given handle.
+ /// @param H Handle for module set to emit/finalize.
+ void emitAndFinalize(ModuleSetHandleT H) {
+ (*H)->emitAndFinalize(BaseLayer);
+ }
+
};
template <typename BaseLayerT>
Modified: llvm/trunk/include/llvm/ExecutionEngine/Orc/ObjectLinkingLayer.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/ExecutionEngine/Orc/ObjectLinkingLayer.h?rev=229451&r1=229450&r2=229451&view=diff
==============================================================================
--- llvm/trunk/include/llvm/ExecutionEngine/Orc/ObjectLinkingLayer.h (original)
+++ llvm/trunk/include/llvm/ExecutionEngine/Orc/ObjectLinkingLayer.h Mon Feb 16 16:36:25 2015
@@ -178,12 +178,6 @@ public:
return Handle;
}
- /// @brief Map section addresses for the objects associated with the handle H.
- void mapSectionAddress(ObjSetHandleT H, const void *LocalAddress,
- TargetAddress TargetAddr) {
- H->mapSectionAddress(LocalAddress, TargetAddr);
- }
-
/// @brief Remove the set of objects associated with handle H.
///
/// All memory allocated for the objects will be freed, and the sections and
@@ -233,6 +227,21 @@ public:
return nullptr;
}
+ /// @brief Map section addresses for the objects associated with the handle H.
+ void mapSectionAddress(ObjSetHandleT H, const void *LocalAddress,
+ TargetAddress TargetAddr) {
+ H->mapSectionAddress(LocalAddress, TargetAddr);
+ }
+
+ /// @brief Immediately emit and finalize the object set represented by the
+ /// given handle.
+ /// @param H Handle for object set to emit/finalize.
+ void emitAndFinalize(ObjSetHandleT H) {
+ H->Finalize();
+ if (NotifyFinalized)
+ NotifyFinalized(H);
+ }
+
private:
LinkedObjectSetListT LinkedObjSetList;
NotifyLoadedFtor NotifyLoaded;
More information about the llvm-commits
mailing list