[llvm] r296916 - [PGO] Text format profile reader needs to clear the value profile

Rong Xu via llvm-commits llvm-commits at lists.llvm.org
Fri Mar 3 13:56:34 PST 2017


Author: xur
Date: Fri Mar  3 15:56:34 2017
New Revision: 296916

URL: http://llvm.org/viewvc/llvm-project?rev=296916&view=rev
Log:
[PGO] Text format profile reader needs to clear the value profile

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

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

Modified: llvm/trunk/include/llvm/ProfileData/InstrProf.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/ProfileData/InstrProf.h?rev=296916&r1=296915&r2=296916&view=diff
==============================================================================
--- llvm/trunk/include/llvm/ProfileData/InstrProf.h (original)
+++ llvm/trunk/include/llvm/ProfileData/InstrProf.h Fri Mar  3 15:56:34 2017
@@ -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)

Modified: llvm/trunk/lib/ProfileData/InstrProfReader.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/ProfileData/InstrProfReader.cpp?rev=296916&r1=296915&r2=296916&view=diff
==============================================================================
--- llvm/trunk/lib/ProfileData/InstrProfReader.cpp (original)
+++ llvm/trunk/lib/ProfileData/InstrProfReader.cpp Fri Mar  3 15:56:34 2017
@@ -250,7 +250,7 @@ Error TextInstrProfReader::readNextRecor
     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())

Modified: llvm/trunk/test/tools/llvm-profdata/value-prof.proftext
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/tools/llvm-profdata/value-prof.proftext?rev=296916&r1=296915&r2=296916&view=diff
==============================================================================
--- llvm/trunk/test/tools/llvm-profdata/value-prof.proftext (original)
+++ llvm/trunk/test/tools/llvm-profdata/value-prof.proftext Fri Mar  3 15:56:34 2017
@@ -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




More information about the llvm-commits mailing list