[llvm] [CGData] Lazy loading support for stable function map (PR #151660)

Kyungwoo Lee via llvm-commits llvm-commits at lists.llvm.org
Fri Aug 8 10:36:19 PDT 2025


================
@@ -104,17 +104,39 @@ void StableFunctionMapRecord::serialize(
       Writer.OS.tell() - NamesByteSizeOffset - sizeof(NamesByteSizeOffset);
   PatchItems.emplace_back(NamesByteSizeOffset, &NamesByteSize, 1);
 
-  // Write StableFunctionEntries whose pointers are sorted.
+  // Write StableFunctionEntries. The structure is:
+  // - Number of StableFunctionEntries
+  // - Hashes of StableFunctionEntries
+  // - Fixed-size fields for each StableFunctionEntry
+  //   - FunctionNameId
+  //   - ModuleNameId
+  //   - InstCount
+  //   - Relative offset to IndexOperandHashes
+  // - Total size of variable-sized IndexOperandHashes for lazy-loading support
+  // - Variable-sized IndexOperandHashes for each StableFunctionEntry
+  //   - Number of IndexOperandHashes
+  //   - Contents of each IndexOperandHashes
   auto FuncEntries = getStableFunctionEntries(*FunctionMap);
   Writer.write<uint32_t>(FuncEntries.size());
-
-  for (const auto *FuncRef : FuncEntries) {
+  for (const auto *FuncRef : FuncEntries)
----------------
kyulee-com wrote:

Serializing all hashes followed by all func entries seems unnatural. Can we do this hash for each func entry? Your `deserialize()` actually seems not consistent on this matter.

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


More information about the llvm-commits mailing list