[PATCH] D108722: [CSSPGO] Avoid repeatedly computing md5 hash code for pseudo probe inline contexts.
Hongtao Yu via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Aug 30 10:12:20 PDT 2021
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rGf39256e3a5dd: [CSSPGO] Avoid repeatedly computing md5 hash code for pseudo probe inlineā¦ (authored by hoy).
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D108722/new/
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, used as caching/memoization for speed.
+ 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) {
@@ -35,7 +37,10 @@
auto Name = SP->getLinkageName();
if (Name.empty())
Name = SP->getName();
- uint64_t CallerGuid = Function::getGUID(Name);
+ // Use caching to avoid redundant md5 computation for build speed.
+ 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.369481.patch
Type: text/x-patch
Size: 1796 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210830/fc861051/attachment.bin>
More information about the llvm-commits
mailing list