[llvm] 089c4bb - [ProfileData] Use ArrayRef instead of const std::vector<T> & (NFC) (#94878)

via llvm-commits llvm-commits at lists.llvm.org
Sun Jun 9 10:26:23 PDT 2024


Author: Kazu Hirata
Date: 2024-06-09T10:26:18-07:00
New Revision: 089c4bb589dd46d1484bd6ba1fe8f5c472339af4

URL: https://github.com/llvm/llvm-project/commit/089c4bb589dd46d1484bd6ba1fe8f5c472339af4
DIFF: https://github.com/llvm/llvm-project/commit/089c4bb589dd46d1484bd6ba1fe8f5c472339af4.diff

LOG: [ProfileData] Use ArrayRef instead of const std::vector<T> & (NFC) (#94878)

Added: 
    

Modified: 
    llvm/lib/ProfileData/InstrProfReader.cpp
    llvm/lib/ProfileData/SampleProfWriter.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/lib/ProfileData/InstrProfReader.cpp b/llvm/lib/ProfileData/InstrProfReader.cpp
index 54a2a61c31875..dad42007c1aec 100644
--- a/llvm/lib/ProfileData/InstrProfReader.cpp
+++ b/llvm/lib/ProfileData/InstrProfReader.cpp
@@ -138,9 +138,8 @@ readBinaryIdsInternal(const MemoryBuffer &DataBuffer,
   return Error::success();
 }
 
-static void
-printBinaryIdsInternal(raw_ostream &OS,
-                       const std::vector<llvm::object::BuildID> &BinaryIds) {
+static void printBinaryIdsInternal(raw_ostream &OS,
+                                   ArrayRef<llvm::object::BuildID> BinaryIds) {
   OS << "Binary IDs: \n";
   for (const auto &BI : BinaryIds) {
     for (auto I : BI)
@@ -1502,7 +1501,7 @@ Expected<InstrProfRecord> IndexedInstrProfReader::getInstrProfRecord(
   // A flag to indicate if the records are from the same type
   // of profile (i.e cs vs nocs).
   bool CSBitMatch = false;
-  auto getFuncSum = [](const std::vector<uint64_t> &Counts) {
+  auto getFuncSum = [](ArrayRef<uint64_t> Counts) {
     uint64_t ValueSum = 0;
     for (uint64_t CountValue : Counts) {
       if (CountValue == (uint64_t)-1)

diff  --git a/llvm/lib/ProfileData/SampleProfWriter.cpp b/llvm/lib/ProfileData/SampleProfWriter.cpp
index 625e523f13cec..1630fefb4fcfb 100644
--- a/llvm/lib/ProfileData/SampleProfWriter.cpp
+++ b/llvm/lib/ProfileData/SampleProfWriter.cpp
@@ -811,8 +811,7 @@ std::error_code SampleProfileWriterBinary::writeSummary() {
   encodeULEB128(Summary->getMaxFunctionCount(), OS);
   encodeULEB128(Summary->getNumCounts(), OS);
   encodeULEB128(Summary->getNumFunctions(), OS);
-  const std::vector<ProfileSummaryEntry> &Entries =
-      Summary->getDetailedSummary();
+  ArrayRef<ProfileSummaryEntry> Entries = Summary->getDetailedSummary();
   encodeULEB128(Entries.size(), OS);
   for (auto Entry : Entries) {
     encodeULEB128(Entry.Cutoff, OS);


        


More information about the llvm-commits mailing list