Skip to content

Commit 6641d29

Browse files
committed
Revert "[JITLink][ORC] Major JITLinkMemoryManager refactor."
This reverts commit e50aea5 while I investigate bot failures.
1 parent e50aea5 commit 6641d29

34 files changed

+852
-1692
lines changed

llvm/examples/OrcV2Examples/LLJITWithCustomObjectLinkingLayer/LLJITWithCustomObjectLinkingLayer.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ int main(int argc, char *argv[]) {
4747
.setObjectLinkingLayerCreator(
4848
[&](ExecutionSession &ES, const Triple &TT) {
4949
return std::make_unique<ObjectLinkingLayer>(
50-
ES, ExitOnErr(jitlink::InProcessMemoryManager::Create()));
50+
ES, std::make_unique<jitlink::InProcessMemoryManager>());
5151
})
5252
.create());
5353

llvm/examples/OrcV2Examples/LLJITWithObjectLinkingLayerPlugin/LLJITWithObjectLinkingLayerPlugin.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,7 @@ int main(int argc, char *argv[]) {
209209
[&](ExecutionSession &ES, const Triple &TT) {
210210
// Create ObjectLinkingLayer.
211211
auto ObjLinkingLayer = std::make_unique<ObjectLinkingLayer>(
212-
ES, ExitOnErr(jitlink::InProcessMemoryManager::Create()));
212+
ES, std::make_unique<jitlink::InProcessMemoryManager>());
213213
// Add an instance of our plugin.
214214
ObjLinkingLayer->addPlugin(std::make_unique<MyPlugin>());
215215
return ObjLinkingLayer;

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

Lines changed: 13 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -13,19 +13,19 @@
1313
#ifndef LLVM_EXECUTIONENGINE_JITLINK_JITLINK_H
1414
#define LLVM_EXECUTIONENGINE_JITLINK_JITLINK_H
1515

16+
#include "JITLinkMemoryManager.h"
1617
#include "llvm/ADT/DenseMap.h"
1718
#include "llvm/ADT/DenseSet.h"
1819
#include "llvm/ADT/Optional.h"
1920
#include "llvm/ADT/STLExtras.h"
2021
#include "llvm/ADT/Triple.h"
21-
#include "llvm/ExecutionEngine/JITLink/JITLinkMemoryManager.h"
22-
#include "llvm/ExecutionEngine/JITLink/MemoryFlags.h"
2322
#include "llvm/ExecutionEngine/JITSymbol.h"
2423
#include "llvm/Support/Allocator.h"
2524
#include "llvm/Support/Endian.h"
2625
#include "llvm/Support/Error.h"
2726
#include "llvm/Support/FormatVariadic.h"
2827
#include "llvm/Support/MathExtras.h"
28+
#include "llvm/Support/Memory.h"
2929
#include "llvm/Support/MemoryBuffer.h"
3030

3131
#include <map>
@@ -225,15 +225,14 @@ class Block : public Addressable {
225225

226226
/// Get the content for this block. Block must not be a zero-fill block.
227227
ArrayRef<char> getContent() const {
228-
assert(Data && "Block does not contain content");
228+
assert(Data && "Section does not contain content");
229229
return ArrayRef<char>(Data, Size);
230230
}
231231

232232
/// Set the content for this block.
233233
/// Caller is responsible for ensuring the underlying bytes are not
234234
/// deallocated while pointed to by this block.
235235
void setContent(ArrayRef<char> Content) {
236-
assert(Content.data() && "Setting null content");
237236
Data = Content.data();
238237
Size = Content.size();
239238
ContentMutable = false;
@@ -252,7 +251,6 @@ class Block : public Addressable {
252251
/// to call this on a block with immutable content -- consider using
253252
/// getMutableContent instead.
254253
MutableArrayRef<char> getAlreadyMutableContent() {
255-
assert(Data && "Block does not contain content");
256254
assert(ContentMutable && "Content is not mutable");
257255
return MutableArrayRef<char>(const_cast<char *>(Data), Size);
258256
}
@@ -262,7 +260,6 @@ class Block : public Addressable {
262260
/// The caller is responsible for ensuring that the memory pointed to by
263261
/// MutableContent is not deallocated while pointed to by this block.
264262
void setMutableContent(MutableArrayRef<char> MutableContent) {
265-
assert(MutableContent.data() && "Setting null content");
266263
Data = MutableContent.data();
267264
Size = MutableContent.size();
268265
ContentMutable = true;
@@ -298,7 +295,6 @@ class Block : public Addressable {
298295
/// Add an edge to this block.
299296
void addEdge(Edge::Kind K, Edge::OffsetT Offset, Symbol &Target,
300297
Edge::AddendT Addend) {
301-
assert(!isZeroFill() && "Adding edge to zero-fill block?");
302298
Edges.push_back(Edge(K, Offset, Target, Addend));
303299
}
304300

@@ -644,7 +640,8 @@ class Section {
644640
friend class LinkGraph;
645641

646642
private:
647-
Section(StringRef Name, MemProt Prot, SectionOrdinal SecOrdinal)
643+
Section(StringRef Name, sys::Memory::ProtectionFlags Prot,
644+
SectionOrdinal SecOrdinal)
648645
: Name(Name), Prot(Prot), SecOrdinal(SecOrdinal) {}
649646

650647
using SymbolSet = DenseSet<Symbol *>;
@@ -669,16 +666,12 @@ class Section {
669666
StringRef getName() const { return Name; }
670667

671668
/// Returns the protection flags for this section.
672-
MemProt getMemProt() const { return Prot; }
669+
sys::Memory::ProtectionFlags getProtectionFlags() const { return Prot; }
673670

674671
/// Set the protection flags for this section.
675-
void setMemProt(MemProt Prot) { this->Prot = Prot; }
676-
677-
/// Get the deallocation policy for this section.
678-
MemDeallocPolicy getMemDeallocPolicy() const { return MDP; }
679-
680-
/// Set the deallocation policy for this section.
681-
void setMemDeallocPolicy(MemDeallocPolicy MDP) { this->MDP = MDP; }
672+
void setProtectionFlags(sys::Memory::ProtectionFlags Prot) {
673+
this->Prot = Prot;
674+
}
682675

683676
/// Returns the ordinal for this section.
684677
SectionOrdinal getOrdinal() const { return SecOrdinal; }
@@ -693,7 +686,6 @@ class Section {
693686
return make_range(Blocks.begin(), Blocks.end());
694687
}
695688

696-
/// Returns the number of blocks in this section.
697689
BlockSet::size_type blocks_size() const { return Blocks.size(); }
698690

699691
/// Returns an iterator over the symbols defined in this section.
@@ -742,8 +734,7 @@ class Section {
742734
}
743735

744736
StringRef Name;
745-
MemProt Prot;
746-
MemDeallocPolicy MDP = MemDeallocPolicy::Standard;
737+
sys::Memory::ProtectionFlags Prot;
747738
SectionOrdinal SecOrdinal = 0;
748739
BlockSet Blocks;
749740
SymbolSet Symbols;
@@ -925,11 +916,6 @@ class LinkGraph {
925916
: Name(std::move(Name)), TT(TT), PointerSize(PointerSize),
926917
Endianness(Endianness), GetEdgeKindName(std::move(GetEdgeKindName)) {}
927918

928-
LinkGraph(const LinkGraph &) = delete;
929-
LinkGraph &operator=(const LinkGraph &) = delete;
930-
LinkGraph(LinkGraph &&) = delete;
931-
LinkGraph &operator=(LinkGraph &&) = delete;
932-
933919
/// Returns the name of this graph (usually the name of the original
934920
/// underlying MemoryBuffer).
935921
const std::string &getName() const { return Name; }
@@ -976,7 +962,7 @@ class LinkGraph {
976962
}
977963

978964
/// Create a section with the given name, protection flags, and alignment.
979-
Section &createSection(StringRef Name, MemProt Prot) {
965+
Section &createSection(StringRef Name, sys::Memory::ProtectionFlags Prot) {
980966
assert(llvm::find_if(Sections,
981967
[&](std::unique_ptr<Section> &Sec) {
982968
return Sec->getName() == Name;
@@ -1364,13 +1350,6 @@ class LinkGraph {
13641350
Sections.erase(I);
13651351
}
13661352

1367-
/// Accessor for the AllocActions object for this graph. This can be used to
1368-
/// register allocation action calls prior to finalization.
1369-
///
1370-
/// Accessing this object after finalization will result in undefined
1371-
/// behavior.
1372-
JITLinkMemoryManager::AllocActions &allocActions() { return AAs; }
1373-
13741353
/// Dump the graph.
13751354
void dump(raw_ostream &OS);
13761355

@@ -1387,7 +1366,6 @@ class LinkGraph {
13871366
SectionList Sections;
13881367
ExternalSymbolSet ExternalSymbols;
13891368
ExternalSymbolSet AbsoluteSymbols;
1390-
JITLinkMemoryManager::AllocActions AAs;
13911369
};
13921370

13931371
inline MutableArrayRef<char> Block::getMutableContent(LinkGraph &G) {
@@ -1677,7 +1655,8 @@ class JITLinkContext {
16771655
/// finalized (i.e. emitted to memory and memory permissions set). If all of
16781656
/// this objects dependencies have also been finalized then the code is ready
16791657
/// to run.
1680-
virtual void notifyFinalized(JITLinkMemoryManager::FinalizedAlloc Alloc) = 0;
1658+
virtual void
1659+
notifyFinalized(std::unique_ptr<JITLinkMemoryManager::Allocation> A) = 0;
16811660

16821661
/// Called by JITLink prior to linking to determine whether default passes for
16831662
/// the target should be added. The default implementation returns true.

0 commit comments

Comments
 (0)