[llvm] [ProfileData] Take ArrayRef<InstrProfValueData> in addValueData (NFC) (PR #97363)

Mingming Liu via llvm-commits llvm-commits at lists.llvm.org
Wed Jul 10 15:00:51 PDT 2024


================
@@ -998,18 +998,18 @@ uint64_t InstrProfRecord::remapValue(uint64_t Value, uint32_t ValueKind,
 }
 
 void InstrProfRecord::addValueData(uint32_t ValueKind, uint32_t Site,
-                                   InstrProfValueData *VData, uint32_t N,
+                                   ArrayRef<InstrProfValueData> VData,
                                    InstrProfSymtab *ValueMap) {
-  for (uint32_t I = 0; I < N; I++) {
-    VData[I].Value = remapValue(VData[I].Value, ValueKind, ValueMap);
-  }
   std::vector<InstrProfValueSiteRecord> &ValueSites =
       getOrCreateValueSitesForKind(ValueKind);
   assert(ValueSites.size() == Site);
-  if (N == 0)
+  if (VData.empty())
     ValueSites.emplace_back();
-  else
-    ValueSites.emplace_back(VData, VData + N);
+  else {
+    ValueSites.emplace_back(VData.begin(), VData.end());
+    for (auto &V : ValueSites.back().ValueData)
----------------
minglotus-6 wrote:

Before or after this PR, this part has dense information for readers to figure out what's going on.

As I understand it, `ValueSites.emplace_back` constructs one vector element using ArrayRef, and the for-loop iterates a data member of this vector element.

Would you mind adding some comments ?


https://github.com/llvm/llvm-project/pull/97363


More information about the llvm-commits mailing list