[llvm] [MemProf] Print full context hash when reporting hinted bytes (PR #114465)

Teresa Johnson via llvm-commits llvm-commits at lists.llvm.org
Thu Nov 7 11:33:29 PST 2024


================
@@ -4404,6 +4410,24 @@ void ModuleBitcodeWriterBase::writePerModuleGlobalValueSummary() {
     Stream.EmitRecord(bitc::FS_STACK_IDS, Index->stackIds(), StackIdAbbvId);
   }
 
+  SmallVector<uint64_t, 64> NameVals;
+  if (!Index->contextSizeInfos().empty()) {
+    auto ContextSizeInfoAbbv = std::make_shared<BitCodeAbbrev>();
+    ContextSizeInfoAbbv->Add(BitCodeAbbrevOp(bitc::FS_CONTEXT_SIZE_INFOS));
+    // numids x (fullStackid, totalsize)
+    ContextSizeInfoAbbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Array));
+    ContextSizeInfoAbbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 8));
+    unsigned ContextSizeInfoAbbvId =
+        Stream.EmitAbbrev(std::move(ContextSizeInfoAbbv));
+    for (const auto &Info : Index->contextSizeInfos()) {
+      NameVals.push_back(Info.FullStackId);
+      NameVals.push_back(Info.TotalSize);
+    }
+    Stream.EmitRecord(bitc::FS_CONTEXT_SIZE_INFOS, NameVals,
+                      ContextSizeInfoAbbvId);
+    NameVals.clear();
----------------
teresajohnson wrote:

Is it worth it? We reuse this vector multiple times for other records. And the lifetime is not so long that it is going to make any noticeable difference on memory (this is in the pre-lto link compile).

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


More information about the llvm-commits mailing list