OSDN Git Service

[PGO] Text format profile reader needs to clear the value profile
authorRong Xu <xur@google.com>
Fri, 3 Mar 2017 21:56:34 +0000 (21:56 +0000)
committerRong Xu <xur@google.com>
Fri, 3 Mar 2017 21:56:34 +0000 (21:56 +0000)
Summary:
Reset the ValueData for each function to avoid using the ones in
the previous function.

Reviewers: davidxl

Reviewed By: davidxl

Subscribers: llvm-commits, xur

Differential Revision: https://reviews.llvm.org/D30479

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@296916 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/ProfileData/InstrProf.h
lib/ProfileData/InstrProfReader.cpp
test/tools/llvm-profdata/value-prof.proftext

index d48622e..8c9a93e 100644 (file)
@@ -671,6 +671,13 @@ struct InstrProfRecord {
         SR.sortByCount();
     }
   }
+
+  /// Clear value data entries and edge counters.
+  void Clear() {
+    Counts.clear();
+    clearValueData();
+  }
+
   /// Clear value data entries
   void clearValueData() {
     for (uint32_t Kind = IPVK_First; Kind <= IPVK_Last; ++Kind)
index 0ba6cdb..856f793 100644 (file)
@@ -250,7 +250,7 @@ Error TextInstrProfReader::readNextRecord(InstrProfRecord &Record) {
     return error(instrprof_error::malformed);
 
   // Read each counter and fill our internal storage with the values.
-  Record.Counts.clear();
+  Record.Clear();
   Record.Counts.reserve(NumCounters);
   for (uint64_t I = 0; I < NumCounters; ++I) {
     if (Line.is_at_end())
index b5979c8..e35efbf 100644 (file)
@@ -63,6 +63,15 @@ foo2:20000
 #ICTEXT-NEXT: foo2:20000
 #
 
+bar
+# Func Hash:
+10
+# Num Counters:
+2
+# Counter Values:
+999000
+359800
+
 #ICSUM: Total Number of Indirect Call Sites : 3
 #ICSUM: Total Number of Sites With Values : 2
 #ICSUM: Total Number of Profiled Values : 3