Skip to content

Conversation

kazutakahirata
Copy link
Contributor

While I am at it, this patch adds const to a couple of places.

While I am at it, this patch adds const to a couple of places.
@llvmbot llvmbot added the PGO Profile Guided Optimizations label Jun 8, 2024
@kazutakahirata kazutakahirata requested a review from MaskRay June 8, 2024 14:20
@llvmbot
Copy link
Member

llvmbot commented Jun 8, 2024

@llvm/pr-subscribers-pgo

Author: Kazu Hirata (kazutakahirata)

Changes

While I am at it, this patch adds const to a couple of places.


Full diff: https://github.com/llvm/llvm-project/pull/94856.diff

1 Files Affected:

  • (modified) llvm/lib/ProfileData/InstrProfReader.cpp (+4-4)
diff --git a/llvm/lib/ProfileData/InstrProfReader.cpp b/llvm/lib/ProfileData/InstrProfReader.cpp
index 7758363d9c952..27855bf92b871 100644
--- a/llvm/lib/ProfileData/InstrProfReader.cpp
+++ b/llvm/lib/ProfileData/InstrProfReader.cpp
@@ -145,11 +145,11 @@ readBinaryIdsInternal(const MemoryBuffer &DataBuffer,
 
 static void
 printBinaryIdsInternal(raw_ostream &OS,
-                       std::vector<llvm::object::BuildID> &BinaryIds) {
+                       const std::vector<llvm::object::BuildID> &BinaryIds) {
   OS << "Binary IDs: \n";
-  for (auto BI : BinaryIds) {
-    for (uint64_t I = 0; I < BI.size(); I++)
-      OS << format("%02x", BI[I]);
+  for (const auto &BI : BinaryIds) {
+    for (auto I : BI)
+      OS << format("%02x", I);
     OS << "\n";
   }
 }

@kazutakahirata kazutakahirata merged commit 38124fe into llvm:main Jun 8, 2024
@kazutakahirata kazutakahirata deleted the profiledata_range_for branch June 8, 2024 15:37
@@ -145,11 +145,11 @@ readBinaryIdsInternal(const MemoryBuffer &DataBuffer,

static void
printBinaryIdsInternal(raw_ostream &OS,
std::vector<llvm::object::BuildID> &BinaryIds) {
const std::vector<llvm::object::BuildID> &BinaryIds) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's not too important, but an ArrayRef is preferred over a constant reference to a vector.

nekoshirro pushed a commit to nekoshirro/Alchemist-LLVM that referenced this pull request Jun 9, 2024
While I am at it, this patch adds const to a couple of places.

Signed-off-by: Hafidz Muzakky <[email protected]>
@HerrCai0907 HerrCai0907 mentioned this pull request Jun 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
PGO Profile Guided Optimizations
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants