[PATCH] D38431: [ProfileData] Fix data racing in merging indexed profiles

Rong Xu via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Oct 2 14:10:52 PDT 2017


xur updated this revision to Diff 117423.
xur added a comment.

Integrated the review comments from vsk.


https://reviews.llvm.org/D38431

Files:
  include/llvm/ProfileData/InstrProfReader.h
  lib/ProfileData/InstrProfReader.cpp


Index: lib/ProfileData/InstrProfReader.cpp
===================================================================
--- lib/ProfileData/InstrProfReader.cpp
+++ lib/ProfileData/InstrProfReader.cpp
@@ -733,8 +733,6 @@
 }
 
 Error IndexedInstrProfReader::readNextRecord(NamedInstrProfRecord &Record) {
-  static unsigned RecordIndex = 0;
-
   ArrayRef<NamedInstrProfRecord> Data;
 
   Error E = Index->getRecords(Data);
Index: include/llvm/ProfileData/InstrProfReader.h
===================================================================
--- include/llvm/ProfileData/InstrProfReader.h
+++ include/llvm/ProfileData/InstrProfReader.h
@@ -397,15 +397,17 @@
   std::unique_ptr<InstrProfReaderIndexBase> Index;
   /// Profile summary data.
   std::unique_ptr<ProfileSummary> Summary;
+  // Index to the current record in the record array.
+  unsigned RecordIndex;
 
   // Read the profile summary. Return a pointer pointing to one byte past the
   // end of the summary data if it exists or the input \c Cur.
   const unsigned char *readSummary(IndexedInstrProf::ProfVersion Version,
                                    const unsigned char *Cur);
 
 public:
   IndexedInstrProfReader(std::unique_ptr<MemoryBuffer> DataBuffer)
-      : DataBuffer(std::move(DataBuffer)) {}
+      : DataBuffer(std::move(DataBuffer)), RecordIndex(0) {}
   IndexedInstrProfReader(const IndexedInstrProfReader &) = delete;
   IndexedInstrProfReader &operator=(const IndexedInstrProfReader &) = delete;
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D38431.117423.patch
Type: text/x-patch
Size: 1470 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20171002/ef9abdec/attachment.bin>


More information about the llvm-commits mailing list