forked from OSchip/llvm-project
[CSSPGO] Avoid repeatedly computing md5 hash code for pseudo probe inline contexts.
Md5 hashing is expansive. Using a hash map to look up already computed GUID for dwarf names. Saw a 2% build time improvement on an internal large application. Reviewed By: wenlei Differential Revision: https://reviews.llvm.org/D108722
This commit is contained in:
parent
881677b58a
commit
f39256e3a5
|
@ -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 @@ void PseudoProbeHandler::emitPseudoProbe(uint64_t Guid, uint64_t Index,
|
|||
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);
|
||||
|
|
|
@ -26,9 +26,12 @@ class DILocation;
|
|||
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);
|
||||
|
|
Loading…
Reference in New Issue