diff --git a/llvm/include/llvm/MC/MCPseudoProbe.h b/llvm/include/llvm/MC/MCPseudoProbe.h --- a/llvm/include/llvm/MC/MCPseudoProbe.h +++ b/llvm/include/llvm/MC/MCPseudoProbe.h @@ -36,7 +36,6 @@ // A list of NUM_INLINED_FUNCTIONS entries describing each of the inlined // callees. Each record contains: // INLINE SITE -// GUID of the inlinee (uint64) // ID of the callsite probe (ULEB128) // FUNCTION BODY // A FUNCTION BODY entry describing the inlined function. diff --git a/llvm/tools/llvm-profgen/PseudoProbe.h b/llvm/tools/llvm-profgen/PseudoProbe.h --- a/llvm/tools/llvm-profgen/PseudoProbe.h +++ b/llvm/tools/llvm-profgen/PseudoProbe.h @@ -71,6 +71,7 @@ return Ret.first->second.get(); } + auto &getChildren() { return Children; } void addProbes(PseudoProbe *Probe) { ProbeVector.push_back(Probe); } // Return false if it's a dummy inline site bool hasInlineSite() const { return std::get<0>(ISite) != 0; } @@ -91,7 +92,7 @@ // GUID to PseudoProbeFuncDesc map using GUIDProbeFunctionMap = std::unordered_map; // Address to pseudo probes map. -using AddressProbesMap = std::unordered_map>; +using AddressProbesMap = std::unordered_map>; /* A pseudo probe has the format like below: diff --git a/llvm/tools/llvm-profgen/PseudoProbe.cpp b/llvm/tools/llvm-profgen/PseudoProbe.cpp --- a/llvm/tools/llvm-profgen/PseudoProbe.cpp +++ b/llvm/tools/llvm-profgen/PseudoProbe.cpp @@ -198,7 +198,6 @@ // A list of NUM_INLINED_FUNCTIONS entries describing each of the // inlined callees. Each record contains: // INLINE SITE - // GUID of the inlinee (uint64) // Index of the callsite probe (ULEB128) // FUNCTION BODY // A FUNCTION BODY entry describing the inlined function. @@ -214,8 +213,11 @@ uint32_t Index = 0; // A DFS-based decoding while (Data < End) { - // Read inline site for inlinees - if (Root != Cur) { + if (Root == Cur) { + // Use a sequential id for outline functions. + Index = Root->getChildren().size(); + } else { + // Read inline site for inlinees Index = readUnsignedNumber(); } // Switch/add to a new tree node(inlinee) @@ -243,10 +245,10 @@ Addr = readUnencodedNumber(); } // Populate Address2ProbesMap - std::vector &ProbeVec = Address2ProbesMap[Addr]; - ProbeVec.emplace_back(Addr, Cur->GUID, Index, PseudoProbeType(Kind), Attr, - Cur); - Cur->addProbes(&ProbeVec.back()); + auto &Probes = Address2ProbesMap[Addr]; + Probes.emplace_back(Addr, Cur->GUID, Index, PseudoProbeType(Kind), Attr, + Cur); + Cur->addProbes(&Probes.back()); LastAddr = Addr; } @@ -298,7 +300,7 @@ auto It = Address2ProbesMap.find(Address); if (It == Address2ProbesMap.end()) return nullptr; - const std::vector &Probes = It->second; + const auto &Probes = It->second; const PseudoProbe *CallProbe = nullptr; for (const auto &Probe : Probes) {