[PATCH] D104158: [not for review] Dump counts of literals/subsections

Jez Ng via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Jun 11 16:32:40 PDT 2021


int3 created this revision.
Herald added a reviewer: gkm.
Herald added a project: lld-macho.
Herald added a reviewer: lld-macho.
int3 requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D104158

Files:
  lld/MachO/InputFiles.cpp
  lld/MachO/InputSection.cpp
  lld/MachO/SyntheticSections.cpp


Index: lld/MachO/SyntheticSections.cpp
===================================================================
--- lld/MachO/SyntheticSections.cpp
+++ lld/MachO/SyntheticSections.cpp
@@ -1142,6 +1142,7 @@
 }
 
 void WordLiteralSection::addInput(WordLiteralInputSection *isec) {
+  size_t litCount = 0;
   isec->parent = this;
   // We do all processing of the InputSection here, so it will be effectively
   // finalized.
@@ -1150,6 +1151,7 @@
   switch (sectionType(isec->flags)) {
   case S_4BYTE_LITERALS: {
     for (size_t off = 0, e = isec->data.size(); off < e; off += 4) {
+      ++litCount;
       if (!isec->isLive(off))
         continue;
       uint32_t value = *reinterpret_cast<const uint32_t *>(buf + off);
@@ -1159,6 +1161,7 @@
   }
   case S_8BYTE_LITERALS: {
     for (size_t off = 0, e = isec->data.size(); off < e; off += 8) {
+      ++litCount;
       if (!isec->isLive(off))
         continue;
       uint64_t value = *reinterpret_cast<const uint64_t *>(buf + off);
@@ -1168,6 +1171,7 @@
   }
   case S_16BYTE_LITERALS: {
     for (size_t off = 0, e = isec->data.size(); off < e; off += 16) {
+      ++litCount;
       if (!isec->isLive(off))
         continue;
       UInt128 value = *reinterpret_cast<const UInt128 *>(buf + off);
@@ -1178,6 +1182,7 @@
   default:
     llvm_unreachable("invalid literal section type");
   }
+  fprintf(stderr, "litcount: %zu\n", litCount);
 }
 
 void WordLiteralSection::writeTo(uint8_t *buf) const {
Index: lld/MachO/InputSection.cpp
===================================================================
--- lld/MachO/InputSection.cpp
+++ lld/MachO/InputSection.cpp
@@ -106,6 +106,7 @@
     s = s.substr(size);
     off += size;
   }
+  fprintf(stderr, "Created %zu strings\n", pieces.size());
 }
 
 StringPiece &CStringInputSection::getStringPiece(uint64_t off) {
Index: lld/MachO/InputFiles.cpp
===================================================================
--- lld/MachO/InputFiles.cpp
+++ lld/MachO/InputFiles.cpp
@@ -597,6 +597,7 @@
                            ArrayRef<typename LP::nlist> nList,
                            const char *strtab, bool subsectionsViaSymbols) {
   using NList = typename LP::nlist;
+  size_t subsecCount = 0;
 
   // Groups indices of the symbols by the sections that contain them.
   std::vector<std::vector<uint32_t>> symbolsBySection(subsections.size());
@@ -621,6 +622,7 @@
     SubsectionMap &subsecMap = subsections[i];
     if (subsecMap.empty())
       continue;
+    subsecCount++;
 
     std::vector<uint32_t> &symbolIndices = symbolsBySection[i];
     llvm::sort(symbolIndices, [&](uint32_t lhs, uint32_t rhs) {
@@ -675,8 +677,10 @@
       nextIsec->align = MinAlign(sectionAlign, sym.n_value);
       subsecMap.push_back({sym.n_value - sectionAddr, nextIsec});
       subsecEntry = subsecMap.back();
+      subsecCount++;
     }
   }
+  fprintf(stderr, "Created %zu subsections\n", subsecCount);
 }
 
 OpaqueFile::OpaqueFile(MemoryBufferRef mb, StringRef segName,


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D104158.351575.patch
Type: text/x-patch
Size: 2968 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210611/3df3fded/attachment.bin>


More information about the llvm-commits mailing list