Skip to content

Commit c5965a4

Browse files
committed
Revert "[JITLink] Update JITLink to use ExecutorAddr rather than..."
This reverts commit 133f86e while I investigate the bot failures at https://lab.llvm.org/buildbot#builders/186/builds/3370.
1 parent aab62aa commit c5965a4

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+429
-519
lines changed

llvm/examples/OrcV2Examples/LLJITWithObjectLinkingLayerPlugin/LLJITWithObjectLinkingLayerPlugin.cpp

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -100,15 +100,14 @@ class MyPlugin : public ObjectLinkingLayer::Plugin {
100100
return;
101101
}
102102

103-
ExecutorAddr InitAddr(B.getAddress().getValue() & ~(LineWidth - 1));
104-
ExecutorAddr StartAddr = B.getAddress();
105-
ExecutorAddr EndAddr = B.getAddress() + B.getSize();
103+
JITTargetAddress InitAddr = B.getAddress() & ~(LineWidth - 1);
104+
JITTargetAddress StartAddr = B.getAddress();
105+
JITTargetAddress EndAddr = B.getAddress() + B.getSize();
106106
auto *Data = reinterpret_cast<const uint8_t *>(B.getContent().data());
107107

108-
for (ExecutorAddr CurAddr = InitAddr; CurAddr != EndAddr; ++CurAddr) {
108+
for (JITTargetAddress CurAddr = InitAddr; CurAddr != EndAddr; ++CurAddr) {
109109
if (CurAddr % LineWidth == 0)
110-
outs() << " " << formatv("{0:x16}", CurAddr.getValue())
111-
<< ": ";
110+
outs() << " " << formatv("{0:x16}", CurAddr) << ": ";
112111
if (CurAddr < StartAddr)
113112
outs() << " ";
114113
else

llvm/include/llvm/ExecutionEngine/JITLink/EHFrameSupport.h

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,24 +25,25 @@ namespace jitlink {
2525
class EHFrameRegistrar {
2626
public:
2727
virtual ~EHFrameRegistrar();
28-
virtual Error registerEHFrames(orc::ExecutorAddr EHFrameSectionAddr,
28+
virtual Error registerEHFrames(JITTargetAddress EHFrameSectionAddr,
2929
size_t EHFrameSectionSize) = 0;
30-
virtual Error deregisterEHFrames(orc::ExecutorAddr EHFrameSectionAddr,
30+
virtual Error deregisterEHFrames(JITTargetAddress EHFrameSectionAddr,
3131
size_t EHFrameSectionSize) = 0;
3232
};
3333

3434
/// Registers / Deregisters EH-frames in the current process.
3535
class InProcessEHFrameRegistrar final : public EHFrameRegistrar {
3636
public:
37-
Error registerEHFrames(orc::ExecutorAddr EHFrameSectionAddr,
37+
Error registerEHFrames(JITTargetAddress EHFrameSectionAddr,
3838
size_t EHFrameSectionSize) override;
3939

40-
Error deregisterEHFrames(orc::ExecutorAddr EHFrameSectionAddr,
40+
Error deregisterEHFrames(JITTargetAddress EHFrameSectionAddr,
4141
size_t EHFrameSectionSize) override;
4242
};
4343

44-
using StoreFrameRangeFunction = std::function<void(
45-
orc::ExecutorAddr EHFrameSectionAddr, size_t EHFrameSectionSize)>;
44+
using StoreFrameRangeFunction =
45+
std::function<void(JITTargetAddress EHFrameSectionAddr,
46+
size_t EHFrameSectionSize)>;
4647

4748
/// Creates a pass that records the address and size of the EH frame section.
4849
/// If no eh-frame section is found then the address and size will both be given

llvm/include/llvm/ExecutionEngine/JITLink/JITLink.h

Lines changed: 64 additions & 76 deletions
Large diffs are not rendered by default.

llvm/include/llvm/ExecutionEngine/JITLink/JITLinkMemoryManager.h

Lines changed: 19 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,9 @@
1313
#ifndef LLVM_EXECUTIONENGINE_JITLINK_JITLINKMEMORYMANAGER_H
1414
#define LLVM_EXECUTIONENGINE_JITLINK_JITLINKMEMORYMANAGER_H
1515

16-
#include "llvm/ADT/FunctionExtras.h"
1716
#include "llvm/ExecutionEngine/JITLink/JITLinkDylib.h"
1817
#include "llvm/ExecutionEngine/JITLink/MemoryFlags.h"
19-
#include "llvm/ExecutionEngine/Orc/Shared/ExecutorAddress.h"
18+
#include "llvm/ExecutionEngine/JITSymbol.h"
2019
#include "llvm/Support/Allocator.h"
2120
#include "llvm/Support/Error.h"
2221
#include "llvm/Support/MSVCErrorWorkarounds.h"
@@ -50,9 +49,9 @@ class Section;
5049
/// executor-side implementation code is responsible for freeing the error
5150
/// string).
5251
struct AllocActionCall {
53-
orc::ExecutorAddr FnAddr;
54-
orc::ExecutorAddr CtxAddr;
55-
orc::ExecutorAddrDiff CtxSize;
52+
JITTargetAddress FnAddr = 0;
53+
JITTargetAddress CtxAddr = 0;
54+
JITTargetAddress CtxSize = 0;
5655
};
5756

5857
/// A pair of AllocActionCalls, one to be run at finalization time, one to be
@@ -94,48 +93,47 @@ class JITLinkMemoryManager {
9493
class FinalizedAlloc {
9594
friend class JITLinkMemoryManager;
9695

97-
static constexpr auto InvalidAddr = ~uint64_t(0);
98-
9996
public:
97+
static constexpr JITTargetAddress InvalidAddr = ~JITTargetAddress(0);
98+
10099
FinalizedAlloc() = default;
101-
explicit FinalizedAlloc(orc::ExecutorAddr A) : A(A) {
102-
assert(A && "Explicitly creating an invalid allocation?");
100+
explicit FinalizedAlloc(JITTargetAddress A) : A(A) {
101+
assert(A != 0 && "Explicitly creating an invalid allocation?");
103102
}
104103
FinalizedAlloc(const FinalizedAlloc &) = delete;
105104
FinalizedAlloc(FinalizedAlloc &&Other) : A(Other.A) {
106-
Other.A.setValue(InvalidAddr);
105+
Other.A = InvalidAddr;
107106
}
108107
FinalizedAlloc &operator=(const FinalizedAlloc &) = delete;
109108
FinalizedAlloc &operator=(FinalizedAlloc &&Other) {
110-
assert(A.getValue() == InvalidAddr &&
109+
assert(A == InvalidAddr &&
111110
"Cannot overwrite active finalized allocation");
112111
std::swap(A, Other.A);
113112
return *this;
114113
}
115114
~FinalizedAlloc() {
116-
assert(A.getValue() == InvalidAddr &&
117-
"Finalized allocation was not deallocated");
115+
assert(A == InvalidAddr && "Finalized allocation was not deallocated");
118116
}
119117

120118
/// FinalizedAllocs convert to false for default-constructed, and
121119
/// true otherwise. Default-constructed allocs need not be deallocated.
122-
explicit operator bool() const { return A.getValue() != InvalidAddr; }
120+
explicit operator bool() const { return A != InvalidAddr; }
123121

124122
/// Returns the address associated with this finalized allocation.
125123
/// The allocation is unmodified.
126-
orc::ExecutorAddr getAddress() const { return A; }
124+
JITTargetAddress getAddress() const { return A; }
127125

128126
/// Returns the address associated with this finalized allocation and
129127
/// resets this object to the default state.
130128
/// This should only be used by allocators when deallocating memory.
131-
orc::ExecutorAddr release() {
132-
orc::ExecutorAddr Tmp = A;
133-
A.setValue(InvalidAddr);
129+
JITTargetAddress release() {
130+
JITTargetAddress Tmp = A;
131+
A = InvalidAddr;
134132
return Tmp;
135133
}
136134

137135
private:
138-
orc::ExecutorAddr A{InvalidAddr};
136+
JITTargetAddress A = InvalidAddr;
139137
};
140138

141139
/// Represents an allocation which has not been finalized yet.
@@ -265,7 +263,7 @@ class BasicLayout {
265263
Align Alignment;
266264
size_t ContentSize;
267265
uint64_t ZeroFillSize;
268-
orc::ExecutorAddr Addr;
266+
JITTargetAddress Addr;
269267
char *WorkingMem = nullptr;
270268

271269
private:
@@ -343,7 +341,7 @@ class SimpleSegmentAlloc {
343341

344342
/// Describes the segment working memory and executor address.
345343
struct SegmentInfo {
346-
orc::ExecutorAddr Addr;
344+
JITTargetAddress Addr = 0;
347345
MutableArrayRef<char> WorkingMem;
348346
};
349347

llvm/include/llvm/ExecutionEngine/JITLink/x86_64.h

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -368,26 +368,26 @@ inline Error applyFixup(LinkGraph &G, Block &B, const Edge &E,
368368

369369
char *BlockWorkingMem = B.getAlreadyMutableContent().data();
370370
char *FixupPtr = BlockWorkingMem + E.getOffset();
371-
auto FixupAddress = B.getAddress() + E.getOffset();
371+
JITTargetAddress FixupAddress = B.getAddress() + E.getOffset();
372372

373373
switch (E.getKind()) {
374374

375375
case Pointer64: {
376-
uint64_t Value = E.getTarget().getAddress().getValue() + E.getAddend();
376+
uint64_t Value = E.getTarget().getAddress() + E.getAddend();
377377
*(ulittle64_t *)FixupPtr = Value;
378378
break;
379379
}
380380

381381
case Pointer32: {
382-
uint64_t Value = E.getTarget().getAddress().getValue() + E.getAddend();
382+
uint64_t Value = E.getTarget().getAddress() + E.getAddend();
383383
if (LLVM_LIKELY(isInRangeForImmU32(Value)))
384384
*(ulittle32_t *)FixupPtr = Value;
385385
else
386386
return makeTargetOutOfRangeError(G, B, E);
387387
break;
388388
}
389389
case Pointer32Signed: {
390-
int64_t Value = E.getTarget().getAddress().getValue() + E.getAddend();
390+
int64_t Value = E.getTarget().getAddress() + E.getAddend();
391391
if (LLVM_LIKELY(isInRangeForImmS32(Value)))
392392
*(little32_t *)FixupPtr = Value;
393393
else
@@ -483,8 +483,8 @@ extern const char PointerJumpStubContent[6];
483483
inline Symbol &createAnonymousPointer(LinkGraph &G, Section &PointerSection,
484484
Symbol *InitialTarget = nullptr,
485485
uint64_t InitialAddend = 0) {
486-
auto &B = G.createContentBlock(PointerSection, NullPointerContent,
487-
orc::ExecutorAddr(~uint64_t(7)), 8, 0);
486+
auto &B =
487+
G.createContentBlock(PointerSection, NullPointerContent, ~7ULL, 8, 0);
488488
if (InitialTarget)
489489
B.addEdge(Pointer64, 0, *InitialTarget, InitialAddend);
490490
return G.addAnonymousSymbol(B, 0, 8, false, false);
@@ -498,8 +498,8 @@ inline Symbol &createAnonymousPointer(LinkGraph &G, Section &PointerSection,
498498
/// address: highest allowable: (~5U)
499499
inline Block &createPointerJumpStubBlock(LinkGraph &G, Section &StubSection,
500500
Symbol &PointerSymbol) {
501-
auto &B = G.createContentBlock(StubSection, PointerJumpStubContent,
502-
orc::ExecutorAddr(~uint64_t(5)), 1, 0);
501+
auto &B =
502+
G.createContentBlock(StubSection, PointerJumpStubContent, ~5ULL, 1, 0);
503503
B.addEdge(Delta32, 2, PointerSymbol, -4);
504504
return B;
505505
}
@@ -552,7 +552,8 @@ class GOTTableManager : public TableManager<GOTTableManager> {
552552
"Fell through switch, but no new kind to set");
553553
DEBUG_WITH_TYPE("jitlink", {
554554
dbgs() << " Fixing " << G.getEdgeKindName(E.getKind()) << " edge at "
555-
<< B->getFixupAddress(E) << " (" << B->getAddress() << " + "
555+
<< formatv("{0:x}", B->getFixupAddress(E)) << " ("
556+
<< formatv("{0:x}", B->getAddress()) << " + "
556557
<< formatv("{0:x}", E.getOffset()) << ")\n";
557558
});
558559
E.setKind(KindToSet);
@@ -585,7 +586,8 @@ class PLTTableManager : public TableManager<PLTTableManager> {
585586
if (E.getKind() == x86_64::BranchPCRel32 && !E.getTarget().isDefined()) {
586587
DEBUG_WITH_TYPE("jitlink", {
587588
dbgs() << " Fixing " << G.getEdgeKindName(E.getKind()) << " edge at "
588-
<< B->getFixupAddress(E) << " (" << B->getAddress() << " + "
589+
<< formatv("{0:x}", B->getFixupAddress(E)) << " ("
590+
<< formatv("{0:x}", B->getAddress()) << " + "
589591
<< formatv("{0:x}", E.getOffset()) << ")\n";
590592
});
591593
// Set the edge kind to Branch32ToPtrJumpStubBypassable to enable it to

llvm/include/llvm/ExecutionEngine/Orc/ELFNixPlatform.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,7 @@ class ELFNixPlatform : public Platform {
236236
DenseMap<JITDylib *, ELFNixJITDylibInitializers> InitSeqs;
237237
std::vector<ELFPerObjectSectionsToRegister> BootstrapPOSRs;
238238

239-
DenseMap<ExecutorAddr, JITDylib *> HandleAddrToJITDylib;
239+
DenseMap<JITTargetAddress, JITDylib *> HandleAddrToJITDylib;
240240
DenseMap<JITDylib *, uint64_t> JITDylibToPThreadKey;
241241
};
242242

llvm/include/llvm/ExecutionEngine/Orc/EPCEHFrameRegistrar.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,9 @@ class EPCEHFrameRegistrar : public jitlink::EHFrameRegistrar {
3939
: ES(ES), RegisterEHFrameWrapperFnAddr(RegisterEHFrameWrapperFnAddr),
4040
DeregisterEHFrameWrapperFnAddr(DeregisterEHFRameWrapperFnAddr) {}
4141

42-
Error registerEHFrames(ExecutorAddr EHFrameSectionAddr,
42+
Error registerEHFrames(JITTargetAddress EHFrameSectionAddr,
4343
size_t EHFrameSectionSize) override;
44-
Error deregisterEHFrames(ExecutorAddr EHFrameSectionAddr,
44+
Error deregisterEHFrames(JITTargetAddress EHFrameSectionAddr,
4545
size_t EHFrameSectionSize) override;
4646

4747
private:

llvm/include/llvm/ExecutionEngine/Orc/EPCGenericJITLinkMemoryManager.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ class SPSSerializationTraits<SPSExecutorAddr,
8585
ExecutorAddr A;
8686
if (!SPSArgList<SPSExecutorAddr>::deserialize(IB, A))
8787
return false;
88-
FA = jitlink::JITLinkMemoryManager::FinalizedAlloc(A);
88+
FA = jitlink::JITLinkMemoryManager::FinalizedAlloc(A.getValue());
8989
return true;
9090
}
9191
};

llvm/include/llvm/ExecutionEngine/Orc/MachOPlatform.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,7 @@ class MachOPlatform : public Platform {
239239
std::mutex PlatformMutex;
240240
DenseMap<JITDylib *, MachOJITDylibInitializers> InitSeqs;
241241

242-
DenseMap<ExecutorAddr, JITDylib *> HeaderAddrToJITDylib;
242+
DenseMap<JITTargetAddress, JITDylib *> HeaderAddrToJITDylib;
243243
DenseMap<JITDylib *, uint64_t> JITDylibToPThreadKey;
244244
};
245245

llvm/include/llvm/ExecutionEngine/Orc/ObjectLinkingLayer.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,7 @@ class EHFrameRegistrationPlugin : public ObjectLinkingLayer::Plugin {
222222
private:
223223

224224
struct EHFrameRange {
225-
orc::ExecutorAddr Addr;
225+
JITTargetAddress Addr = 0;
226226
size_t Size;
227227
};
228228

0 commit comments

Comments
 (0)