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.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@229451
91177308-0d34-0410-b5e6-
96231b3b80d8
return BaseLayer.findSymbolIn(H, Name, ExportedSymbolsOnly);
}
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) {
private:
object::OwningBinary<object::ObjectFile>
tryToLoadFromObjectCache(const Module &M) {
return 0;
else if (this->EmitState == NotEmitted) {
this->EmitState = Emitting;
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)
this->EmitState = Emitted;
}
return B.findSymbolIn(Handle, PName, ExportedSymbolsOnly)
BaseLayer.removeModuleSet(Handle);
}
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,
template <typename ModuleSetT>
static std::unique_ptr<EmissionDeferredSet>
create(BaseLayerT &B, ModuleSetT Ms,
protected:
virtual bool provides(StringRef Name, bool ExportedSymbolsOnly) const = 0;
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;
private:
enum { NotEmitted, Emitting, Emitted } EmitState;
: Ms(std::move(Ms)), MM(std::move(MM)) {}
protected:
: 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();
// 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();
bool ExportedSymbolsOnly) {
return (*H)->find(Name, ExportedSymbolsOnly, BaseLayer);
}
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>
};
template <typename BaseLayerT>
- /// @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
/// @brief Remove the set of objects associated with handle H.
///
/// All memory allocated for the objects will be freed, and the sections and
+ /// @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;
private:
LinkedObjectSetListT LinkedObjSetList;
NotifyLoadedFtor NotifyLoaded;