Rename EHFrameSplitter to DWARFRecordSectionSplitter
authorShubham Sandeep Rastogi <srastogi22@apple.com>
Fri, 11 Mar 2022 20:14:05 +0000 (12:14 -0800)
committerShubham Sandeep Rastogi <srastogi22@apple.com>
Sat, 12 Mar 2022 00:02:31 +0000 (16:02 -0800)
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

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

index 21bdb3f..da618fe 100644 (file)
 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");
index ef4b47b..425a8af 100644 (file)
 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
index 79d2cdb..398a38f 100644 (file)
@@ -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));
index 3ca2e40..b4a41e6 100644 (file)
@@ -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));
 
index 82afaa3..5e5bafe 100644 (file)
@@ -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() {
index 34b4830..425f981 100644 (file)
@@ -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