Lines Matching +full:input +full:- +full:depth
1 //===- SampleProfReader.cpp - Read LLVM sample profile data ---------------===//
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 //===----------------------------------------------------------------------===//
18 // All three encodings can be used interchangeably as an input sample profile.
20 //===----------------------------------------------------------------------===//
51 #define DEBUG_TYPE "samplepgo-reader"
55 // For ext-binary format profiles, the flag is set in the summary.
57 "profile-isfs", cl::Hidden, cl::init(false),
150 /// Parse \p Input as function head.
152 /// Parse one line of \p Input, and update function name in \p FName,
157 static bool ParseHead(const StringRef &Input, StringRef &FName, in ParseHead() argument
159 if (Input[0] == ' ') in ParseHead()
161 size_t n2 = Input.rfind(':'); in ParseHead()
162 size_t n1 = Input.rfind(':', n2 - 1); in ParseHead()
163 FName = Input.substr(0, n1); in ParseHead()
164 if (Input.substr(n1 + 1, n2 - n1 - 1).getAsInteger(10, NumSamples)) in ParseHead()
166 if (Input.substr(n2 + 1).getAsInteger(10, NumHeadSamples)) in ParseHead()
174 /// Parse \p Input that contains metadata.
176 /// - CFG Checksum information:
178 /// - CFG Checksum information:
181 static bool parseMetadata(const StringRef &Input, uint64_t &FunctionHash, in parseMetadata() argument
183 if (Input.starts_with("!CFGChecksum:")) { in parseMetadata()
184 StringRef CFGInfo = Input.substr(strlen("!CFGChecksum:")).trim(); in parseMetadata()
188 if (Input.starts_with("!Attributes:")) { in parseMetadata()
189 StringRef Attrib = Input.substr(strlen("!Attributes:")).trim(); in parseMetadata()
202 /// Parse \p Input as line sample.
204 /// \param Input input line.
206 /// \param Depth the depth of the inline stack.
214 static bool ParseLine(const StringRef &Input, LineType &LineTy, uint32_t &Depth, in ParseLine() argument
219 for (Depth = 0; Input[Depth] == ' '; Depth++) in ParseLine()
221 if (Depth == 0) in ParseLine()
224 if (Input[Depth] == '!') { in ParseLine()
226 return parseMetadata(Input.substr(Depth), FunctionHash, Attributes); in ParseLine()
229 size_t n1 = Input.find(':'); in ParseLine()
230 StringRef Loc = Input.substr(Depth, n1 - Depth); in ParseLine()
243 StringRef Rest = Input.substr(n1 + 2); in ParseLine()
283 StringRef WordAfterColon = Rest.substr(n3 + 1, n4 - n3 - 1); in ParseLine()
325 // top-level or nested function profile. in readImpl()
331 size_t pos = LineIt->find_first_not_of(' '); in readImpl()
332 if (pos == LineIt->npos || (*LineIt)[pos] == '#') in readImpl()
367 uint32_t Depth, LineOffset, Discriminator; in readImpl() local
371 if (!ParseLine(*LineIt, LineTy, Depth, NumSamples, LineOffset, in readImpl()
379 if (LineTy != LineType::Metadata && Depth == DepthMetadata) { in readImpl()
382 "Found non-metadata after metadata: " + *LineIt); in readImpl()
389 while (InlineStack.size() > Depth) { in readImpl()
394 FunctionSamples &FSamples = InlineStack.back()->functionSamplesAt( in readImpl()
403 while (InlineStack.size() > Depth) { in readImpl()
422 if (Depth == 1) in readImpl()
428 DepthMetadata = Depth; in readImpl()
436 "Cannot have both context-sensitive and regular profile"); in readImpl()
440 "Cannot have both probe-based profiles and regular profiles"); in readImpl()
455 // Check that the first non-comment line is a valid function header. in hasFormat()
669 FunctionSamples &FProfile = Res.first->second; in readFuncProfile()
701 Summary->setPartialProfile(true); in readOneSection()
768 // sequences of contexts in pre-order layout in useFuncOffsetList()
863 Remapper->insert(Name); in readFuncProfiles()
895 (Remapper && Remapper->exist(FNameString))))) { in readFuncProfiles()
896 if (!CommonContext || !CommonContext->isPrefixOf(FContext)) in readFuncProfiles()
901 (CommonContext && CommonContext->isPrefixOf(FContext))) { in readFuncProfiles()
916 const uint8_t *FuncProfileAddr = Start + iter->second; in readFuncProfiles()
926 if (!FuncsToUse.count(FuncNameStr) && !Remapper->exist(FuncNameStr)) in readFuncProfiles()
938 const uint8_t *FuncProfileAddr = Start + iter->second; in readFuncProfiles()
946 "Cannot have both context-sensitive and regular profile"); in readFuncProfiles()
956 if (std::error_code EC = ProfSymList->read(Data, End - Data)) in readProfileSymbolList()
992 reinterpret_cast<const uint8_t *>(Buffer->getBufferStart()); in readImpl()
1029 End = BufStart + Buffer->getBufferSize(); in readImpl()
1147 // a callsite identifier that only makes sense for non-leaf frames.
1200 FProfile->setFunctionHash(*Checksum); in readFuncMetadata()
1208 FProfile->getContext().setAllAttributes(*Attributes); in readFuncMetadata()
1234 &FProfile->functionSamplesAt(LineLocation( in readFuncMetadata()
1258 FProfile = &It->second; in readFuncMetadata()
1310 reinterpret_cast<const uint8_t *>(Buffer->getBufferStart()); in readHeader()
1312 End = BufStart + Buffer->getBufferSize(); in readHeader()
1372 Flags.append("fs-discriminator,"); in getSecFlagsStr()
1398 OS << getSecName(Entry.Type) << " - Offset: " << Entry.Offset in dumpSectionInfo()
1433 Data = reinterpret_cast<const uint8_t *>(Buffer->getBufferStart()); in readHeader()
1434 End = Data + Buffer->getBufferSize(); in readHeader()
1552 // Read the version number. Note - the GCC reader does not validate this in readHeader()
1647 FProfile->addHeadSamples(HeadCount); in readOneFunctionProfile()
1648 if (FProfile->getTotalSamples() > 0) in readOneFunctionProfile()
1657 FProfile = &CallerProfile->functionSamplesAt( in readOneFunctionProfile()
1660 FProfile->setFunction(FunctionId(Name)); in readOneFunctionProfile()
1688 CallerProfile->addTotalSamples(Count); in readOneFunctionProfile()
1691 FProfile->addBodySamples(LineOffset, Discriminator, Count); in readOneFunctionProfile()
1715 FProfile->addCalledTargetSamples(LineOffset, Discriminator, in readOneFunctionProfile()
1767 Reader.getBuffer()->getBufferIdentifier(), in applyRemapping()
1774 // CSSPGO-TODO: Remapper is not yet supported. in applyRemapping()
1782 if (auto Key = Remappings->insert(NameStr)) in applyRemapping()
1792 if (auto Key = Remappings->lookup(Fname)) { in lookUpNameInProfile()
1805 auto BufferOrErr = Filename.str() == "-" ? MemoryBuffer::getSTDIN() in setupMemoryBuffer()
1814 /// Create a sample profile reader based on the format of the input file.
1835 /// Create a sample profile remapper from the given input, to remap the
1856 /// Create a sample profile remapper from the given input, to remap the
1871 if (Error E = Remappings->read(*B)) { in create()
1874 C.diagnose(DiagnosticInfoSampleProfile(B->getBufferIdentifier(), in create()
1885 /// Create a sample profile reader based on the format of the input data.
1920 Reader->Remapper = std::move(ReaderOrErr.get()); in create()
1923 if (std::error_code EC = Reader->readHeader()) { in create()
1927 Reader->setDiscriminatorMaskedBitFrom(P); in create()