summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRong Xu <xur@google.com>2017-03-03 21:56:34 +0000
committerRong Xu <xur@google.com>2017-03-03 21:56:34 +0000
commit6241c2a6c11de3aef40704b02ff919f170252953 (patch)
treeb350be9348299ec3ce05d12087c05eb8f474c711
parent6cf254034f05f90c7387913667afd12eceaeb4d9 (diff)
downloadbcm5719-llvm-6241c2a6c11de3aef40704b02ff919f170252953.tar.gz
bcm5719-llvm-6241c2a6c11de3aef40704b02ff919f170252953.zip
[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 llvm-svn: 296916
-rw-r--r--llvm/include/llvm/ProfileData/InstrProf.h7
-rw-r--r--llvm/lib/ProfileData/InstrProfReader.cpp2
-rw-r--r--llvm/test/tools/llvm-profdata/value-prof.proftext9
3 files changed, 17 insertions, 1 deletions
diff --git a/llvm/include/llvm/ProfileData/InstrProf.h b/llvm/include/llvm/ProfileData/InstrProf.h
index d48622ed881..8c9a93eb7c4 100644
--- a/llvm/include/llvm/ProfileData/InstrProf.h
+++ b/llvm/include/llvm/ProfileData/InstrProf.h
@@ -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)
diff --git a/llvm/lib/ProfileData/InstrProfReader.cpp b/llvm/lib/ProfileData/InstrProfReader.cpp
index 0ba6cdb0c70..856f793363f 100644
--- a/llvm/lib/ProfileData/InstrProfReader.cpp
+++ b/llvm/lib/ProfileData/InstrProfReader.cpp
@@ -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())
diff --git a/llvm/test/tools/llvm-profdata/value-prof.proftext b/llvm/test/tools/llvm-profdata/value-prof.proftext
index b5979c84249..e35efbfa003 100644
--- a/llvm/test/tools/llvm-profdata/value-prof.proftext
+++ b/llvm/test/tools/llvm-profdata/value-prof.proftext
@@ -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
OpenPOWER on IntegriCloud