[PATCH] D107779: Support MD5-based context at the early stage of profile generation
Lei Wang via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Aug 9 12:17:57 PDT 2021
wlei created this revision.
Herald added subscribers: hoy, wenlei, lxfind, hiraditya.
wlei requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D107779
Files:
llvm/include/llvm/MC/MCPseudoProbe.h
llvm/lib/MC/MCPseudoProbe.cpp
llvm/tools/llvm-profgen/ProfileGenerator.cpp
llvm/tools/llvm-profgen/ProfiledBinary.h
Index: llvm/tools/llvm-profgen/ProfiledBinary.h
===================================================================
--- llvm/tools/llvm-profgen/ProfiledBinary.h
+++ llvm/tools/llvm-profgen/ProfiledBinary.h
@@ -272,9 +272,9 @@
void
getInlineContextForProbe(const MCDecodedPseudoProbe *Probe,
SmallVectorImpl<std::string> &InlineContextStack,
- bool IncludeLeaf = false) const {
+ bool UseMD5, bool IncludeLeaf = false) const {
return ProbeDecoder.getInlineContextForProbe(Probe, InlineContextStack,
- IncludeLeaf);
+ UseMD5, IncludeLeaf);
}
const AddressProbesMap &getAddress2ProbesMap() const {
return ProbeDecoder.getAddress2ProbesMap();
Index: llvm/tools/llvm-profgen/ProfileGenerator.cpp
===================================================================
--- llvm/tools/llvm-profgen/ProfileGenerator.cpp
+++ llvm/tools/llvm-profgen/ProfileGenerator.cpp
@@ -452,7 +452,7 @@
const SmallVectorImpl<const MCDecodedPseudoProbe *> &Probes,
ProfiledBinary *Binary) {
for (const auto *P : Probes) {
- Binary->getInlineContextForProbe(P, ContextStrStack, true);
+ Binary->getInlineContextForProbe(P, ContextStrStack, UseMD5, true);
}
}
@@ -646,7 +646,8 @@
// Explicitly copy the context for appending the leaf context
SmallVector<std::string, 16> ContextStrStackCopy(ContextStrStack.begin(),
ContextStrStack.end());
- Binary->getInlineContextForProbe(LeafProbe, ContextStrStackCopy, true);
+ Binary->getInlineContextForProbe(LeafProbe, ContextStrStackCopy, UseMD5,
+ true);
const auto *FuncDesc = Binary->getFuncDescForGUID(LeafProbe->getGuid());
bool WasLeafInlined = LeafProbe->getInlineTreeNode()->hasInlineSite();
return getFunctionProfileForLeafProbe(ContextStrStackCopy, FuncDesc,
Index: llvm/lib/MC/MCPseudoProbe.cpp
===================================================================
--- llvm/lib/MC/MCPseudoProbe.cpp
+++ llvm/lib/MC/MCPseudoProbe.cpp
@@ -555,15 +555,24 @@
void MCPseudoProbeDecoder::getInlineContextForProbe(
const MCDecodedPseudoProbe *Probe,
- SmallVectorImpl<std::string> &InlineContextStack, bool IncludeLeaf) const {
- Probe->getInlineContext(InlineContextStack, GUID2FuncDescMap, true);
+ SmallVectorImpl<std::string> &InlineContextStack, bool UseMD5,
+ bool IncludeLeaf) const {
+ Probe->getInlineContext(InlineContextStack, GUID2FuncDescMap, !UseMD5);
if (!IncludeLeaf)
return;
+
// Note that the context from probe doesn't include leaf frame,
// hence we need to retrieve and prepend leaf if requested.
- const auto *FuncDesc = getFuncDescForGUID(Probe->getGuid());
- InlineContextStack.emplace_back(FuncDesc->FuncName + ":" +
- Twine(Probe->getIndex()).str());
+ std::string LeafFrame;
+ if (UseMD5) {
+ LeafFrame = Twine(Probe->getGuid()).str();
+ } else {
+ const auto *FuncDesc = getFuncDescForGUID(Probe->getGuid());
+ LeafFrame = FuncDesc->FuncName;
+ }
+ LeafFrame += ":" + Twine(Probe->getIndex()).str();
+
+ InlineContextStack.emplace_back(LeafFrame);
}
const MCPseudoProbeFuncDesc *MCPseudoProbeDecoder::getInlinerDescForProbe(
Index: llvm/include/llvm/MC/MCPseudoProbe.h
===================================================================
--- llvm/include/llvm/MC/MCPseudoProbe.h
+++ llvm/include/llvm/MC/MCPseudoProbe.h
@@ -385,7 +385,7 @@
void
getInlineContextForProbe(const MCDecodedPseudoProbe *Probe,
SmallVectorImpl<std::string> &InlineContextStack,
- bool IncludeLeaf) const;
+ bool UseMD5, bool IncludeLeaf) const;
const AddressProbesMap &getAddress2ProbesMap() const {
return Address2ProbesMap;
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D107779.365256.patch
Type: text/x-patch
Size: 3954 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210809/b207da0c/attachment.bin>
More information about the llvm-commits
mailing list