[PGO] Value profiling (index format) code cleanup and testing

 1. Added a set of public interfaces in InstrProfRecord
    class to access (read/write) value profile data.
 2. Changed IndexedProfile reader and writer code to 
    use the newly defined interfaces and hide implementation
    details.
 3. Added a couple of unittests for value profiling:
   - Test new interfaces to get and set value profile data
   - Test value profile data merging with various scenarios.

 No functional change is expected. The new interfaces will also
 make it possible to change on-disk format of value prof data
 to be more compact (to be submitted). 

llvm-svn: 251771
diff --git a/llvm/tools/llvm-profdata/llvm-profdata.cpp b/llvm/tools/llvm-profdata/llvm-profdata.cpp
index 382ac90..48fc83c 100644
--- a/llvm/tools/llvm-profdata/llvm-profdata.cpp
+++ b/llvm/tools/llvm-profdata/llvm-profdata.cpp
@@ -168,8 +168,8 @@
          << "    Counters: " << Func.Counts.size() << "\n"
          << "    Function count: " << Func.Counts[0] << "\n";
       if (ShowIndirectCallTargets)
-        OS << "    Indirect Call Site Count: " << Func.IndirectCallSites.size()
-           << "\n";
+        OS << "    Indirect Call Site Count: "
+           << Func.getNumValueSites(IPVK_IndirectCallTarget) << "\n";
     }
 
     if (Show && ShowCounts)
@@ -184,11 +184,15 @@
       OS << "]\n";
 
     if (Show && ShowIndirectCallTargets) {
+      uint32_t NS = Func.getNumValueSites(IPVK_IndirectCallTarget);
       OS << "    Indirect Target Results: \n";
-      for (size_t I = 0, E = Func.IndirectCallSites.size(); I < E; ++I) {
-        for (auto V : Func.IndirectCallSites[I].ValueData) {
+      for (size_t I = 0; I < NS; ++I) {
+        uint32_t NV = Func.getNumValueDataForSite(IPVK_IndirectCallTarget, I);
+        std::unique_ptr<InstrProfValueData[]> VD =
+            Func.getValueForSite(IPVK_IndirectCallTarget, I);
+        for (uint32_t V = 0; V < NV; V++) {
           OS << "\t[ " << I << ", ";
-          OS << (const char *)V.first << ", " << V.second << " ]\n";
+          OS << (const char *)VD[V].Value << ", " << VD[V].Count << " ]\n";
         }
       }
     }