-
Notifications
You must be signed in to change notification settings - Fork 13.5k
[ProfileData] Add const to a few places (NFC) #94803
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
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@llvm/pr-subscribers-pgo Author: Kazu Hirata (kazutakahirata) ChangesFull diff: https://github.com/llvm/llvm-project/pull/94803.diff 5 Files Affected:
diff --git a/llvm/include/llvm/ProfileData/MemProf.h b/llvm/include/llvm/ProfileData/MemProf.h
index 0e6245acb77e8..0e4bb9cc3c6cb 100644
--- a/llvm/include/llvm/ProfileData/MemProf.h
+++ b/llvm/include/llvm/ProfileData/MemProf.h
@@ -440,7 +440,7 @@ struct IndexedMemProfRecord {
void serialize(const MemProfSchema &Schema, raw_ostream &OS,
IndexedVersion Version,
llvm::DenseMap<memprof::CallStackId, LinearCallStackId>
- *MemProfCallStackIndexes = nullptr);
+ *MemProfCallStackIndexes = nullptr) const;
// Deserializes memprof records from the Buffer.
static IndexedMemProfRecord deserialize(const MemProfSchema &Schema,
diff --git a/llvm/lib/ProfileData/InstrProf.cpp b/llvm/lib/ProfileData/InstrProf.cpp
index 6a8f25d4d3bfb..d707c07e6dc50 100644
--- a/llvm/lib/ProfileData/InstrProf.cpp
+++ b/llvm/lib/ProfileData/InstrProf.cpp
@@ -282,7 +282,7 @@ std::string getPGOFuncName(StringRef Name, GlobalValue::LinkageTypes Linkage,
static StringRef stripDirPrefix(StringRef PathNameStr, uint32_t NumPrefix) {
uint32_t Count = NumPrefix;
uint32_t Pos = 0, LastPos = 0;
- for (auto & CI : PathNameStr) {
+ for (const auto &CI : PathNameStr) {
++Pos;
if (llvm::sys::path::is_separator(CI)) {
LastPos = Pos;
@@ -1299,7 +1299,7 @@ void annotateValueSite(Module &M, Instruction &Inst,
// Value Profile Data
uint32_t MDCount = MaxMDCount;
- for (auto &VD : VDs) {
+ for (const auto &VD : VDs) {
Vals.push_back(MDHelper.createConstant(
ConstantInt::get(Type::getInt64Ty(Ctx), VD.Value)));
Vals.push_back(MDHelper.createConstant(
diff --git a/llvm/lib/ProfileData/InstrProfWriter.cpp b/llvm/lib/ProfileData/InstrProfWriter.cpp
index a73f72a534f16..7d7c980a9e11f 100644
--- a/llvm/lib/ProfileData/InstrProfWriter.cpp
+++ b/llvm/lib/ProfileData/InstrProfWriter.cpp
@@ -55,7 +55,7 @@ class ProfOStream {
ProfOStream(raw_string_ostream &STR)
: IsFDOStream(false), OS(STR), LE(STR, llvm::endianness::little) {}
- uint64_t tell() { return OS.tell(); }
+ [[nodiscard]] uint64_t tell() const { return OS.tell(); }
void write(uint64_t V) { LE.write<uint64_t>(V); }
void write32(uint32_t V) { LE.write<uint32_t>(V); }
void writeByte(uint8_t V) { LE.write<uint8_t>(V); }
@@ -894,7 +894,7 @@ Error InstrProfWriter::writeImpl(ProfOStream &OS) {
BinaryIds.erase(std::unique(BinaryIds.begin(), BinaryIds.end()),
BinaryIds.end());
- for (auto BI : BinaryIds) {
+ for (const auto &BI : BinaryIds) {
// Increment by binary id length data type size.
BinaryIdsSectionSize += sizeof(uint64_t);
// Increment by binary id data length, aligned to 8 bytes.
@@ -903,7 +903,7 @@ Error InstrProfWriter::writeImpl(ProfOStream &OS) {
// Write binary ids section size.
OS.write(BinaryIdsSectionSize);
- for (auto BI : BinaryIds) {
+ for (const auto &BI : BinaryIds) {
uint64_t BILen = BI.size();
// Write binary id length.
OS.write(BILen);
diff --git a/llvm/lib/ProfileData/MemProf.cpp b/llvm/lib/ProfileData/MemProf.cpp
index aecac24169526..620e2e2d71a0f 100644
--- a/llvm/lib/ProfileData/MemProf.cpp
+++ b/llvm/lib/ProfileData/MemProf.cpp
@@ -194,7 +194,8 @@ static void serializeV3(
void IndexedMemProfRecord::serialize(
const MemProfSchema &Schema, raw_ostream &OS, IndexedVersion Version,
- llvm::DenseMap<CallStackId, LinearCallStackId> *MemProfCallStackIndexes) {
+ llvm::DenseMap<CallStackId, LinearCallStackId> *MemProfCallStackIndexes)
+ const {
switch (Version) {
case Version0:
case Version1:
diff --git a/llvm/lib/ProfileData/MemProfReader.cpp b/llvm/lib/ProfileData/MemProfReader.cpp
index 693897f874a29..de58cb6331860 100644
--- a/llvm/lib/ProfileData/MemProfReader.cpp
+++ b/llvm/lib/ProfileData/MemProfReader.cpp
@@ -67,7 +67,7 @@ Error checkBuffer(const MemoryBuffer &Buffer) {
uint64_t TotalSize = 0;
const char *Next = Buffer.getBufferStart();
while (Next < Buffer.getBufferEnd()) {
- auto *H = reinterpret_cast<const Header *>(Next);
+ const auto *H = reinterpret_cast<const Header *>(Next);
if (H->Version != MEMPROF_RAW_VERSION) {
return make_error<InstrProfError>(instrprof_error::unsupported_version);
}
@@ -597,7 +597,7 @@ RawMemProfReader::peekBuildIds(MemoryBuffer *DataBuffer) {
llvm::SmallSet<std::string, 10>>
BuildIds;
while (Next < DataBuffer->getBufferEnd()) {
- auto *Header = reinterpret_cast<const memprof::Header *>(Next);
+ const auto *Header = reinterpret_cast<const memprof::Header *>(Next);
const llvm::SmallVector<SegmentEntry> Entries =
readSegmentEntries(Next + Header->SegmentOffset);
@@ -615,7 +615,7 @@ Error RawMemProfReader::readRawProfile(
const char *Next = DataBuffer->getBufferStart();
while (Next < DataBuffer->getBufferEnd()) {
- auto *Header = reinterpret_cast<const memprof::Header *>(Next);
+ const auto *Header = reinterpret_cast<const memprof::Header *>(Next);
// Read in the segment information, check whether its the same across all
// profiles in this binary file.
|
mingmingl-llvm
approved these changes
Jun 7, 2024
nekoshirro
pushed a commit
to nekoshirro/Alchemist-LLVM
that referenced
this pull request
Jun 9, 2024
Signed-off-by: Hafidz Muzakky <ais.muzakky@gmail.com>
Closed
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
No description provided.