Skip to content

Commit

Permalink
[ORC] Rename ORC layers to make the "new" ORC layers the default.
Browse files Browse the repository at this point in the history
This commit adds a 'Legacy' prefix to old ORC layers and utilities, and removes
the '2' suffix from the new ORC layers. If you wish to continue using the old
ORC layers you will need to add a 'Legacy' prefix to your classes. If you were
already using the new ORC layers you will need to drop the '2' suffix.

The legacy layers will remain in-tree until the new layers reach feature
parity with them. This will involve adding support for removing code from the
new layers, and ensuring that performance is comperable.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@344572 91177308-0d34-0410-b5e6-96231b3b80d8
  • Loading branch information
lhames committed Oct 15, 2018
1 parent 270bd83 commit 582b119
Show file tree
Hide file tree
Showing 30 changed files with 564 additions and 564 deletions.
6 changes: 3 additions & 3 deletions examples/Kaleidoscope/BuildingAJIT/Chapter1/KaleidoscopeJIT.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@ class KaleidoscopeJIT {
std::shared_ptr<SymbolResolver> Resolver;
std::unique_ptr<TargetMachine> TM;
const DataLayout DL;
RTDyldObjectLinkingLayer ObjectLayer;
IRCompileLayer<decltype(ObjectLayer), SimpleCompiler> CompileLayer;
LegacyRTDyldObjectLinkingLayer ObjectLayer;
LegacyIRCompileLayer<decltype(ObjectLayer), SimpleCompiler> CompileLayer;

public:
KaleidoscopeJIT()
Expand All @@ -63,7 +63,7 @@ class KaleidoscopeJIT {
TM(EngineBuilder().selectTarget()), DL(TM->createDataLayout()),
ObjectLayer(ES,
[this](VModuleKey) {
return RTDyldObjectLinkingLayer::Resources{
return LegacyRTDyldObjectLinkingLayer::Resources{
std::make_shared<SectionMemoryManager>(), Resolver};
}),
CompileLayer(ObjectLayer, SimpleCompiler(*TM)) {
Expand Down
8 changes: 4 additions & 4 deletions examples/Kaleidoscope/BuildingAJIT/Chapter2/KaleidoscopeJIT.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,13 +47,13 @@ class KaleidoscopeJIT {
std::shared_ptr<SymbolResolver> Resolver;
std::unique_ptr<TargetMachine> TM;
const DataLayout DL;
RTDyldObjectLinkingLayer ObjectLayer;
IRCompileLayer<decltype(ObjectLayer), SimpleCompiler> CompileLayer;
LegacyRTDyldObjectLinkingLayer ObjectLayer;
LegacyIRCompileLayer<decltype(ObjectLayer), SimpleCompiler> CompileLayer;

using OptimizeFunction =
std::function<std::unique_ptr<Module>(std::unique_ptr<Module>)>;

IRTransformLayer<decltype(CompileLayer), OptimizeFunction> OptimizeLayer;
LegacyIRTransformLayer<decltype(CompileLayer), OptimizeFunction> OptimizeLayer;

public:
KaleidoscopeJIT()
Expand All @@ -73,7 +73,7 @@ class KaleidoscopeJIT {
TM(EngineBuilder().selectTarget()), DL(TM->createDataLayout()),
ObjectLayer(ES,
[this](VModuleKey) {
return RTDyldObjectLinkingLayer::Resources{
return LegacyRTDyldObjectLinkingLayer::Resources{
std::make_shared<SectionMemoryManager>(), Resolver};
}),
CompileLayer(ObjectLayer, SimpleCompiler(*TM)),
Expand Down
10 changes: 5 additions & 5 deletions examples/Kaleidoscope/BuildingAJIT/Chapter3/KaleidoscopeJIT.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,23 +51,23 @@ class KaleidoscopeJIT {
std::map<VModuleKey, std::shared_ptr<SymbolResolver>> Resolvers;
std::unique_ptr<TargetMachine> TM;
const DataLayout DL;
RTDyldObjectLinkingLayer ObjectLayer;
IRCompileLayer<decltype(ObjectLayer), SimpleCompiler> CompileLayer;
LegacyRTDyldObjectLinkingLayer ObjectLayer;
LegacyIRCompileLayer<decltype(ObjectLayer), SimpleCompiler> CompileLayer;

using OptimizeFunction =
std::function<std::unique_ptr<Module>(std::unique_ptr<Module>)>;

IRTransformLayer<decltype(CompileLayer), OptimizeFunction> OptimizeLayer;
LegacyIRTransformLayer<decltype(CompileLayer), OptimizeFunction> OptimizeLayer;

std::unique_ptr<JITCompileCallbackManager> CompileCallbackManager;
CompileOnDemandLayer<decltype(OptimizeLayer)> CODLayer;
LegacyCompileOnDemandLayer<decltype(OptimizeLayer)> CODLayer;

public:
KaleidoscopeJIT()
: TM(EngineBuilder().selectTarget()), DL(TM->createDataLayout()),
ObjectLayer(ES,
[this](VModuleKey K) {
return RTDyldObjectLinkingLayer::Resources{
return LegacyRTDyldObjectLinkingLayer::Resources{
std::make_shared<SectionMemoryManager>(),
Resolvers[K]};
}),
Expand Down
8 changes: 4 additions & 4 deletions examples/Kaleidoscope/BuildingAJIT/Chapter4/KaleidoscopeJIT.h
Original file line number Diff line number Diff line change
Expand Up @@ -77,13 +77,13 @@ class KaleidoscopeJIT {
std::shared_ptr<SymbolResolver> Resolver;
std::unique_ptr<TargetMachine> TM;
const DataLayout DL;
RTDyldObjectLinkingLayer ObjectLayer;
IRCompileLayer<decltype(ObjectLayer), SimpleCompiler> CompileLayer;
LegacyRTDyldObjectLinkingLayer ObjectLayer;
LegacyIRCompileLayer<decltype(ObjectLayer), SimpleCompiler> CompileLayer;

using OptimizeFunction =
std::function<std::unique_ptr<Module>(std::unique_ptr<Module>)>;

IRTransformLayer<decltype(CompileLayer), OptimizeFunction> OptimizeLayer;
LegacyIRTransformLayer<decltype(CompileLayer), OptimizeFunction> OptimizeLayer;

std::unique_ptr<JITCompileCallbackManager> CompileCallbackMgr;
std::unique_ptr<IndirectStubsManager> IndirectStubsMgr;
Expand All @@ -108,7 +108,7 @@ class KaleidoscopeJIT {
TM(EngineBuilder().selectTarget()), DL(TM->createDataLayout()),
ObjectLayer(ES,
[this](VModuleKey K) {
return RTDyldObjectLinkingLayer::Resources{
return LegacyRTDyldObjectLinkingLayer::Resources{
std::make_shared<SectionMemoryManager>(), Resolver};
}),
CompileLayer(ObjectLayer, SimpleCompiler(*TM)),
Expand Down
8 changes: 4 additions & 4 deletions examples/Kaleidoscope/BuildingAJIT/Chapter5/KaleidoscopeJIT.h
Original file line number Diff line number Diff line change
Expand Up @@ -82,13 +82,13 @@ class KaleidoscopeJIT {
std::shared_ptr<SymbolResolver> Resolver;
std::unique_ptr<TargetMachine> TM;
const DataLayout DL;
RTDyldObjectLinkingLayer ObjectLayer;
IRCompileLayer<decltype(ObjectLayer), SimpleCompiler> CompileLayer;
LegacyRTDyldObjectLinkingLayer ObjectLayer;
LegacyIRCompileLayer<decltype(ObjectLayer), SimpleCompiler> CompileLayer;

using OptimizeFunction =
std::function<std::unique_ptr<Module>(std::unique_ptr<Module>)>;

IRTransformLayer<decltype(CompileLayer), OptimizeFunction> OptimizeLayer;
LegacyIRTransformLayer<decltype(CompileLayer), OptimizeFunction> OptimizeLayer;

JITCompileCallbackManager *CompileCallbackMgr;
std::unique_ptr<IndirectStubsManager> IndirectStubsMgr;
Expand Down Expand Up @@ -116,7 +116,7 @@ class KaleidoscopeJIT {
DL(TM->createDataLayout()),
ObjectLayer(ES,
[this](VModuleKey K) {
return RTDyldObjectLinkingLayer::Resources{
return LegacyRTDyldObjectLinkingLayer::Resources{
cantFail(this->Remote.createRemoteMemoryManager()),
Resolver};
}),
Expand Down
4 changes: 2 additions & 2 deletions examples/Kaleidoscope/include/KaleidoscopeJIT.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ namespace orc {

class KaleidoscopeJIT {
public:
using ObjLayerT = RTDyldObjectLinkingLayer;
using CompileLayerT = IRCompileLayer<ObjLayerT, SimpleCompiler>;
using ObjLayerT = LegacyRTDyldObjectLinkingLayer;
using CompileLayerT = LegacyIRCompileLayer<ObjLayerT, SimpleCompiler>;

KaleidoscopeJIT()
: Resolver(createLegacyLookupResolver(
Expand Down
24 changes: 12 additions & 12 deletions include/llvm/ExecutionEngine/Orc/CompileOnDemandLayer.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ namespace orc {

class ExtractingIRMaterializationUnit;

class CompileOnDemandLayer2 : public IRLayer {
class CompileOnDemandLayer : public IRLayer {
friend class PartitioningIRMaterializationUnit;

public:
Expand All @@ -84,8 +84,8 @@ class CompileOnDemandLayer2 : public IRLayer {
/// symbol in them is requested.
static Optional<GlobalValueSet> compileWholeModule(GlobalValueSet Requested);

/// Construct a CompileOnDemandLayer2.
CompileOnDemandLayer2(ExecutionSession &ES, IRLayer &BaseLayer,
/// Construct a CompileOnDemandLayer.
CompileOnDemandLayer(ExecutionSession &ES, IRLayer &BaseLayer,
LazyCallThroughManager &LCTMgr,
IndirectStubsManagerBuilder BuildIndirectStubsManager);

Expand Down Expand Up @@ -142,7 +142,7 @@ class CompileOnDemandLayer2 : public IRLayer {
template <typename BaseLayerT,
typename CompileCallbackMgrT = JITCompileCallbackManager,
typename IndirectStubsMgrT = IndirectStubsManager>
class CompileOnDemandLayer {
class LegacyCompileOnDemandLayer {
private:
template <typename MaterializerFtor>
class LambdaMaterializer final : public ValueMaterializer {
Expand Down Expand Up @@ -266,21 +266,21 @@ class CompileOnDemandLayer {
std::function<void(VModuleKey K, std::shared_ptr<SymbolResolver> R)>;

/// Construct a compile-on-demand layer instance.
CompileOnDemandLayer(ExecutionSession &ES, BaseLayerT &BaseLayer,
SymbolResolverGetter GetSymbolResolver,
SymbolResolverSetter SetSymbolResolver,
PartitioningFtor Partition,
CompileCallbackMgrT &CallbackMgr,
IndirectStubsManagerBuilderT CreateIndirectStubsManager,
bool CloneStubsIntoPartitions = true)
LegacyCompileOnDemandLayer(ExecutionSession &ES, BaseLayerT &BaseLayer,
SymbolResolverGetter GetSymbolResolver,
SymbolResolverSetter SetSymbolResolver,
PartitioningFtor Partition,
CompileCallbackMgrT &CallbackMgr,
IndirectStubsManagerBuilderT CreateIndirectStubsManager,
bool CloneStubsIntoPartitions = true)
: ES(ES), BaseLayer(BaseLayer),
GetSymbolResolver(std::move(GetSymbolResolver)),
SetSymbolResolver(std::move(SetSymbolResolver)),
Partition(std::move(Partition)), CompileCallbackMgr(CallbackMgr),
CreateIndirectStubsManager(std::move(CreateIndirectStubsManager)),
CloneStubsIntoPartitions(CloneStubsIntoPartitions) {}

~CompileOnDemandLayer() {
~LegacyCompileOnDemandLayer() {
// FIXME: Report error on log.
while (!LogicalDylibs.empty())
consumeError(removeModule(LogicalDylibs.begin()->first));
Expand Down
14 changes: 7 additions & 7 deletions include/llvm/ExecutionEngine/Orc/ExecutionUtils.h
Original file line number Diff line number Diff line change
Expand Up @@ -94,11 +94,11 @@ iterator_range<CtorDtorIterator> getDestructors(const Module &M);
/// Convenience class for recording constructor/destructor names for
/// later execution.
template <typename JITLayerT>
class CtorDtorRunner {
class LegacyCtorDtorRunner {
public:
/// Construct a CtorDtorRunner for the given range using the given
/// name mangling function.
CtorDtorRunner(std::vector<std::string> CtorDtorNames, VModuleKey K)
LegacyCtorDtorRunner(std::vector<std::string> CtorDtorNames, VModuleKey K)
: CtorDtorNames(std::move(CtorDtorNames)), K(K) {}

/// Run the recorded constructors/destructors through the given JIT
Expand Down Expand Up @@ -129,9 +129,9 @@ class CtorDtorRunner {
orc::VModuleKey K;
};

class CtorDtorRunner2 {
class CtorDtorRunner {
public:
CtorDtorRunner2(JITDylib &JD) : JD(JD) {}
CtorDtorRunner(JITDylib &JD) : JD(JD) {}
void add(iterator_range<CtorDtorIterator> CtorDtors);
Error run();

Expand Down Expand Up @@ -177,11 +177,11 @@ class LocalCXXRuntimeOverridesBase {
void *DSOHandle);
};

class LocalCXXRuntimeOverrides : public LocalCXXRuntimeOverridesBase {
class LegacyLocalCXXRuntimeOverrides : public LocalCXXRuntimeOverridesBase {
public:
/// Create a runtime-overrides class.
template <typename MangleFtorT>
LocalCXXRuntimeOverrides(const MangleFtorT &Mangle) {
LegacyLocalCXXRuntimeOverrides(const MangleFtorT &Mangle) {
addOverride(Mangle("__dso_handle"), toTargetAddress(&DSOHandleOverride));
addOverride(Mangle("__cxa_atexit"), toTargetAddress(&CXAAtExitOverride));
}
Expand All @@ -202,7 +202,7 @@ class LocalCXXRuntimeOverrides : public LocalCXXRuntimeOverridesBase {
StringMap<JITTargetAddress> CXXRuntimeOverrides;
};

class LocalCXXRuntimeOverrides2 : public LocalCXXRuntimeOverridesBase {
class LocalCXXRuntimeOverrides : public LocalCXXRuntimeOverridesBase {
public:
Error enable(JITDylib &JD, MangleAndInterner &Mangler);
};
Expand Down
12 changes: 6 additions & 6 deletions include/llvm/ExecutionEngine/Orc/IRCompileLayer.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,16 +28,16 @@ class Module;

namespace orc {

class IRCompileLayer2 : public IRLayer {
class IRCompileLayer : public IRLayer {
public:
using CompileFunction =
std::function<Expected<std::unique_ptr<MemoryBuffer>>(Module &)>;

using NotifyCompiledFunction =
std::function<void(VModuleKey K, ThreadSafeModule TSM)>;

IRCompileLayer2(ExecutionSession &ES, ObjectLayer &BaseLayer,
CompileFunction Compile);
IRCompileLayer(ExecutionSession &ES, ObjectLayer &BaseLayer,
CompileFunction Compile);

void setNotifyCompiled(NotifyCompiledFunction NotifyCompiled);

Expand All @@ -57,15 +57,15 @@ class IRCompileLayer2 : public IRLayer {
/// object file and adds this module file to the layer below, which must
/// implement the object layer concept.
template <typename BaseLayerT, typename CompileFtor>
class IRCompileLayer {
class LegacyIRCompileLayer {
public:
/// Callback type for notifications when modules are compiled.
using NotifyCompiledCallback =
std::function<void(VModuleKey K, std::unique_ptr<Module>)>;

/// Construct an IRCompileLayer with the given BaseLayer, which must
/// Construct an LegacyIRCompileLayer with the given BaseLayer, which must
/// implement the ObjectLayer concept.
IRCompileLayer(
LegacyIRCompileLayer(
BaseLayerT &BaseLayer, CompileFtor Compile,
NotifyCompiledCallback NotifyCompiled = NotifyCompiledCallback())
: BaseLayer(BaseLayer), Compile(std::move(Compile)),
Expand Down
12 changes: 6 additions & 6 deletions include/llvm/ExecutionEngine/Orc/IRTransformLayer.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,13 @@ namespace llvm {
class Module;
namespace orc {

class IRTransformLayer2 : public IRLayer {
class IRTransformLayer : public IRLayer {
public:
using TransformFunction = std::function<Expected<ThreadSafeModule>(
ThreadSafeModule, const MaterializationResponsibility &R)>;

IRTransformLayer2(ExecutionSession &ES, IRLayer &BaseLayer,
TransformFunction Transform = identityTransform);
IRTransformLayer(ExecutionSession &ES, IRLayer &BaseLayer,
TransformFunction Transform = identityTransform);

void setTransform(TransformFunction Transform) {
this->Transform = std::move(Transform);
Expand All @@ -54,11 +54,11 @@ class IRTransformLayer2 : public IRLayer {
/// This layer applies a user supplied transform to each module that is added,
/// then adds the transformed module to the layer below.
template <typename BaseLayerT, typename TransformFtor>
class IRTransformLayer {
class LegacyIRTransformLayer {
public:

/// Construct an IRTransformLayer with the given BaseLayer
IRTransformLayer(BaseLayerT &BaseLayer,
/// Construct an LegacyIRTransformLayer with the given BaseLayer
LegacyIRTransformLayer(BaseLayerT &BaseLayer,
TransformFtor Transform = TransformFtor())
: BaseLayer(BaseLayer), Transform(std::move(Transform)) {}

Expand Down
16 changes: 8 additions & 8 deletions include/llvm/ExecutionEngine/Orc/LLJIT.h
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ class LLJIT {
Error runDestructors() { return DtorRunner.run(); }

/// Returns a reference to the ObjLinkingLayer
RTDyldObjectLinkingLayer2 &getObjLinkingLayer() { return ObjLinkingLayer; }
RTDyldObjectLinkingLayer &getObjLinkingLayer() { return ObjLinkingLayer; }

protected:

Expand All @@ -125,10 +125,10 @@ class LLJIT {
DataLayout DL;
std::unique_ptr<ThreadPool> CompileThreads;

RTDyldObjectLinkingLayer2 ObjLinkingLayer;
IRCompileLayer2 CompileLayer;
RTDyldObjectLinkingLayer ObjLinkingLayer;
IRCompileLayer CompileLayer;

CtorDtorRunner2 CtorRunner, DtorRunner;
CtorDtorRunner CtorRunner, DtorRunner;
};

/// An extended version of LLJIT that supports lazy function-at-a-time
Expand All @@ -145,13 +145,13 @@ class LLLazyJIT : public LLJIT {

/// Set an IR transform (e.g. pass manager pipeline) to run on each function
/// when it is compiled.
void setLazyCompileTransform(IRTransformLayer2::TransformFunction Transform) {
void setLazyCompileTransform(IRTransformLayer::TransformFunction Transform) {
TransformLayer.setTransform(std::move(Transform));
}

/// Sets the partition function.
void
setPartitionFunction(CompileOnDemandLayer2::PartitionFunction Partition) {
setPartitionFunction(CompileOnDemandLayer::PartitionFunction Partition) {
CODLayer.setPartitionFunction(std::move(Partition));
}

Expand Down Expand Up @@ -180,8 +180,8 @@ class LLLazyJIT : public LLJIT {
std::unique_ptr<LazyCallThroughManager> LCTMgr;
std::function<std::unique_ptr<IndirectStubsManager>()> ISMBuilder;

IRTransformLayer2 TransformLayer;
CompileOnDemandLayer2 CODLayer;
IRTransformLayer TransformLayer;
CompileOnDemandLayer CODLayer;
};

} // End namespace orc
Expand Down
12 changes: 6 additions & 6 deletions include/llvm/ExecutionEngine/Orc/ObjectTransformLayer.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,14 @@
namespace llvm {
namespace orc {

class ObjectTransformLayer2 : public ObjectLayer {
class ObjectTransformLayer : public ObjectLayer {
public:
using TransformFunction =
std::function<Expected<std::unique_ptr<MemoryBuffer>>(
std::unique_ptr<MemoryBuffer>)>;

ObjectTransformLayer2(ExecutionSession &ES, ObjectLayer &BaseLayer,
TransformFunction Transform);
ObjectTransformLayer(ExecutionSession &ES, ObjectLayer &BaseLayer,
TransformFunction Transform);

void emit(MaterializationResponsibility R, VModuleKey K,
std::unique_ptr<MemoryBuffer> O) override;
Expand All @@ -46,11 +46,11 @@ class ObjectTransformLayer2 : public ObjectLayer {
/// immediately applies the user supplied functor to each object, then adds
/// the set of transformed objects to the layer below.
template <typename BaseLayerT, typename TransformFtor>
class ObjectTransformLayer {
class LegacyObjectTransformLayer {
public:
/// Construct an ObjectTransformLayer with the given BaseLayer
ObjectTransformLayer(BaseLayerT &BaseLayer,
TransformFtor Transform = TransformFtor())
LegacyObjectTransformLayer(BaseLayerT &BaseLayer,
TransformFtor Transform = TransformFtor())
: BaseLayer(BaseLayer), Transform(std::move(Transform)) {}

/// Apply the transform functor to each object in the object set, then
Expand Down
Loading

0 comments on commit 582b119

Please sign in to comment.