[PATCH] D136698: [SampleFDO] Persist profile staleness metrics into binary

Lei Wang via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Oct 26 17:35:27 PDT 2022


wlei added a comment.

In D136698#3886105 <https://reviews.llvm.org/D136698#3886105>, @wenlei wrote:

> This can be dealt with later but do we need separate support (i.e. MCAsmStreamer?) for llvm-objdump to print out stats nicely?

Good idea to dump it in a human readable way, will try it later.



================
Comment at: llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp:370
+  if (NamedMDNode *LLVMStats = M.getNamedMetadata("llvm.stats")) {
+    auto *S = C.getObjectFileInfo()->getLLVMStatsSection();
+    Streamer.switchSection(S);
----------------
hoy wrote:
> S could end up null. Suggest `getLLVMStatsSection` to return a non-null ptr even if it's non-elf. The work should work for non-elf since we are not using comdat concept here.
I see, removed the ELF condition.


================
Comment at: llvm/lib/MC/MCObjectFileInfo.cpp:534
       Ctx->getELFSection(".pseudo_probe_desc", DebugSecType, 0);
+  LLVMStatsSection = Ctx->getELFSection(".llvm_stats", DebugSecType, 0);
 }
----------------
wenlei wrote:
> Use explicit section type `ELF::SHT_PROGBITS` instead of `DebugSecType`.
fixed, thanks!


================
Comment at: llvm/lib/Transforms/IPO/SampleProfile.cpp:2174
+    MDBuilder MDB(Ctx);
+    SmallVector<std::pair<std::string, uint64_t>> ProfStatsVec;
+    if (FunctionSamples::ProfileIsProbeBased) {
----------------
hoy wrote:
> nit: StringRef should work here since all keys are literal constants.
fixed, thanks!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D136698



More information about the llvm-commits mailing list