Skip to content

Commit a5eb9df

Browse files
[Orc][NFC] Turn LLJIT member ObjTransformLayer into unique_ptr
All other layers in LLJIT are stored as unique_ptr's already. At this point, it is not strictly necessary for ObjTransformLayer, but it makes a follow-up change more straightforward. Reviewed By: lhames Differential Revision: https://reviews.llvm.org/D94689
1 parent 2b8db40 commit a5eb9df

File tree

2 files changed

+10
-7
lines changed

2 files changed

+10
-7
lines changed

llvm/include/llvm/ExecutionEngine/Orc/LLJIT.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
#include "llvm/ExecutionEngine/Orc/IRCompileLayer.h"
2020
#include "llvm/ExecutionEngine/Orc/IRTransformLayer.h"
2121
#include "llvm/ExecutionEngine/Orc/JITTargetMachineBuilder.h"
22-
#include "llvm/ExecutionEngine/Orc/ObjectTransformLayer.h"
2322
#include "llvm/ExecutionEngine/Orc/ThreadSafeModule.h"
2423
#include "llvm/Support/Debug.h"
2524
#include "llvm/Support/ThreadPool.h"
@@ -29,6 +28,7 @@ namespace orc {
2928

3029
class LLJITBuilderState;
3130
class LLLazyJITBuilderState;
31+
class ObjectTransformLayer;
3232
class TargetProcessControl;
3333

3434
/// A pre-fabricated ORC JIT stack that can serve as an alternative to MCJIT.
@@ -169,7 +169,7 @@ class LLJIT {
169169
ObjectLayer &getObjLinkingLayer() { return *ObjLinkingLayer; }
170170

171171
/// Returns a reference to the object transform layer.
172-
ObjectTransformLayer &getObjTransformLayer() { return ObjTransformLayer; }
172+
ObjectTransformLayer &getObjTransformLayer() { return *ObjTransformLayer; }
173173

174174
/// Returns a reference to the IR transform layer.
175175
IRTransformLayer &getIRTransformLayer() { return *TransformLayer; }
@@ -209,7 +209,7 @@ class LLJIT {
209209
std::unique_ptr<ThreadPool> CompileThreads;
210210

211211
std::unique_ptr<ObjectLayer> ObjLinkingLayer;
212-
ObjectTransformLayer ObjTransformLayer;
212+
std::unique_ptr<ObjectTransformLayer> ObjTransformLayer;
213213
std::unique_ptr<IRCompileLayer> CompileLayer;
214214
std::unique_ptr<IRTransformLayer> TransformLayer;
215215
std::unique_ptr<IRTransformLayer> InitHelperTransformLayer;

llvm/lib/ExecutionEngine/Orc/LLJIT.cpp

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
#include "llvm/ExecutionEngine/JITLink/JITLinkMemoryManager.h"
1212
#include "llvm/ExecutionEngine/Orc/MachOPlatform.h"
1313
#include "llvm/ExecutionEngine/Orc/ObjectLinkingLayer.h"
14+
#include "llvm/ExecutionEngine/Orc/ObjectTransformLayer.h"
1415
#include "llvm/ExecutionEngine/Orc/OrcError.h"
1516
#include "llvm/ExecutionEngine/Orc/RTDyldObjectLinkingLayer.h"
1617
#include "llvm/ExecutionEngine/Orc/TargetProcessControl.h"
@@ -997,7 +998,7 @@ Error LLJIT::addObjectFile(ResourceTrackerSP RT,
997998
std::unique_ptr<MemoryBuffer> Obj) {
998999
assert(Obj && "Can not add null object");
9991000

1000-
return ObjTransformLayer.add(std::move(RT), std::move(Obj));
1001+
return ObjTransformLayer->add(std::move(RT), std::move(Obj));
10011002
}
10021003

10031004
Error LLJIT::addObjectFile(JITDylib &JD, std::unique_ptr<MemoryBuffer> Obj) {
@@ -1057,8 +1058,7 @@ LLJIT::createCompileFunction(LLJITBuilderState &S,
10571058
LLJIT::LLJIT(LLJITBuilderState &S, Error &Err)
10581059
: ES(S.ES ? std::move(S.ES) : std::make_unique<ExecutionSession>()), Main(),
10591060
DL(""), TT(S.JTMB->getTargetTriple()),
1060-
ObjLinkingLayer(createObjectLinkingLayer(S, *ES)),
1061-
ObjTransformLayer(*this->ES, *ObjLinkingLayer) {
1061+
ObjLinkingLayer(createObjectLinkingLayer(S, *ES)) {
10621062

10631063
ErrorAsOutParameter _(&Err);
10641064

@@ -1078,14 +1078,17 @@ LLJIT::LLJIT(LLJITBuilderState &S, Error &Err)
10781078
return;
10791079
}
10801080

1081+
ObjTransformLayer =
1082+
std::make_unique<ObjectTransformLayer>(*ES, *ObjLinkingLayer);
1083+
10811084
{
10821085
auto CompileFunction = createCompileFunction(S, std::move(*S.JTMB));
10831086
if (!CompileFunction) {
10841087
Err = CompileFunction.takeError();
10851088
return;
10861089
}
10871090
CompileLayer = std::make_unique<IRCompileLayer>(
1088-
*ES, ObjTransformLayer, std::move(*CompileFunction));
1091+
*ES, *ObjTransformLayer, std::move(*CompileFunction));
10891092
TransformLayer = std::make_unique<IRTransformLayer>(*ES, *CompileLayer);
10901093
InitHelperTransformLayer =
10911094
std::make_unique<IRTransformLayer>(*ES, *TransformLayer);

0 commit comments

Comments
 (0)