Skip to content

Commit 47682e4

Browse files
committed
Revert "[ORC] Implement basic reoptimization. (#67050)"
This reverts commit 0d288e5. Breaks the build.
1 parent 82d8760 commit 47682e4

21 files changed

+325
-1548
lines changed

compiler-rt/lib/orc/common.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,9 @@
1919

2020
/// This macro should be used to define tags that will be associated with
2121
/// handlers in the JIT process, and call can be used to define tags f
22-
#define ORC_RT_JIT_DISPATCH_TAG(X) \
23-
ORC_RT_INTERFACE char X; \
24-
char X = 0;
22+
#define ORC_RT_JIT_DISPATCH_TAG(X) \
23+
extern "C" char X; \
24+
char X = 0;
2525

2626
/// Opaque struct for external symbols.
2727
struct __orc_rt_Opaque {};

compiler-rt/lib/orc/elfnix_platform.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ using namespace __orc_rt;
2828
using namespace __orc_rt::elfnix;
2929

3030
// Declare function tags for functions in the JIT process.
31-
ORC_RT_JIT_DISPATCH_TAG(__orc_rt_reoptimize_tag)
3231
ORC_RT_JIT_DISPATCH_TAG(__orc_rt_elfnix_get_initializers_tag)
3332
ORC_RT_JIT_DISPATCH_TAG(__orc_rt_elfnix_get_deinitializers_tag)
3433
ORC_RT_JIT_DISPATCH_TAG(__orc_rt_elfnix_symbol_lookup_tag)

