[PATCH] D108722: [CSSPGO] Avoid repeatedly compute md5 hash code for pseudo probe inline contexts.

Hongtao Yu via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Aug 25 12:00:12 PDT 2021


hoy created this revision.
Herald added subscribers: modimo, wenlei, hiraditya.
hoy requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Using a hash map to look up already computed GUID for dwarf names. Saw a 2% build time improvement on an internal large application.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D108722

Files:
  llvm/lib/CodeGen/AsmPrinter/PseudoProbePrinter.cpp
  llvm/lib/CodeGen/AsmPrinter/PseudoProbePrinter.h


Index: llvm/lib/CodeGen/AsmPrinter/PseudoProbePrinter.h
===================================================================
--- llvm/lib/CodeGen/AsmPrinter/PseudoProbePrinter.h
+++ llvm/lib/CodeGen/AsmPrinter/PseudoProbePrinter.h
@@ -26,9 +26,12 @@
 class PseudoProbeHandler : public AsmPrinterHandler {
   // Target of pseudo probe emission.
   AsmPrinter *Asm;
+  // Name to GUID map
+  DenseMap<StringRef, uint64_t> NameGuidMap;
 
 public:
   PseudoProbeHandler(AsmPrinter *A) : Asm(A){};
+  ~PseudoProbeHandler() override;
 
   void emitPseudoProbe(uint64_t Guid, uint64_t Index, uint64_t Type,
                        uint64_t Attr, const DILocation *DebugLoc);
Index: llvm/lib/CodeGen/AsmPrinter/PseudoProbePrinter.cpp
===================================================================
--- llvm/lib/CodeGen/AsmPrinter/PseudoProbePrinter.cpp
+++ llvm/lib/CodeGen/AsmPrinter/PseudoProbePrinter.cpp
@@ -20,6 +20,8 @@
 
 using namespace llvm;
 
+PseudoProbeHandler::~PseudoProbeHandler() = default;
+
 void PseudoProbeHandler::emitPseudoProbe(uint64_t Guid, uint64_t Index,
                                          uint64_t Type, uint64_t Attr,
                                          const DILocation *DebugLoc) {
@@ -33,9 +35,9 @@
     const DISubprogram *SP = InlinedAt->getScope()->getSubprogram();
     // Use linkage name for C++ if possible.
     auto Name = SP->getLinkageName();
-    if (Name.empty())
-      Name = SP->getName();
-    uint64_t CallerGuid = Function::getGUID(Name);
+    uint64_t &CallerGuid = NameGuidMap[Name];
+    if (!CallerGuid)
+      CallerGuid = Function::getGUID(Name);
     uint64_t CallerProbeId = PseudoProbeDwarfDiscriminator::extractProbeIndex(
         InlinedAt->getDiscriminator());
     ReversedInlineStack.emplace_back(CallerGuid, CallerProbeId);


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D108722.368698.patch
Type: text/x-patch
Size: 1799 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210825/ddaf75df/attachment.bin>


More information about the llvm-commits mailing list