Skip to content

Commit e994f84

Browse files
committed
[ORC] Rename MemLifetimePolicy to MemLifetime.
The *Policy suffix came from the earlier MemAllocPolicy type, where it was included to distinguish the type from a memory-allocation operation. MemLifetime is a noun already, so the *Policy suffix is just dead weight now.
1 parent e52899e commit e994f84

File tree

13 files changed

+42
-47
lines changed

13 files changed

+42
-47
lines changed

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -722,10 +722,10 @@ class Section {
722722
void setMemProt(orc::MemProt Prot) { this->Prot = Prot; }
723723

724724
/// Get the memory lifetime policy for this section.
725-
orc::MemLifetimePolicy getMemLifetimePolicy() const { return MLP; }
725+
orc::MemLifetime getMemLifetime() const { return ML; }
726726

727727
/// Set the memory lifetime policy for this section.
728-
void setMemLifetimePolicy(orc::MemLifetimePolicy MLP) { this->MLP = MLP; }
728+
void setMemLifetime(orc::MemLifetime ML) { this->ML = ML; }
729729

730730
/// Returns the ordinal for this section.
731731
SectionOrdinal getOrdinal() const { return SecOrdinal; }
@@ -793,7 +793,7 @@ class Section {
793793

794794
StringRef Name;
795795
orc::MemProt Prot;
796-
orc::MemLifetimePolicy MLP = orc::MemLifetimePolicy::Standard;
796+
orc::MemLifetime ML = orc::MemLifetime::Standard;
797797
SectionOrdinal SecOrdinal = 0;
798798
BlockSet Blocks;
799799
SymbolSet Symbols;

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -292,8 +292,8 @@ class BasicLayout {
292292
/// address of that block using the Segment's AllocGroup. Once memory has been
293293
/// populated, clients can call finalize to finalize the memory.
294294
///
295-
/// Note: Segments with MemLifetimePolicy::NoAlloc are not permitted, since
296-
/// they would not be useful, and their presence is likely to indicate a bug.
295+
/// Note: Segments with MemLifetime::NoAlloc are not permitted, since they would
296+
/// not be useful, and their presence is likely to indicate a bug.
297297
class SimpleSegmentAlloc {
298298
public:
299299
/// Describes a segment to be allocated.

llvm/include/llvm/ExecutionEngine/Orc/Shared/MemoryFlags.h

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ inline MemProt fromSysMemoryProtectionFlags(sys::Memory::ProtectionFlags PF) {
7272
/// deallocated if a call is made to
7373
/// JITLinkMemoryManager::InFlightAllocation::abandon. The policies below apply
7474
/// to finalized allocations.
75-
enum class MemLifetimePolicy {
75+
enum class MemLifetime {
7676
/// Standard memory should be allocated by the allocator and then deallocated
7777
/// when the deallocate method is called for the finalized allocation.
7878
Standard,
@@ -89,15 +89,15 @@ enum class MemLifetimePolicy {
8989
};
9090

9191
/// Print a MemDeallocPolicy.
92-
inline raw_ostream &operator<<(raw_ostream &OS, MemLifetimePolicy MLP) {
92+
inline raw_ostream &operator<<(raw_ostream &OS, MemLifetime MLP) {
9393
switch (MLP) {
94-
case MemLifetimePolicy::Standard:
94+
case MemLifetime::Standard:
9595
OS << "standard";
9696
break;
97-
case MemLifetimePolicy::Finalize:
97+
case MemLifetime::Finalize:
9898
OS << "finalize";
9999
break;
100-
case MemLifetimePolicy::NoAlloc:
100+
case MemLifetime::NoAlloc:
101101
OS << "noalloc";
102102
break;
103103
}
@@ -124,11 +124,11 @@ class AllocGroup {
124124
AllocGroup() = default;
125125

126126
/// Create an AllocGroup from a MemProt only -- uses
127-
/// MemLifetimePolicy::Standard.
127+
/// MemLifetime::Standard.
128128
AllocGroup(MemProt MP) : Id(static_cast<underlying_type>(MP)) {}
129129

130-
/// Create an AllocGroup from a MemProt and a MemLifetimePolicy.
131-
AllocGroup(MemProt MP, MemLifetimePolicy MLP)
130+
/// Create an AllocGroup from a MemProt and a MemLifetime.
131+
AllocGroup(MemProt MP, MemLifetime MLP)
132132
: Id(static_cast<underlying_type>(MP) |
133133
(static_cast<underlying_type>(MLP) << BitsForProt)) {}
134134

@@ -137,9 +137,9 @@ class AllocGroup {
137137
return static_cast<MemProt>(Id & ((1U << BitsForProt) - 1));
138138
}
139139

140-
/// Returns the MemLifetimePolicy for this group.
141-
MemLifetimePolicy getMemLifetimePolicy() const {
142-
return static_cast<MemLifetimePolicy>(Id >> BitsForProt);
140+
/// Returns the MemLifetime for this group.
141+
MemLifetime getMemLifetime() const {
142+
return static_cast<MemLifetime>(Id >> BitsForProt);
143143
}
144144

145145
friend bool operator==(const AllocGroup &LHS, const AllocGroup &RHS) {
@@ -203,8 +203,7 @@ template <typename T> class AllocGroupSmallMap {
203203

204204
/// Print an AllocGroup.
205205
inline raw_ostream &operator<<(raw_ostream &OS, AllocGroup AG) {
206-
return OS << '(' << AG.getMemProt() << ", " << AG.getMemLifetimePolicy()
207-
<< ')';
206+
return OS << '(' << AG.getMemProt() << ", " << AG.getMemLifetime() << ')';
208207
}
209208

210209
} // end namespace orc

llvm/include/llvm/ExecutionEngine/Orc/Shared/TargetProcessControlTypes.h

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,9 @@ struct RemoteAllocGroup {
3636
RemoteAllocGroup(MemProt Prot, bool FinalizeLifetime)
3737
: Prot(Prot), FinalizeLifetime(FinalizeLifetime) {}
3838
RemoteAllocGroup(const AllocGroup &AG) : Prot(AG.getMemProt()) {
39-
assert(AG.getMemLifetimePolicy() != orc::MemLifetimePolicy::NoAlloc &&
39+
assert(AG.getMemLifetime() != orc::MemLifetime::NoAlloc &&
4040
"Cannot use no-alloc memory in a remote alloc request");
41-
FinalizeLifetime =
42-
AG.getMemLifetimePolicy() == orc::MemLifetimePolicy::Finalize;
41+
FinalizeLifetime = AG.getMemLifetime() == orc::MemLifetime::Finalize;
4342
}
4443

4544
MemProt Prot;

llvm/lib/ExecutionEngine/JITLink/COFFLinkGraphBuilder.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ Error COFFLinkGraphBuilder::graphifySections() {
161161
if (!GraphSec) {
162162
GraphSec = &G->createSection(SectionName, Prot);
163163
if ((*Sec)->Characteristics & COFF::IMAGE_SCN_LNK_REMOVE)
164-
GraphSec->setMemLifetimePolicy(orc::MemLifetimePolicy::NoAlloc);
164+
GraphSec->setMemLifetime(orc::MemLifetime::NoAlloc);
165165
}
166166
if (GraphSec->getMemProt() != Prot)
167167
return make_error<JITLinkError>("MemProt should match");

llvm/lib/ExecutionEngine/JITLink/ELFLinkGraphBuilder.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -366,7 +366,7 @@ template <typename ELFT> Error ELFLinkGraphBuilder<ELFT>::graphifySections() {
366366
GraphSec = &G->createSection(*Name, Prot);
367367
// Non-SHF_ALLOC sections get NoAlloc memory lifetimes.
368368
if (!(Sec.sh_flags & ELF::SHF_ALLOC)) {
369-
GraphSec->setMemLifetimePolicy(orc::MemLifetimePolicy::NoAlloc);
369+
GraphSec->setMemLifetime(orc::MemLifetime::NoAlloc);
370370
LLVM_DEBUG({
371371
dbgs() << " " << SecIndex << ": \"" << *Name
372372
<< "\" is not a SHF_ALLOC section. Using NoAlloc lifetime.\n";

llvm/lib/ExecutionEngine/JITLink/JITLinkGeneric.h

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -134,8 +134,7 @@ template <typename LinkerImpl> class JITLinker : public JITLinkerBase {
134134
LLVM_DEBUG(dbgs() << "Fixing up blocks:\n");
135135

136136
for (auto &Sec : G.sections()) {
137-
bool NoAllocSection =
138-
Sec.getMemLifetimePolicy() == orc::MemLifetimePolicy::NoAlloc;
137+
bool NoAllocSection = Sec.getMemLifetime() == orc::MemLifetime::NoAlloc;
139138

140139
for (auto *B : Sec.blocks()) {
141140
LLVM_DEBUG(dbgs() << " " << *B << ":\n");
@@ -163,12 +162,11 @@ template <typename LinkerImpl> class JITLinker : public JITLinkerBase {
163162

164163
// If B is a block in a Standard or Finalize section then make sure
165164
// that no edges point to symbols in NoAlloc sections.
166-
assert(
167-
(NoAllocSection || !E.getTarget().isDefined() ||
168-
E.getTarget().getBlock().getSection().getMemLifetimePolicy() !=
169-
orc::MemLifetimePolicy::NoAlloc) &&
170-
"Block in allocated section has edge pointing to no-alloc "
171-
"section");
165+
assert((NoAllocSection || !E.getTarget().isDefined() ||
166+
E.getTarget().getBlock().getSection().getMemLifetime() !=
167+
orc::MemLifetime::NoAlloc) &&
168+
"Block in allocated section has edge pointing to no-alloc "
169+
"section");
172170

173171
// Dispatch to LinkerImpl for fixup.
174172
if (auto Err = impl().applyFixup(G, *B, E))

llvm/lib/ExecutionEngine/JITLink/JITLinkMemoryManager.cpp

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,10 @@ BasicLayout::BasicLayout(LinkGraph &G) : G(G) {
2626
for (auto &Sec : G.sections()) {
2727
// Skip empty sections, and sections with NoAlloc lifetime policies.
2828
if (Sec.blocks().empty() ||
29-
Sec.getMemLifetimePolicy() == orc::MemLifetimePolicy::NoAlloc)
29+
Sec.getMemLifetime() == orc::MemLifetime::NoAlloc)
3030
continue;
3131

32-
auto &Seg = Segments[{Sec.getMemProt(), Sec.getMemLifetimePolicy()}];
32+
auto &Seg = Segments[{Sec.getMemProt(), Sec.getMemLifetime()}];
3333
for (auto *B : Sec.blocks())
3434
if (LLVM_LIKELY(!B->isZeroFill()))
3535
Seg.ContentBlocks.push_back(B);
@@ -90,7 +90,7 @@ BasicLayout::getContiguousPageBasedLayoutSizes(uint64_t PageSize) {
9090
inconvertibleErrorCode());
9191

9292
uint64_t SegSize = alignTo(Seg.ContentSize + Seg.ZeroFillSize, PageSize);
93-
if (AG.getMemLifetimePolicy() == orc::MemLifetimePolicy::Standard)
93+
if (AG.getMemLifetime() == orc::MemLifetime::Standard)
9494
SegsSizes.StandardSegs += SegSize;
9595
else
9696
SegsSizes.FinalizeSegs += SegSize;
@@ -164,15 +164,15 @@ void SimpleSegmentAlloc::Create(JITLinkMemoryManager &MemMgr,
164164
auto &AG = KV.first;
165165
auto &Seg = KV.second;
166166

167-
assert(AG.getMemLifetimePolicy() != orc::MemLifetimePolicy::NoAlloc &&
167+
assert(AG.getMemLifetime() != orc::MemLifetime::NoAlloc &&
168168
"NoAlloc segments are not supported by SimpleSegmentAlloc");
169169

170170
auto AGSectionName =
171171
AGSectionNames[static_cast<unsigned>(AG.getMemProt()) |
172-
static_cast<bool>(AG.getMemLifetimePolicy()) << 3];
172+
static_cast<bool>(AG.getMemLifetime()) << 3];
173173

174174
auto &Sec = G->createSection(AGSectionName, AG.getMemProt());
175-
Sec.setMemLifetimePolicy(AG.getMemLifetimePolicy());
175+
Sec.setMemLifetime(AG.getMemLifetime());
176176

177177
if (Seg.ContentSize != 0) {
178178
NextAddr =
@@ -419,10 +419,9 @@ void InProcessMemoryManager::allocate(const JITLinkDylib *JD, LinkGraph &G,
419419
auto &AG = KV.first;
420420
auto &Seg = KV.second;
421421

422-
auto &SegAddr =
423-
(AG.getMemLifetimePolicy() == orc::MemLifetimePolicy::Standard)
424-
? NextStandardSegAddr
425-
: NextFinalizeSegAddr;
422+
auto &SegAddr = (AG.getMemLifetime() == orc::MemLifetime::Standard)
423+
? NextStandardSegAddr
424+
: NextFinalizeSegAddr;
426425

427426
Seg.WorkingMem = SegAddr.toPtr<char *>();
428427
Seg.Addr = SegAddr;

llvm/lib/ExecutionEngine/JITLink/MachOLinkGraphBuilder.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@ Error MachOLinkGraphBuilder::createNormalizedSections() {
192192

193193
// TODO: Are there any other criteria for NoAlloc lifetime?
194194
if (NSec.Flags & MachO::S_ATTR_DEBUG)
195-
NSec.GraphSection->setMemLifetimePolicy(orc::MemLifetimePolicy::NoAlloc);
195+
NSec.GraphSection->setMemLifetime(orc::MemLifetime::NoAlloc);
196196

197197
IndexToSection.insert(std::make_pair(SecIndex, std::move(NSec)));
198198
}

llvm/lib/ExecutionEngine/Orc/DebuggerSupportPlugin.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ class MachODebugObjectSynthesizer : public MachODebugObjectSynthesizerBase {
110110

111111
if (isDebugSection(Sec))
112112
DebugSections.push_back({&Sec, nullptr});
113-
else if (Sec.getMemLifetimePolicy() != MemLifetimePolicy::NoAlloc)
113+
else if (Sec.getMemLifetime() != MemLifetime::NoAlloc)
114114
NonDebugSections.push_back({&Sec, nullptr});
115115
}
116116

llvm/lib/ExecutionEngine/Orc/MemoryMapper.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -322,8 +322,8 @@ void SharedMemoryMapper::initialize(MemoryMapper::AllocInfo &AI,
322322
std::memset(Base + Segment.ContentSize, 0, Segment.ZeroFillSize);
323323

324324
tpctypes::SharedMemorySegFinalizeRequest SegReq;
325-
SegReq.RAG = {Segment.AG.getMemProt(), Segment.AG.getMemLifetimePolicy() ==
326-
MemLifetimePolicy::Finalize};
325+
SegReq.RAG = {Segment.AG.getMemProt(),
326+
Segment.AG.getMemLifetime() == MemLifetime::Finalize};
327327
SegReq.Addr = AI.MappingBase + Segment.Offset;
328328
SegReq.Size = Segment.ContentSize + Segment.ZeroFillSize;
329329

llvm/tools/llvm-jitlink/llvm-jitlink.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -512,7 +512,7 @@ class InProcessDeltaMapper final : public InProcessMemoryMapper {
512512
auto FixedAI = std::move(AI);
513513
FixedAI.MappingBase -= DeltaAddr;
514514
for (auto &Seg : FixedAI.Segments)
515-
Seg.AG = {MemProt::Read | MemProt::Write, Seg.AG.getMemLifetimePolicy()};
515+
Seg.AG = {MemProt::Read | MemProt::Write, Seg.AG.getMemLifetime()};
516516
FixedAI.Actions.clear();
517517
InProcessMemoryMapper::initialize(
518518
FixedAI, [this, OnInitialized = std::move(OnInitialized)](

llvm/unittests/ExecutionEngine/JITLink/LinkGraphTests.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -798,7 +798,7 @@ TEST(LinkGraphTest, BasicLayoutHonorsNoAlloc) {
798798
// Create a NoAlloc section and block.
799799
auto &Sec2 =
800800
G.createSection("__metadata", orc::MemProt::Read | orc::MemProt::Write);
801-
Sec2.setMemLifetimePolicy(orc::MemLifetimePolicy::NoAlloc);
801+
Sec2.setMemLifetime(orc::MemLifetime::NoAlloc);
802802
G.createContentBlock(Sec2, BlockContent.slice(0, 8), orc::ExecutorAddr(), 8,
803803
0);
804804

0 commit comments

Comments
 (0)