resolve comments

This commit is contained in:
mingmingl 2025-08-21 10:54:11 -07:00
parent 7fba3160b9
commit 41a024725b
3 changed files with 22 additions and 16 deletions

View File

@ -589,6 +589,10 @@ protected:
/// Whether the function profiles use FS discriminators.
bool ProfileIsFS = false;
/// If true, the profile has vtable profiles and reader should decode them
/// to parse profiles correctly.
bool ReadVTableProf = false;
/// \brief The format of sample.
SampleProfileFormat Format = SPF_None;
@ -735,10 +739,6 @@ protected:
/// to the start of MD5SampleContextTable.
const uint64_t *MD5SampleContextStart = nullptr;
/// If true, the profile has vtable profiles and reader should decode them
/// to parse profiles correctly.
bool ReadVTableProf = false;
private:
std::error_code readSummaryEntry(std::vector<ProfileSummaryEntry> &Entries);
virtual std::error_code verifySPMagic(uint64_t Magic) = 0;

View File

@ -144,7 +144,6 @@ sampleprof_error SampleRecord::merge(const SampleRecord &Other,
for (const auto &I : Other.getCallTargets()) {
mergeSampleProfErrors(Result, addCalledTarget(I.first, I.second, Weight));
}
return Result;
}

View File

@ -205,20 +205,25 @@ enum class LineType {
static bool parseTypeCountMap(StringRef Input,
DenseMap<StringRef, uint64_t> &TypeCountMap) {
for (size_t Index = Input.find_first_not_of(' '); Index != StringRef::npos;) {
size_t n1 = Input.find(':', Index);
if (n1 == StringRef::npos)
size_t ColonIndex = Input.find(':', Index);
if (ColonIndex == StringRef::npos)
return false; // No colon found, invalid format.
StringRef TypeName = Input.substr(Index, n1 - Index);
// n2 is the start index of count.
size_t n2 = n1 + 1;
// n3 is the start index after the 'target:count' pair.
size_t n3 = Input.find_first_of(' ', n2);
StringRef TypeName = Input.substr(Index, ColonIndex - Index);
// CountIndex is the start index of count.
size_t CountStartIndex = ColonIndex + 1;
// NextIndex is the start index after the 'target:count' pair.
size_t NextIndex = Input.find_first_of(' ', CountStartIndex);
uint64_t Count;
if (Input.substr(n2, n3 - n2).getAsInteger(10, Count))
if (Input.substr(CountStartIndex, NextIndex - CountStartIndex)
.getAsInteger(10, Count))
return false; // Invalid count.
TypeCountMap[TypeName] = Count;
Index = (n3 == StringRef::npos) ? StringRef::npos
: Input.find_first_not_of(' ', n3);
// Error on duplicated type names in one line of input.
auto [Iter, Inserted] = TypeCountMap.insert({TypeName, Count});
if (!Inserted)
return false;
Index = (NextIndex == StringRef::npos)
? StringRef::npos
: Input.find_first_not_of(' ', NextIndex);
}
return true;
}
@ -409,6 +414,8 @@ std::error_code SampleProfileReaderText::readImpl() {
uint64_t FunctionHash = 0;
uint32_t Attributes = 0;
bool IsFlat = false;
// TODO: Update ParseLine to return an error code instead of a bool and
// report it.
if (!ParseLine(*LineIt, LineTy, Depth, NumSamples, LineOffset,
Discriminator, FName, TargetCountMap, TypeCountMap,
FunctionHash, Attributes, IsFlat)) {