[llvm] [CGData] Skip reading Names into StableFunctionMap in non-assertion b… (PR #142095)

Ellis Hoag via llvm-commits llvm-commits at lists.llvm.org
Wed Jun 4 14:28:38 PDT 2025


================
@@ -77,26 +77,33 @@ static IndexOperandHashVecType getStableIndexOperandHashes(
   return IndexOperandHashes;
 }
 
-void StableFunctionMapRecord::serialize(raw_ostream &OS) const {
-  serialize(OS, FunctionMap.get());
+void StableFunctionMapRecord::serialize(
+    raw_ostream &OS, std::vector<CGDataPatchItem> &PatchItems) const {
+  serialize(OS, FunctionMap.get(), PatchItems);
 }
 
-void StableFunctionMapRecord::serialize(raw_ostream &OS,
-                                        const StableFunctionMap *FunctionMap) {
+void StableFunctionMapRecord::serialize(
+    raw_ostream &OS, const StableFunctionMap *FunctionMap,
+    std::vector<CGDataPatchItem> &PatchItems) {
   support::endian::Writer Writer(OS, endianness::little);
 
   // Write Names.
   ArrayRef<std::string> Names = FunctionMap->getNames();
-  uint32_t ByteSize = 4;
   Writer.write<uint32_t>(Names.size());
+  // Remember the position, write back the total size of Names, so we can skip
+  // reading them if needed.
+  const uint64_t NamesByteSizeOffset = Writer.OS.tell();
+  Writer.write<uint64_t>(0);
   for (auto &Name : Names) {
----------------
ellishg wrote:

```suggestion
  for (auto &Name : Names)
```

https://github.com/llvm/llvm-project/pull/142095


More information about the llvm-commits mailing list