================ @@ -58,8 +60,164 @@ const BinaryFunction *YAMLProfileWriter::setCSIDestination( return nullptr; } +std::vector<YAMLProfileWriter::InlineTreeNode> +YAMLProfileWriter::getInlineTree(const MCPseudoProbeDecoder &Decoder, + const MCDecodedPseudoProbeInlineTree *Root) { + auto getHash = [&](const MCDecodedPseudoProbeInlineTree &Node) { + return Decoder.getFuncDescForGUID(Node.Guid)->FuncHash; + }; + assert(Root); + std::vector<InlineTreeNode> InlineTree; + InlineTreeNode Node{Root, Root->Guid, getHash(*Root), 0, 0}; + InlineTree.emplace_back(Node); + uint32_t ParentId = 0; + while (ParentId != InlineTree.size()) { + const MCDecodedPseudoProbeInlineTree *Cur = InlineTree[ParentId].InlineTree; + for (const MCDecodedPseudoProbeInlineTree &Child : Cur->getChildren()) { + InlineTreeNode Node{&Child, Child.Guid, getHash(Child), ParentId, + std::get<1>(Child.getInlineSite())}; + InlineTree.emplace_back(Node); + } + ++ParentId; + } + + return InlineTree; +} + +std::tuple<yaml::bolt::PseudoProbeDesc, YAMLProfileWriter::InlineTreeDesc> +YAMLProfileWriter::convertPseudoProbeDesc(const MCPseudoProbeDecoder &Decoder) { + yaml::bolt::PseudoProbeDesc Desc; + InlineTreeDesc InlineTree; + + for (const MCDecodedPseudoProbeInlineTree &TopLev : + Decoder.getDummyInlineRoot().getChildren()) + InlineTree.TopLevelGUIDToInlineTree[TopLev.Guid] = &TopLev; + + for (const auto &FuncDesc : Decoder.getGUID2FuncDescMap()) + ++InlineTree.HashIdxMap[FuncDesc.FuncHash]; ---------------- wlei-llvm wrote:
reserve the size here? looks `reserve`'s used for all other map but not `HashIdxMap` https://github.com/llvm/llvm-project/pull/107137 _______________________________________________ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits