[llvm] e994f84 - [ORC] Rename MemLifetimePolicy to MemLifetime.

Lang Hames via llvm-commits llvm-commits at lists.llvm.org
Thu Sep 28 10:30:47 PDT 2023


Author: Lang Hames
Date: 2023-09-28T10:30:38-07:00
New Revision: e994f84c8a6da60ef5426764ffb7b2487a2bf6e0

URL: https://github.com/llvm/llvm-project/commit/e994f84c8a6da60ef5426764ffb7b2487a2bf6e0
DIFF: https://github.com/llvm/llvm-project/commit/e994f84c8a6da60ef5426764ffb7b2487a2bf6e0.diff

LOG: [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.

Added: 
    

Modified: 
    llvm/include/llvm/ExecutionEngine/JITLink/JITLink.h
    llvm/include/llvm/ExecutionEngine/JITLink/JITLinkMemoryManager.h
    llvm/include/llvm/ExecutionEngine/Orc/Shared/MemoryFlags.h
    llvm/include/llvm/ExecutionEngine/Orc/Shared/TargetProcessControlTypes.h
    llvm/lib/ExecutionEngine/JITLink/COFFLinkGraphBuilder.cpp
    llvm/lib/ExecutionEngine/JITLink/ELFLinkGraphBuilder.h
    llvm/lib/ExecutionEngine/JITLink/JITLinkGeneric.h
    llvm/lib/ExecutionEngine/JITLink/JITLinkMemoryManager.cpp
    llvm/lib/ExecutionEngine/JITLink/MachOLinkGraphBuilder.cpp
    llvm/lib/ExecutionEngine/Orc/DebuggerSupportPlugin.cpp
    llvm/lib/ExecutionEngine/Orc/MemoryMapper.cpp
    llvm/tools/llvm-jitlink/llvm-jitlink.cpp
    llvm/unittests/ExecutionEngine/JITLink/LinkGraphTests.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/include/llvm/ExecutionEngine/JITLink/JITLink.h b/llvm/include/llvm/ExecutionEngine/JITLink/JITLink.h
index ab4441fbec4606d..4fcb4656a2df069 100644
--- a/llvm/include/llvm/ExecutionEngine/JITLink/JITLink.h
+++ b/llvm/include/llvm/ExecutionEngine/JITLink/JITLink.h
@@ -722,10 +722,10 @@ class Section {
   void setMemProt(orc::MemProt Prot) { this->Prot = Prot; }
 
   /// Get the memory lifetime policy for this section.
-  orc::MemLifetimePolicy getMemLifetimePolicy() const { return MLP; }
+  orc::MemLifetime getMemLifetime() const { return ML; }
 
   /// Set the memory lifetime policy for this section.
-  void setMemLifetimePolicy(orc::MemLifetimePolicy MLP) { this->MLP = MLP; }
+  void setMemLifetime(orc::MemLifetime ML) { this->ML = ML; }
 
   /// Returns the ordinal for this section.
   SectionOrdinal getOrdinal() const { return SecOrdinal; }
@@ -793,7 +793,7 @@ class Section {
 
   StringRef Name;
   orc::MemProt Prot;
-  orc::MemLifetimePolicy MLP = orc::MemLifetimePolicy::Standard;
+  orc::MemLifetime ML = orc::MemLifetime::Standard;
   SectionOrdinal SecOrdinal = 0;
   BlockSet Blocks;
   SymbolSet Symbols;

diff  --git a/llvm/include/llvm/ExecutionEngine/JITLink/JITLinkMemoryManager.h b/llvm/include/llvm/ExecutionEngine/JITLink/JITLinkMemoryManager.h
index 09e0d71cf0bd29c..1b8c4d4e181cdcc 100644
--- a/llvm/include/llvm/ExecutionEngine/JITLink/JITLinkMemoryManager.h
+++ b/llvm/include/llvm/ExecutionEngine/JITLink/JITLinkMemoryManager.h
@@ -292,8 +292,8 @@ class BasicLayout {
 /// address of that block using the Segment's AllocGroup. Once memory has been
 /// populated, clients can call finalize to finalize the memory.
 ///
-/// Note: Segments with MemLifetimePolicy::NoAlloc are not permitted, since
-/// they would not be useful, and their presence is likely to indicate a bug.
+/// Note: Segments with MemLifetime::NoAlloc are not permitted, since they would
+/// not be useful, and their presence is likely to indicate a bug.
 class SimpleSegmentAlloc {
 public:
   /// Describes a segment to be allocated.

diff  --git a/llvm/include/llvm/ExecutionEngine/Orc/Shared/MemoryFlags.h b/llvm/include/llvm/ExecutionEngine/Orc/Shared/MemoryFlags.h
index c20366cfbb38883..b8b5f90b6b0fbc8 100644
--- a/llvm/include/llvm/ExecutionEngine/Orc/Shared/MemoryFlags.h
+++ b/llvm/include/llvm/ExecutionEngine/Orc/Shared/MemoryFlags.h
@@ -72,7 +72,7 @@ inline MemProt fromSysMemoryProtectionFlags(sys::Memory::ProtectionFlags PF) {
 /// deallocated if a call is made to
 /// JITLinkMemoryManager::InFlightAllocation::abandon. The policies below apply
 /// to finalized allocations.
-enum class MemLifetimePolicy {
+enum class MemLifetime {
   /// Standard memory should be allocated by the allocator and then deallocated
   /// when the deallocate method is called for the finalized allocation.
   Standard,
@@ -89,15 +89,15 @@ enum class MemLifetimePolicy {
 };
 
 /// Print a MemDeallocPolicy.
-inline raw_ostream &operator<<(raw_ostream &OS, MemLifetimePolicy MLP) {
+inline raw_ostream &operator<<(raw_ostream &OS, MemLifetime MLP) {
   switch (MLP) {
-  case MemLifetimePolicy::Standard:
+  case MemLifetime::Standard:
     OS << "standard";
     break;
-  case MemLifetimePolicy::Finalize:
+  case MemLifetime::Finalize:
     OS << "finalize";
     break;
-  case MemLifetimePolicy::NoAlloc:
+  case MemLifetime::NoAlloc:
     OS << "noalloc";
     break;
   }
@@ -124,11 +124,11 @@ class AllocGroup {
   AllocGroup() = default;
 
   /// Create an AllocGroup from a MemProt only -- uses
-  /// MemLifetimePolicy::Standard.
+  /// MemLifetime::Standard.
   AllocGroup(MemProt MP) : Id(static_cast<underlying_type>(MP)) {}
 
-  /// Create an AllocGroup from a MemProt and a MemLifetimePolicy.
-  AllocGroup(MemProt MP, MemLifetimePolicy MLP)
+  /// Create an AllocGroup from a MemProt and a MemLifetime.
+  AllocGroup(MemProt MP, MemLifetime MLP)
       : Id(static_cast<underlying_type>(MP) |
            (static_cast<underlying_type>(MLP) << BitsForProt)) {}
 
@@ -137,9 +137,9 @@ class AllocGroup {
     return static_cast<MemProt>(Id & ((1U << BitsForProt) - 1));
   }
 
-  /// Returns the MemLifetimePolicy for this group.
-  MemLifetimePolicy getMemLifetimePolicy() const {
-    return static_cast<MemLifetimePolicy>(Id >> BitsForProt);
+  /// Returns the MemLifetime for this group.
+  MemLifetime getMemLifetime() const {
+    return static_cast<MemLifetime>(Id >> BitsForProt);
   }
 
   friend bool operator==(const AllocGroup &LHS, const AllocGroup &RHS) {
@@ -203,8 +203,7 @@ template <typename T> class AllocGroupSmallMap {
 
 /// Print an AllocGroup.
 inline raw_ostream &operator<<(raw_ostream &OS, AllocGroup AG) {
-  return OS << '(' << AG.getMemProt() << ", " << AG.getMemLifetimePolicy()
-            << ')';
+  return OS << '(' << AG.getMemProt() << ", " << AG.getMemLifetime() << ')';
 }
 
 } // end namespace orc

diff  --git a/llvm/include/llvm/ExecutionEngine/Orc/Shared/TargetProcessControlTypes.h b/llvm/include/llvm/ExecutionEngine/Orc/Shared/TargetProcessControlTypes.h
index 985baa769a67aad..7322674559c9e9e 100644
--- a/llvm/include/llvm/ExecutionEngine/Orc/Shared/TargetProcessControlTypes.h
+++ b/llvm/include/llvm/ExecutionEngine/Orc/Shared/TargetProcessControlTypes.h
@@ -36,10 +36,9 @@ struct RemoteAllocGroup {
   RemoteAllocGroup(MemProt Prot, bool FinalizeLifetime)
       : Prot(Prot), FinalizeLifetime(FinalizeLifetime) {}
   RemoteAllocGroup(const AllocGroup &AG) : Prot(AG.getMemProt()) {
-    assert(AG.getMemLifetimePolicy() != orc::MemLifetimePolicy::NoAlloc &&
+    assert(AG.getMemLifetime() != orc::MemLifetime::NoAlloc &&
            "Cannot use no-alloc memory in a remote alloc request");
-    FinalizeLifetime =
-        AG.getMemLifetimePolicy() == orc::MemLifetimePolicy::Finalize;
+    FinalizeLifetime = AG.getMemLifetime() == orc::MemLifetime::Finalize;
   }
 
   MemProt Prot;

diff  --git a/llvm/lib/ExecutionEngine/JITLink/COFFLinkGraphBuilder.cpp b/llvm/lib/ExecutionEngine/JITLink/COFFLinkGraphBuilder.cpp
index 30286ea8811f7ca..060b3d672340ca6 100644
--- a/llvm/lib/ExecutionEngine/JITLink/COFFLinkGraphBuilder.cpp
+++ b/llvm/lib/ExecutionEngine/JITLink/COFFLinkGraphBuilder.cpp
@@ -161,7 +161,7 @@ Error COFFLinkGraphBuilder::graphifySections() {
     if (!GraphSec) {
       GraphSec = &G->createSection(SectionName, Prot);
       if ((*Sec)->Characteristics & COFF::IMAGE_SCN_LNK_REMOVE)
-        GraphSec->setMemLifetimePolicy(orc::MemLifetimePolicy::NoAlloc);
+        GraphSec->setMemLifetime(orc::MemLifetime::NoAlloc);
     }
     if (GraphSec->getMemProt() != Prot)
       return make_error<JITLinkError>("MemProt should match");

diff  --git a/llvm/lib/ExecutionEngine/JITLink/ELFLinkGraphBuilder.h b/llvm/lib/ExecutionEngine/JITLink/ELFLinkGraphBuilder.h
index f221497b5efe4d8..1f545adcdf0e618 100644
--- a/llvm/lib/ExecutionEngine/JITLink/ELFLinkGraphBuilder.h
+++ b/llvm/lib/ExecutionEngine/JITLink/ELFLinkGraphBuilder.h
@@ -366,7 +366,7 @@ template <typename ELFT> Error ELFLinkGraphBuilder<ELFT>::graphifySections() {
       GraphSec = &G->createSection(*Name, Prot);
       // Non-SHF_ALLOC sections get NoAlloc memory lifetimes.
       if (!(Sec.sh_flags & ELF::SHF_ALLOC)) {
-        GraphSec->setMemLifetimePolicy(orc::MemLifetimePolicy::NoAlloc);
+        GraphSec->setMemLifetime(orc::MemLifetime::NoAlloc);
         LLVM_DEBUG({
           dbgs() << "      " << SecIndex << ": \"" << *Name
                  << "\" is not a SHF_ALLOC section. Using NoAlloc lifetime.\n";

diff  --git a/llvm/lib/ExecutionEngine/JITLink/JITLinkGeneric.h b/llvm/lib/ExecutionEngine/JITLink/JITLinkGeneric.h
index 25c533a5103be5c..12542e399360b61 100644
--- a/llvm/lib/ExecutionEngine/JITLink/JITLinkGeneric.h
+++ b/llvm/lib/ExecutionEngine/JITLink/JITLinkGeneric.h
@@ -134,8 +134,7 @@ template <typename LinkerImpl> class JITLinker : public JITLinkerBase {
     LLVM_DEBUG(dbgs() << "Fixing up blocks:\n");
 
     for (auto &Sec : G.sections()) {
-      bool NoAllocSection =
-          Sec.getMemLifetimePolicy() == orc::MemLifetimePolicy::NoAlloc;
+      bool NoAllocSection = Sec.getMemLifetime() == orc::MemLifetime::NoAlloc;
 
       for (auto *B : Sec.blocks()) {
         LLVM_DEBUG(dbgs() << "  " << *B << ":\n");
@@ -163,12 +162,11 @@ template <typename LinkerImpl> class JITLinker : public JITLinkerBase {
 
           // If B is a block in a Standard or Finalize section then make sure
           // that no edges point to symbols in NoAlloc sections.
-          assert(
-              (NoAllocSection || !E.getTarget().isDefined() ||
-               E.getTarget().getBlock().getSection().getMemLifetimePolicy() !=
-                   orc::MemLifetimePolicy::NoAlloc) &&
-              "Block in allocated section has edge pointing to no-alloc "
-              "section");
+          assert((NoAllocSection || !E.getTarget().isDefined() ||
+                  E.getTarget().getBlock().getSection().getMemLifetime() !=
+                      orc::MemLifetime::NoAlloc) &&
+                 "Block in allocated section has edge pointing to no-alloc "
+                 "section");
 
           // Dispatch to LinkerImpl for fixup.
           if (auto Err = impl().applyFixup(G, *B, E))

diff  --git a/llvm/lib/ExecutionEngine/JITLink/JITLinkMemoryManager.cpp b/llvm/lib/ExecutionEngine/JITLink/JITLinkMemoryManager.cpp
index f481504135a5fba..57e17aa78fed919 100644
--- a/llvm/lib/ExecutionEngine/JITLink/JITLinkMemoryManager.cpp
+++ b/llvm/lib/ExecutionEngine/JITLink/JITLinkMemoryManager.cpp
@@ -26,10 +26,10 @@ BasicLayout::BasicLayout(LinkGraph &G) : G(G) {
   for (auto &Sec : G.sections()) {
     // Skip empty sections, and sections with NoAlloc lifetime policies.
     if (Sec.blocks().empty() ||
-        Sec.getMemLifetimePolicy() == orc::MemLifetimePolicy::NoAlloc)
+        Sec.getMemLifetime() == orc::MemLifetime::NoAlloc)
       continue;
 
-    auto &Seg = Segments[{Sec.getMemProt(), Sec.getMemLifetimePolicy()}];
+    auto &Seg = Segments[{Sec.getMemProt(), Sec.getMemLifetime()}];
     for (auto *B : Sec.blocks())
       if (LLVM_LIKELY(!B->isZeroFill()))
         Seg.ContentBlocks.push_back(B);
@@ -90,7 +90,7 @@ BasicLayout::getContiguousPageBasedLayoutSizes(uint64_t PageSize) {
                                      inconvertibleErrorCode());
 
     uint64_t SegSize = alignTo(Seg.ContentSize + Seg.ZeroFillSize, PageSize);
-    if (AG.getMemLifetimePolicy() == orc::MemLifetimePolicy::Standard)
+    if (AG.getMemLifetime() == orc::MemLifetime::Standard)
       SegsSizes.StandardSegs += SegSize;
     else
       SegsSizes.FinalizeSegs += SegSize;
@@ -164,15 +164,15 @@ void SimpleSegmentAlloc::Create(JITLinkMemoryManager &MemMgr,
     auto &AG = KV.first;
     auto &Seg = KV.second;
 
-    assert(AG.getMemLifetimePolicy() != orc::MemLifetimePolicy::NoAlloc &&
+    assert(AG.getMemLifetime() != orc::MemLifetime::NoAlloc &&
            "NoAlloc segments are not supported by SimpleSegmentAlloc");
 
     auto AGSectionName =
         AGSectionNames[static_cast<unsigned>(AG.getMemProt()) |
-                       static_cast<bool>(AG.getMemLifetimePolicy()) << 3];
+                       static_cast<bool>(AG.getMemLifetime()) << 3];
 
     auto &Sec = G->createSection(AGSectionName, AG.getMemProt());
-    Sec.setMemLifetimePolicy(AG.getMemLifetimePolicy());
+    Sec.setMemLifetime(AG.getMemLifetime());
 
     if (Seg.ContentSize != 0) {
       NextAddr =
@@ -419,10 +419,9 @@ void InProcessMemoryManager::allocate(const JITLinkDylib *JD, LinkGraph &G,
     auto &AG = KV.first;
     auto &Seg = KV.second;
 
-    auto &SegAddr =
-        (AG.getMemLifetimePolicy() == orc::MemLifetimePolicy::Standard)
-            ? NextStandardSegAddr
-            : NextFinalizeSegAddr;
+    auto &SegAddr = (AG.getMemLifetime() == orc::MemLifetime::Standard)
+                        ? NextStandardSegAddr
+                        : NextFinalizeSegAddr;
 
     Seg.WorkingMem = SegAddr.toPtr<char *>();
     Seg.Addr = SegAddr;

diff  --git a/llvm/lib/ExecutionEngine/JITLink/MachOLinkGraphBuilder.cpp b/llvm/lib/ExecutionEngine/JITLink/MachOLinkGraphBuilder.cpp
index e876876014abb95..0927f2ff4e33805 100644
--- a/llvm/lib/ExecutionEngine/JITLink/MachOLinkGraphBuilder.cpp
+++ b/llvm/lib/ExecutionEngine/JITLink/MachOLinkGraphBuilder.cpp
@@ -192,7 +192,7 @@ Error MachOLinkGraphBuilder::createNormalizedSections() {
 
     // TODO: Are there any other criteria for NoAlloc lifetime?
     if (NSec.Flags & MachO::S_ATTR_DEBUG)
-      NSec.GraphSection->setMemLifetimePolicy(orc::MemLifetimePolicy::NoAlloc);
+      NSec.GraphSection->setMemLifetime(orc::MemLifetime::NoAlloc);
 
     IndexToSection.insert(std::make_pair(SecIndex, std::move(NSec)));
   }

diff  --git a/llvm/lib/ExecutionEngine/Orc/DebuggerSupportPlugin.cpp b/llvm/lib/ExecutionEngine/Orc/DebuggerSupportPlugin.cpp
index 63c188676d197b4..560311214bf1859 100644
--- a/llvm/lib/ExecutionEngine/Orc/DebuggerSupportPlugin.cpp
+++ b/llvm/lib/ExecutionEngine/Orc/DebuggerSupportPlugin.cpp
@@ -110,7 +110,7 @@ class MachODebugObjectSynthesizer : public MachODebugObjectSynthesizerBase {
 
       if (isDebugSection(Sec))
         DebugSections.push_back({&Sec, nullptr});
-      else if (Sec.getMemLifetimePolicy() != MemLifetimePolicy::NoAlloc)
+      else if (Sec.getMemLifetime() != MemLifetime::NoAlloc)
         NonDebugSections.push_back({&Sec, nullptr});
     }
 

diff  --git a/llvm/lib/ExecutionEngine/Orc/MemoryMapper.cpp b/llvm/lib/ExecutionEngine/Orc/MemoryMapper.cpp
index ca4950077ffe92a..9cfe547c84c310b 100644
--- a/llvm/lib/ExecutionEngine/Orc/MemoryMapper.cpp
+++ b/llvm/lib/ExecutionEngine/Orc/MemoryMapper.cpp
@@ -322,8 +322,8 @@ void SharedMemoryMapper::initialize(MemoryMapper::AllocInfo &AI,
     std::memset(Base + Segment.ContentSize, 0, Segment.ZeroFillSize);
 
     tpctypes::SharedMemorySegFinalizeRequest SegReq;
-    SegReq.RAG = {Segment.AG.getMemProt(), Segment.AG.getMemLifetimePolicy() ==
-                                               MemLifetimePolicy::Finalize};
+    SegReq.RAG = {Segment.AG.getMemProt(),
+                  Segment.AG.getMemLifetime() == MemLifetime::Finalize};
     SegReq.Addr = AI.MappingBase + Segment.Offset;
     SegReq.Size = Segment.ContentSize + Segment.ZeroFillSize;
 

diff  --git a/llvm/tools/llvm-jitlink/llvm-jitlink.cpp b/llvm/tools/llvm-jitlink/llvm-jitlink.cpp
index 42ef651851a4ac5..c1354ee96c6ef8d 100644
--- a/llvm/tools/llvm-jitlink/llvm-jitlink.cpp
+++ b/llvm/tools/llvm-jitlink/llvm-jitlink.cpp
@@ -512,7 +512,7 @@ class InProcessDeltaMapper final : public InProcessMemoryMapper {
     auto FixedAI = std::move(AI);
     FixedAI.MappingBase -= DeltaAddr;
     for (auto &Seg : FixedAI.Segments)
-      Seg.AG = {MemProt::Read | MemProt::Write, Seg.AG.getMemLifetimePolicy()};
+      Seg.AG = {MemProt::Read | MemProt::Write, Seg.AG.getMemLifetime()};
     FixedAI.Actions.clear();
     InProcessMemoryMapper::initialize(
         FixedAI, [this, OnInitialized = std::move(OnInitialized)](

diff  --git a/llvm/unittests/ExecutionEngine/JITLink/LinkGraphTests.cpp b/llvm/unittests/ExecutionEngine/JITLink/LinkGraphTests.cpp
index ff153f6d4b32766..711f35fc7683c31 100644
--- a/llvm/unittests/ExecutionEngine/JITLink/LinkGraphTests.cpp
+++ b/llvm/unittests/ExecutionEngine/JITLink/LinkGraphTests.cpp
@@ -798,7 +798,7 @@ TEST(LinkGraphTest, BasicLayoutHonorsNoAlloc) {
   // Create a NoAlloc section and block.
   auto &Sec2 =
       G.createSection("__metadata", orc::MemProt::Read | orc::MemProt::Write);
-  Sec2.setMemLifetimePolicy(orc::MemLifetimePolicy::NoAlloc);
+  Sec2.setMemLifetime(orc::MemLifetime::NoAlloc);
   G.createContentBlock(Sec2, BlockContent.slice(0, 8), orc::ExecutorAddr(), 8,
                        0);
 


        


More information about the llvm-commits mailing list