Skip to content

Commit 02af830

Browse files
committed
[𝘀𝗽𝗿] initial version
Created using spr 1.3.4
1 parent 4c3e032 commit 02af830

File tree

6 files changed

+3051
-20
lines changed

6 files changed

+3051
-20
lines changed

bolt/include/bolt/Profile/YAMLProfileWriter.h

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,16 +36,15 @@ class YAMLProfileWriter {
3636
DenseMap<const MCDecodedPseudoProbeInlineTree *, uint32_t>;
3737
struct InlineTreeDesc {
3838
template <typename T> using GUIDMapTy = std::unordered_map<uint64_t, T>;
39-
using GUIDNodeMap = GUIDMapTy<const MCDecodedPseudoProbeInlineTree *>;
4039
using GUIDNumMap = GUIDMapTy<uint32_t>;
41-
GUIDNodeMap TopLevelGUIDToInlineTree;
4240
GUIDNumMap GUIDIdxMap;
4341
GUIDNumMap HashIdxMap;
4442
};
4543

4644
static std::tuple<std::vector<yaml::bolt::InlineTreeNode>, InlineTreeMapTy>
4745
convertBFInlineTree(const MCPseudoProbeDecoder &Decoder,
48-
const InlineTreeDesc &InlineTree, uint64_t GUID);
46+
const InlineTreeDesc &InlineTree,
47+
const BinaryFunction &BF);
4948

5049
static std::tuple<yaml::bolt::ProfilePseudoProbeDesc, InlineTreeDesc>
5150
convertPseudoProbeDesc(const MCPseudoProbeDecoder &PseudoProbeDecoder);

bolt/lib/Profile/DataAggregator.cpp

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2387,11 +2387,9 @@ std::error_code DataAggregator::writeBATYAML(BinaryContext &BC,
23872387
if (PseudoProbeDecoder) {
23882388
DenseMap<const MCDecodedPseudoProbeInlineTree *, uint32_t>
23892389
InlineTreeNodeId;
2390-
if (BF->getGUID()) {
2391-
std::tie(YamlBF.InlineTree, InlineTreeNodeId) =
2392-
YAMLProfileWriter::convertBFInlineTree(*PseudoProbeDecoder,
2393-
InlineTree, BF->getGUID());
2394-
}
2390+
std::tie(YamlBF.InlineTree, InlineTreeNodeId) =
2391+
YAMLProfileWriter::convertBFInlineTree(*PseudoProbeDecoder,
2392+
InlineTree, *BF);
23952393
// Fetch probes belonging to all fragments
23962394
const AddressProbesMap &ProbeMap =
23972395
PseudoProbeDecoder->getAddress2ProbesMap();

bolt/lib/Profile/YAMLProfileWriter.cpp

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -87,10 +87,6 @@ YAMLProfileWriter::convertPseudoProbeDesc(const MCPseudoProbeDecoder &Decoder) {
8787
yaml::bolt::ProfilePseudoProbeDesc Desc;
8888
InlineTreeDesc InlineTree;
8989

90-
for (const MCDecodedPseudoProbeInlineTree &TopLev :
91-
Decoder.getDummyInlineRoot().getChildren())
92-
InlineTree.TopLevelGUIDToInlineTree[TopLev.Guid] = &TopLev;
93-
9490
for (const auto &FuncDesc : Decoder.getGUID2FuncDescMap())
9591
++InlineTree.HashIdxMap[FuncDesc.FuncHash];
9692

@@ -191,14 +187,18 @@ std::tuple<std::vector<yaml::bolt::InlineTreeNode>,
191187
YAMLProfileWriter::InlineTreeMapTy>
192188
YAMLProfileWriter::convertBFInlineTree(const MCPseudoProbeDecoder &Decoder,
193189
const InlineTreeDesc &InlineTree,
194-
uint64_t GUID) {
190+
const BinaryFunction &BF) {
195191
DenseMap<const MCDecodedPseudoProbeInlineTree *, uint32_t> InlineTreeNodeId;
196192
std::vector<yaml::bolt::InlineTreeNode> YamlInlineTree;
197-
auto It = InlineTree.TopLevelGUIDToInlineTree.find(GUID);
198-
if (It == InlineTree.TopLevelGUIDToInlineTree.end())
193+
uint64_t Addr = BF.getAddress();
194+
uint64_t Size = BF.getSize();
195+
auto Probes = Decoder.getAddress2ProbesMap().find(Addr, Addr + Size);
196+
if (Probes.empty())
199197
return {YamlInlineTree, InlineTreeNodeId};
200-
const MCDecodedPseudoProbeInlineTree *Root = It->second;
201-
assert(Root && "Malformed TopLevelGUIDToInlineTree");
198+
const MCDecodedPseudoProbe &Probe = *Probes.begin();
199+
const MCDecodedPseudoProbeInlineTree *Root = Probe.getInlineTreeNode();
200+
while (Root->hasInlineSite())
201+
Root = (const MCDecodedPseudoProbeInlineTree *)Root->Parent;
202202
uint32_t Index = 0;
203203
uint32_t PrevParent = 0;
204204
uint32_t PrevGUIDIdx = 0;
@@ -240,10 +240,9 @@ YAMLProfileWriter::convert(const BinaryFunction &BF, bool UseDFS,
240240
YamlBF.ExecCount = BF.getKnownExecutionCount();
241241
YamlBF.ExternEntryCount = BF.getExternEntryCount();
242242
DenseMap<const MCDecodedPseudoProbeInlineTree *, uint32_t> InlineTreeNodeId;
243-
if (PseudoProbeDecoder && BF.getGUID()) {
243+
if (PseudoProbeDecoder)
244244
std::tie(YamlBF.InlineTree, InlineTreeNodeId) =
245-
convertBFInlineTree(*PseudoProbeDecoder, InlineTree, BF.getGUID());
246-
}
245+
convertBFInlineTree(*PseudoProbeDecoder, InlineTree, BF);
247246

248247
BinaryFunction::BasicBlockOrderType Order;
249248
llvm::copy(UseDFS ? BF.dfs() : BF.getLayout().blocks(),

0 commit comments

Comments
 (0)