https://github.com/aaupov updated https://github.com/llvm/llvm-project/pull/102789
>From ddcbb593f72ca47acaa82f9c14a7fd2c4e30903b Mon Sep 17 00:00:00 2001 From: Amir Ayupov <aau...@fb.com> Date: Tue, 13 Aug 2024 03:51:31 -0700 Subject: [PATCH] Pass CurChildIndex by value Created using spr 1.3.4 --- llvm/include/llvm/MC/MCPseudoProbe.h | 6 ++++-- llvm/lib/MC/MCPseudoProbe.cpp | 26 +++++++++++--------------- 2 files changed, 15 insertions(+), 17 deletions(-) diff --git a/llvm/include/llvm/MC/MCPseudoProbe.h b/llvm/include/llvm/MC/MCPseudoProbe.h index a46188e565c7e8..32d7a4e9129eca 100644 --- a/llvm/include/llvm/MC/MCPseudoProbe.h +++ b/llvm/include/llvm/MC/MCPseudoProbe.h @@ -474,11 +474,13 @@ class MCPseudoProbeDecoder { } private: + // Recursively parse an inlining tree encoded in pseudo_probe section. Returns + // whether the the top-level node should be skipped. template <bool IsTopLevelFunc> - void buildAddress2ProbeMap(MCDecodedPseudoProbeInlineTree *Cur, + bool buildAddress2ProbeMap(MCDecodedPseudoProbeInlineTree *Cur, uint64_t &LastAddr, const Uint64Set &GuildFilter, const Uint64Map &FuncStartAddrs, - uint32_t &CurChild); + const uint32_t CurChildIndex); }; } // end namespace llvm diff --git a/llvm/lib/MC/MCPseudoProbe.cpp b/llvm/lib/MC/MCPseudoProbe.cpp index c4c2dfcec40564..e6f6e797b4ee71 100644 --- a/llvm/lib/MC/MCPseudoProbe.cpp +++ b/llvm/lib/MC/MCPseudoProbe.cpp @@ -420,17 +420,17 @@ bool MCPseudoProbeDecoder::buildGUID2FuncDescMap(const uint8_t *Start, } template <bool IsTopLevelFunc> -void MCPseudoProbeDecoder::buildAddress2ProbeMap( +bool MCPseudoProbeDecoder::buildAddress2ProbeMap( MCDecodedPseudoProbeInlineTree *Cur, uint64_t &LastAddr, const Uint64Set &GuidFilter, const Uint64Map &FuncStartAddrs, - uint32_t &CurChild) { + const uint32_t CurChildIndex) { // The pseudo_probe section encodes an inline forest and each tree has a // format defined in MCPseudoProbe.h uint32_t Index = 0; if (IsTopLevelFunc) { // Use a sequential id for top level inliner. - Index = CurChild; + Index = CurChildIndex; } else { // Read inline site for inlinees Index = cantFail(errorOrToExpected(readUnsignedNumber<uint32_t>())); @@ -446,19 +446,14 @@ void MCPseudoProbeDecoder::buildAddress2ProbeMap( // If the incoming node is null, all its children nodes should be disgarded. if (Cur) { // Switch/add to a new tree node(inlinee) - Cur->Children[CurChild] = MCDecodedPseudoProbeInlineTree(Guid, Index, Cur); - Cur = &Cur->Children[CurChild]; + Cur->Children[CurChildIndex] = + MCDecodedPseudoProbeInlineTree(Guid, Index, Cur); + Cur = &Cur->Children[CurChildIndex]; if (IsTopLevelFunc && !EncodingIsAddrBased) { if (auto V = FuncStartAddrs.lookup(Guid)) LastAddr = V; } } - // Advance CurChild for non-skipped top-level functions and unconditionally - // for inlined functions. - if (IsTopLevelFunc) - CurChild += !!Cur; - else - ++CurChild; // Read number of probes in the current node. uint32_t NodeCount = @@ -519,9 +514,10 @@ void MCPseudoProbeDecoder::buildAddress2ProbeMap( InlineTreeVec.resize(InlineTreeVec.size() + ChildrenToProcess); Cur->Children = MutableArrayRef(InlineTreeVec).take_back(ChildrenToProcess); } - for (uint32_t I = 0; I < ChildrenToProcess;) { + for (uint32_t I = 0; I < ChildrenToProcess; I++) { buildAddress2ProbeMap<false>(Cur, LastAddr, GuidFilter, FuncStartAddrs, I); } + return Cur; } template <bool IsTopLevelFunc> @@ -630,10 +626,10 @@ bool MCPseudoProbeDecoder::buildAddress2ProbeMap( Data = Start; End = Data + Size; uint64_t LastAddr = 0; - uint32_t Child = 0; + uint32_t CurChildIndex = 0; while (Data < End) - buildAddress2ProbeMap<true>(&DummyInlineRoot, LastAddr, GuidFilter, - FuncStartAddrs, Child); + CurChildIndex += buildAddress2ProbeMap<true>( + &DummyInlineRoot, LastAddr, GuidFilter, FuncStartAddrs, CurChildIndex); assert(Data == End && "Have unprocessed data in pseudo_probe section"); return true; } _______________________________________________ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits