[llvm] 229d576 - Rename EHFrameSplitter to DWARFRecordSectionSplitter

Shubham Sandeep Rastogi via llvm-commits llvm-commits at lists.llvm.org
Fri Mar 11 16:02:40 PST 2022


Author: Shubham Sandeep Rastogi
Date: 2022-03-11T16:02:31-08:00
New Revision: 229d576b31f4071ab68c85ac4fabb78cfa502b04

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

LOG: Rename EHFrameSplitter to DWARFRecordSectionSplitter

EHFrameSplitter does the exact same work to split up the eh_frame as it would need for any section that follows the DWARF record, therefore this patch just changes the name of it to DWARFRecordSectionSplitter to be more general.

Differential Revision: https://reviews.llvm.org/D121486

Added: 
    

Modified: 
    llvm/lib/ExecutionEngine/JITLink/EHFrameSupport.cpp
    llvm/lib/ExecutionEngine/JITLink/EHFrameSupportImpl.h
    llvm/lib/ExecutionEngine/JITLink/ELF_x86_64.cpp
    llvm/lib/ExecutionEngine/JITLink/MachO_arm64.cpp
    llvm/lib/ExecutionEngine/JITLink/MachO_x86_64.cpp
    llvm/test/ExecutionEngine/JITLink/AArch64/MachO_arm64_ehframe.s

Removed: 
    


################################################################################
diff  --git a/llvm/lib/ExecutionEngine/JITLink/EHFrameSupport.cpp b/llvm/lib/ExecutionEngine/JITLink/EHFrameSupport.cpp
index 21bdb3ff1920d..da618fe0c12bb 100644
--- a/llvm/lib/ExecutionEngine/JITLink/EHFrameSupport.cpp
+++ b/llvm/lib/ExecutionEngine/JITLink/EHFrameSupport.cpp
@@ -18,40 +18,41 @@
 namespace llvm {
 namespace jitlink {
 
-EHFrameSplitter::EHFrameSplitter(StringRef EHFrameSectionName)
-    : EHFrameSectionName(EHFrameSectionName) {}
+DWARFRecordSectionSplitter::DWARFRecordSectionSplitter(StringRef SectionName)
+    : SectionName(SectionName) {}
 
-Error EHFrameSplitter::operator()(LinkGraph &G) {
-  auto *EHFrame = G.findSectionByName(EHFrameSectionName);
+Error DWARFRecordSectionSplitter::operator()(LinkGraph &G) {
+  auto *Section = G.findSectionByName(SectionName);
 
-  if (!EHFrame) {
+  if (!Section) {
     LLVM_DEBUG({
-      dbgs() << "EHFrameSplitter: No " << EHFrameSectionName
+      dbgs() << "DWARFRecordSectionSplitter: No " << SectionName
              << " section. Nothing to do\n";
     });
     return Error::success();
   }
 
   LLVM_DEBUG({
-    dbgs() << "EHFrameSplitter: Processing " << EHFrameSectionName << "...\n";
+    dbgs() << "DWARFRecordSectionSplitter: Processing " << SectionName
+           << "...\n";
   });
 
   DenseMap<Block *, LinkGraph::SplitBlockCache> Caches;
 
   {
     // Pre-build the split caches.
-    for (auto *B : EHFrame->blocks())
+    for (auto *B : Section->blocks())
       Caches[B] = LinkGraph::SplitBlockCache::value_type();
-    for (auto *Sym : EHFrame->symbols())
+    for (auto *Sym : Section->symbols())
       Caches[&Sym->getBlock()]->push_back(Sym);
-    for (auto *B : EHFrame->blocks())
+    for (auto *B : Section->blocks())
       llvm::sort(*Caches[B], [](const Symbol *LHS, const Symbol *RHS) {
         return LHS->getOffset() > RHS->getOffset();
       });
   }
 
   // Iterate over blocks (we do this by iterating over Caches entries rather
-  // than EHFrame->blocks() as we will be inserting new blocks along the way,
+  // than Section->blocks() as we will be inserting new blocks along the way,
   // which would invalidate iterators in the latter sequence.
   for (auto &KV : Caches) {
     auto &B = *KV.first;
@@ -63,14 +64,14 @@ Error EHFrameSplitter::operator()(LinkGraph &G) {
   return Error::success();
 }
 
-Error EHFrameSplitter::processBlock(LinkGraph &G, Block &B,
-                                    LinkGraph::SplitBlockCache &Cache) {
+Error DWARFRecordSectionSplitter::processBlock(
+    LinkGraph &G, Block &B, LinkGraph::SplitBlockCache &Cache) {
   LLVM_DEBUG(dbgs() << "  Processing block at " << B.getAddress() << "\n");
 
-  // eh-frame should not contain zero-fill blocks.
+  // Section should not contain zero-fill blocks.
   if (B.isZeroFill())
     return make_error<JITLinkError>("Unexpected zero-fill block in " +
-                                    EHFrameSectionName + " section");
+                                    SectionName + " section");
 
   if (B.getSize() == 0) {
     LLVM_DEBUG(dbgs() << "    Block is empty. Skipping.\n");

diff  --git a/llvm/lib/ExecutionEngine/JITLink/EHFrameSupportImpl.h b/llvm/lib/ExecutionEngine/JITLink/EHFrameSupportImpl.h
index ef4b47b9aa28c..425a8afef1c98 100644
--- a/llvm/lib/ExecutionEngine/JITLink/EHFrameSupportImpl.h
+++ b/llvm/lib/ExecutionEngine/JITLink/EHFrameSupportImpl.h
@@ -21,19 +21,19 @@
 namespace llvm {
 namespace jitlink {
 
-/// A LinkGraph pass that splits blocks in an eh-frame section into sub-blocks
-/// representing individual eh-frames.
-/// EHFrameSplitter should not be run without EHFrameEdgeFixer, which is
-/// responsible for adding FDE-to-CIE edges.
-class EHFrameSplitter {
+/// A LinkGraph pass that splits blocks in a section that follows the DWARF
+/// Record format into sub-blocks where each header gets its own block.
+/// When splitting EHFrames, DWARFRecordSectionSplitter should not be run
+/// without EHFrameEdgeFixer, which is responsible for adding FDE-to-CIE edges.
+class DWARFRecordSectionSplitter {
 public:
-  EHFrameSplitter(StringRef EHFrameSectionName);
+  DWARFRecordSectionSplitter(StringRef SectionName);
   Error operator()(LinkGraph &G);
 
 private:
   Error processBlock(LinkGraph &G, Block &B, LinkGraph::SplitBlockCache &Cache);
 
-  StringRef EHFrameSectionName;
+  StringRef SectionName;
 };
 
 /// A LinkGraph pass that adds missing FDE-to-CIE, FDE-to-PC and FDE-to-LSDA

diff  --git a/llvm/lib/ExecutionEngine/JITLink/ELF_x86_64.cpp b/llvm/lib/ExecutionEngine/JITLink/ELF_x86_64.cpp
index 79d2cdbb30f18..398a38f6c6e2b 100644
--- a/llvm/lib/ExecutionEngine/JITLink/ELF_x86_64.cpp
+++ b/llvm/lib/ExecutionEngine/JITLink/ELF_x86_64.cpp
@@ -379,7 +379,7 @@ void link_ELF_x86_64(std::unique_ptr<LinkGraph> G,
 
   if (Ctx->shouldAddDefaultTargetPasses(G->getTargetTriple())) {
 
-    Config.PrePrunePasses.push_back(EHFrameSplitter(".eh_frame"));
+    Config.PrePrunePasses.push_back(DWARFRecordSectionSplitter(".eh_frame"));
     Config.PrePrunePasses.push_back(
         EHFrameEdgeFixer(".eh_frame", x86_64::PointerSize, x86_64::Delta64,
                          x86_64::Delta32, x86_64::NegDelta32));

diff  --git a/llvm/lib/ExecutionEngine/JITLink/MachO_arm64.cpp b/llvm/lib/ExecutionEngine/JITLink/MachO_arm64.cpp
index 3ca2e40c7263f..b4a41e68991b9 100644
--- a/llvm/lib/ExecutionEngine/JITLink/MachO_arm64.cpp
+++ b/llvm/lib/ExecutionEngine/JITLink/MachO_arm64.cpp
@@ -712,7 +712,8 @@ void link_MachO_arm64(std::unique_ptr<LinkGraph> G,
     // Add eh-frame passses.
     // FIXME: Prune eh-frames for which compact-unwind is available once
     // we support compact-unwind registration with libunwind.
-    Config.PrePrunePasses.push_back(EHFrameSplitter("__TEXT,__eh_frame"));
+    Config.PrePrunePasses.push_back(
+        DWARFRecordSectionSplitter("__TEXT,__eh_frame"));
     Config.PrePrunePasses.push_back(
         EHFrameEdgeFixer("__TEXT,__eh_frame", 8, Delta64, Delta32, NegDelta32));
 

diff  --git a/llvm/lib/ExecutionEngine/JITLink/MachO_x86_64.cpp b/llvm/lib/ExecutionEngine/JITLink/MachO_x86_64.cpp
index 82afaa3aa3c55..5e5bafe921e39 100644
--- a/llvm/lib/ExecutionEngine/JITLink/MachO_x86_64.cpp
+++ b/llvm/lib/ExecutionEngine/JITLink/MachO_x86_64.cpp
@@ -504,7 +504,7 @@ void link_MachO_x86_64(std::unique_ptr<LinkGraph> G,
 }
 
 LinkGraphPassFunction createEHFrameSplitterPass_MachO_x86_64() {
-  return EHFrameSplitter("__TEXT,__eh_frame");
+  return DWARFRecordSectionSplitter("__TEXT,__eh_frame");
 }
 
 LinkGraphPassFunction createEHFrameEdgeFixerPass_MachO_x86_64() {

diff  --git a/llvm/test/ExecutionEngine/JITLink/AArch64/MachO_arm64_ehframe.s b/llvm/test/ExecutionEngine/JITLink/AArch64/MachO_arm64_ehframe.s
index 34b4830d029ae..425f981c48471 100644
--- a/llvm/test/ExecutionEngine/JITLink/AArch64/MachO_arm64_ehframe.s
+++ b/llvm/test/ExecutionEngine/JITLink/AArch64/MachO_arm64_ehframe.s
@@ -5,7 +5,7 @@
 #
 # Check that splitting of eh-frame sections works.
 #
-# CHECK: EHFrameSplitter: Processing __TEXT,__eh_frame...
+# CHECK: DWARFRecordSectionSplitter: Processing __TEXT,__eh_frame...
 # CHECK:  Processing block at
 # CHECK:    Processing CFI record at
 # CHECK:      Extracted {{.*}} section = __TEXT,__eh_frame


        


More information about the llvm-commits mailing list