llvm/examples/Kaleidoscope/BuildingAJIT/Chapter3/KaleidoscopeJIT.h

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121
#include "llvm/ExecutionEngine/Orc/ExecutionUtils.h"
2222
#include "llvm/ExecutionEngine/Orc/ExecutorProcessControl.h"
2323
#include "llvm/ExecutionEngine/Orc/IRCompileLayer.h"
24-
#include "llvm/ExecutionEngine/Orc/IRPartitionLayer.h"
2524
#include "llvm/ExecutionEngine/Orc/IRTransformLayer.h"
2625
#include "llvm/ExecutionEngine/Orc/JITTargetMachineBuilder.h"
2726
#include "llvm/ExecutionEngine/Orc/RTDyldObjectLinkingLayer.h"
@@ -49,7 +48,6 @@ class KaleidoscopeJIT {
4948
RTDyldObjectLinkingLayer ObjectLayer;
5049
IRCompileLayer CompileLayer;
5150
IRTransformLayer OptimizeLayer;
52-
IRPartitionLayer IPLayer;
5351
CompileOnDemandLayer CODLayer;
5452

5553
JITDylib &MainJD;
@@ -70,8 +68,8 @@ class KaleidoscopeJIT {
7068
CompileLayer(*this->ES, ObjectLayer,
7169
std::make_unique<ConcurrentIRCompiler>(std::move(JTMB))),
7270
OptimizeLayer(*this->ES, CompileLayer, optimizeModule),
73-
IPLayer(*this->ES, OptimizeLayer),
74-
CODLayer(*this->ES, IPLayer, this->EPCIU->getLazyCallThroughManager(),
71+
CODLayer(*this->ES, OptimizeLayer,
72+
this->EPCIU->getLazyCallThroughManager(),
7573
[this] { return this->EPCIU->createIndirectStubsManager(); }),
7674
MainJD(this->ES->createBareJITDylib("<main>")) {
7775
MainJD.addGenerator(

llvm/examples/SpeculativeJIT/SpeculativeJIT.cpp

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
#include "llvm/ExecutionEngine/Orc/Core.h"
44
#include "llvm/ExecutionEngine/Orc/ExecutionUtils.h"
55
#include "llvm/ExecutionEngine/Orc/IRCompileLayer.h"
6-
#include "llvm/ExecutionEngine/Orc/IRPartitionLayer.h"
76
#include "llvm/ExecutionEngine/Orc/IndirectionUtils.h"
87
#include "llvm/ExecutionEngine/Orc/JITTargetMachineBuilder.h"
98
#include "llvm/ExecutionEngine/Orc/RTDyldObjectLinkingLayer.h"
@@ -110,14 +109,13 @@ class SpeculativeJIT {
110109
IndirectStubsManagerBuilderFunction ISMBuilder,
111110
std::unique_ptr<DynamicLibrarySearchGenerator> ProcessSymbolsGenerator)
112111
: ES(std::move(ES)), DL(std::move(DL)),
113-
MainJD(this->ES->createBareJITDylib("<main>")),
114-
LCTMgr(std::move(LCTMgr)),
112+
MainJD(this->ES->createBareJITDylib("<main>")), LCTMgr(std::move(LCTMgr)),
115113
CompileLayer(*this->ES, ObjLayer,
116114
std::make_unique<ConcurrentIRCompiler>(std::move(JTMB))),
117115
S(Imps, *this->ES),
118116
SpeculateLayer(*this->ES, CompileLayer, S, Mangle, BlockFreqQuery()),
119-
IPLayer(*this->ES, SpeculateLayer),
120-
CODLayer(*this->ES, IPLayer, *this->LCTMgr, std::move(ISMBuilder)) {
117+
CODLayer(*this->ES, SpeculateLayer, *this->LCTMgr,
118+
std::move(ISMBuilder)) {
121119
MainJD.addGenerator(std::move(ProcessSymbolsGenerator));
122120
this->CODLayer.setImplMap(&Imps);
123121
ExitOnErr(S.addSpeculationRuntime(MainJD, Mangle));
@@ -143,7 +141,6 @@ class SpeculativeJIT {
143141
Speculator S;
144142
RTDyldObjectLinkingLayer ObjLayer{*ES, createMemMgr};
145143
IRSpeculationLayer SpeculateLayer;
146-
IRPartitionLayer IPLayer;
147144
CompileOnDemandLayer CODLayer;
148145
};
149146

llvm/include/llvm/ExecutionEngine/Orc/CompileOnDemandLayer.h

Lines changed: 34 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,15 +53,37 @@ namespace llvm {
5353
namespace orc {
5454

5555
class CompileOnDemandLayer : public IRLayer {
56+
friend class PartitioningIRMaterializationUnit;
57+
5658
public:
5759
/// Builder for IndirectStubsManagers.
5860
using IndirectStubsManagerBuilder =
5961
std::function<std::unique_ptr<IndirectStubsManager>()>;
6062

63+
using GlobalValueSet = std::set<const GlobalValue *>;
64+
65+
/// Partitioning function.
66+
using PartitionFunction =
67+
std::function<std::optional<GlobalValueSet>(GlobalValueSet Requested)>;
68+
69+
/// Off-the-shelf partitioning which compiles all requested symbols (usually
70+
/// a single function at a time).
71+
static std::optional<GlobalValueSet>
72+
compileRequested(GlobalValueSet Requested);
73+
74+
/// Off-the-shelf partitioning which compiles whole modules whenever any
75+
/// symbol in them is requested.
76+
static std::optional<GlobalValueSet>
77+
compileWholeModule(GlobalValueSet Requested);
78+
6179
/// Construct a CompileOnDemandLayer.
6280
CompileOnDemandLayer(ExecutionSession &ES, IRLayer &BaseLayer,
63-
LazyCallThroughManager &LCTMgr,
64-
IndirectStubsManagerBuilder BuildIndirectStubsManager);
81+
LazyCallThroughManager &LCTMgr,
82+
IndirectStubsManagerBuilder BuildIndirectStubsManager);
83+
84+
/// Sets the partition function.
85+
void setPartitionFunction(PartitionFunction Partition);
86+
6587
/// Sets the ImplSymbolMap
6688
void setImplMap(ImplSymbolMap *Imp);
6789

@@ -88,12 +110,22 @@ class CompileOnDemandLayer : public IRLayer {
88110

89111
PerDylibResources &getPerDylibResources(JITDylib &TargetD);
90112

113+
void cleanUpModule(Module &M);
114+
115+
void expandPartition(GlobalValueSet &Partition);
116+
117+
void emitPartition(std::unique_ptr<MaterializationResponsibility> R,
118+
ThreadSafeModule TSM,
119+
IRMaterializationUnit::SymbolNameToDefinitionMap Defs);
120+
91121
mutable std::mutex CODLayerMutex;
92122

93123
IRLayer &BaseLayer;
94124
LazyCallThroughManager &LCTMgr;
95125
IndirectStubsManagerBuilder BuildIndirectStubsManager;
96126
PerDylibResourcesMap DylibResources;
127+
PartitionFunction Partition = compileRequested;
128+
SymbolLinkagePromoter PromoteSymbols;
97129
ImplSymbolMap *AliaseeImpls = nullptr;
98130
};
99131

llvm/include/llvm/ExecutionEngine/Orc/IRPartitionLayer.h

Lines changed: 0 additions & 85 deletions
This file was deleted.

llvm/include/llvm/ExecutionEngine/Orc/JITLinkRedirectableSymbolManager.h

Lines changed: 0 additions & 107 deletions
This file was deleted.

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

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
#include "llvm/ExecutionEngine/Orc/CompileUtils.h"
1818
#include "llvm/ExecutionEngine/Orc/ExecutionUtils.h"
1919
#include "llvm/ExecutionEngine/Orc/IRCompileLayer.h"
20-
#include "llvm/ExecutionEngine/Orc/IRPartitionLayer.h"
2120
#include "llvm/ExecutionEngine/Orc/IRTransformLayer.h"
2221
#include "llvm/ExecutionEngine/Orc/JITTargetMachineBuilder.h"
2322
#include "llvm/ExecutionEngine/Orc/ThreadSafeModule.h"
@@ -271,8 +270,9 @@ class LLLazyJIT : public LLJIT {
271270
public:
272271

273272
/// Sets the partition function.
274-
void setPartitionFunction(IRPartitionLayer::PartitionFunction Partition) {
275-
IPLayer->setPartitionFunction(std::move(Partition));
273+
void
274+
setPartitionFunction(CompileOnDemandLayer::PartitionFunction Partition) {
275+
CODLayer->setPartitionFunction(std::move(Partition));
276276
}
277277

278278
/// Returns a reference to the on-demand layer.
@@ -292,7 +292,6 @@ class LLLazyJIT : public LLJIT {
292292
LLLazyJIT(LLLazyJITBuilderState &S, Error &Err);
293293

294294
std::unique_ptr<LazyCallThroughManager> LCTMgr;
295-
std::unique_ptr<IRPartitionLayer> IPLayer;
296295
std::unique_ptr<CompileOnDemandLayer> CODLayer;
297296
};
298297

0 commit comments

Comments
 (0)