[PATCH] D117273: [lld-macho] Simplify DeduplicatedCStringSection::finalizeContents. NFC

Fangrui Song via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Jan 14 13:13:13 PST 2022


This revision was automatically updated to reflect the committed changes.
Closed by commit rG7c269db779ff: [lld-macho] Simplify DeduplicatedCStringSection::finalizeContents. NFC (authored by MaskRay).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D117273/new/

https://reviews.llvm.org/D117273

Files:
  lld/MachO/SyntheticSections.cpp


Index: lld/MachO/SyntheticSections.cpp
===================================================================
--- lld/MachO/SyntheticSections.cpp
+++ lld/MachO/SyntheticSections.cpp
@@ -1379,26 +1379,15 @@
 void DeduplicatedCStringSection::finalizeContents() {
   // Add all string pieces to the string table builder to create section
   // contents.
-  for (const CStringInputSection *isec : inputs)
+  for (CStringInputSection *isec : inputs) {
     for (size_t i = 0, e = isec->pieces.size(); i != e; ++i)
       if (isec->pieces[i].live)
-        builder.add(isec->getCachedHashStringRef(i));
+        isec->pieces[i].outSecOff =
+            builder.add(isec->getCachedHashStringRef(i));
+    isec->isFinal = true;
+  }
 
-  // Fix the string table content. After this, the contents will never change.
   builder.finalizeInOrder();
-
-  // finalize() fixed tail-optimized strings, so we can now get
-  // offsets of strings. Get an offset for each string and save it
-  // to a corresponding SectionPiece for easy access.
-  for (CStringInputSection *isec : inputs) {
-    for (size_t i = 0, e = isec->pieces.size(); i != e; ++i) {
-      if (!isec->pieces[i].live)
-        continue;
-      isec->pieces[i].outSecOff =
-          builder.getOffset(isec->getCachedHashStringRef(i));
-      isec->isFinal = true;
-    }
-  }
 }
 
 // This section is actually emitted as __TEXT,__const by ld64, but clang may


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D117273.400126.patch
Type: text/x-patch
Size: 1409 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220114/62e7b383/attachment.bin>


More information about the llvm-commits mailing list