Skip to content

[ProfileData] Use size_t in PatchItem (NFC) #87014

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 29, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions llvm/lib/ProfileData/InstrProfWriter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ using namespace llvm;
struct PatchItem {
uint64_t Pos; // Where to patch.
uint64_t *D; // Pointer to an array of source data.
int N; // Number of elements in \c D array.
size_t N; // Number of elements in \c D array.
};

namespace llvm {
Expand Down Expand Up @@ -69,7 +69,7 @@ class ProfOStream {
const uint64_t LastPos = FDOStream.tell();
for (const auto &K : P) {
FDOStream.seek(K.Pos);
for (int I = 0; I < K.N; I++)
for (size_t I = 0; I < K.N; I++)
write(K.D[I]);
}
// Reset the stream to the last position after patching so that users
Expand All @@ -80,7 +80,7 @@ class ProfOStream {
raw_string_ostream &SOStream = static_cast<raw_string_ostream &>(OS);
std::string &Data = SOStream.str(); // with flush
for (const auto &K : P) {
for (int I = 0; I < K.N; I++) {
for (size_t I = 0; I < K.N; I++) {
uint64_t Bytes =
endian::byte_swap<uint64_t, llvm::endianness::little>(K.D[I]);
Data.replace(K.Pos + I * sizeof(uint64_t), sizeof(uint64_t),
Expand Down Expand Up @@ -707,9 +707,9 @@ Error InstrProfWriter::writeImpl(ProfOStream &OS) {
{VTableNamesOffset, &VTableNamesSectionStart, 1},
// Patch the summary data.
{SummaryOffset, reinterpret_cast<uint64_t *>(TheSummary.get()),
(int)(SummarySize / sizeof(uint64_t))},
SummarySize / sizeof(uint64_t)},
{CSSummaryOffset, reinterpret_cast<uint64_t *>(TheCSSummary.get()),
(int)CSSummarySize}};
CSSummarySize}};

OS.patch(PatchItems);
} else {
Expand All @@ -727,9 +727,9 @@ Error InstrProfWriter::writeImpl(ProfOStream &OS) {
{TemporalProfTracesOffset, &TemporalProfTracesSectionStart, 1},
// Patch the summary data.
{SummaryOffset, reinterpret_cast<uint64_t *>(TheSummary.get()),
(int)(SummarySize / sizeof(uint64_t))},
SummarySize / sizeof(uint64_t)},
{CSSummaryOffset, reinterpret_cast<uint64_t *>(TheCSSummary.get()),
(int)CSSummarySize}};
CSSummarySize}};

OS.patch(PatchItems);
}
Expand Down