[llvm] r290407 - MetadataLoader: Make sure every member of MetadataLoader are initialized (NFC)

Mehdi Amini via llvm-commits llvm-commits at lists.llvm.org
Thu Dec 22 18:20:07 PST 2016


Author: mehdi_amini
Date: Thu Dec 22 20:20:07 2016
New Revision: 290407

URL: http://llvm.org/viewvc/llvm-project?rev=290407&view=rev
Log:
MetadataLoader: Make sure every member of MetadataLoader are initialized (NFC)

Modified:
    llvm/trunk/lib/Bitcode/Reader/MetadataLoader.cpp

Modified: llvm/trunk/lib/Bitcode/Reader/MetadataLoader.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Bitcode/Reader/MetadataLoader.cpp?rev=290407&r1=290406&r2=290407&view=diff
==============================================================================
--- llvm/trunk/lib/Bitcode/Reader/MetadataLoader.cpp (original)
+++ llvm/trunk/lib/Bitcode/Reader/MetadataLoader.cpp Thu Dec 22 20:20:07 2016
@@ -97,10 +97,18 @@ namespace {
 static int64_t unrotateSign(uint64_t U) { return U & 1 ? ~(U >> 1) : U >> 1; }
 
 class BitcodeReaderMetadataList {
-  unsigned NumFwdRefs;
-  bool AnyFwdRefs;
-  unsigned MinFwdRef;
-  unsigned MaxFwdRef;
+  /// Keep track of the current number of ForwardReference in the list.
+  unsigned NumFwdRefs = 0;
+  /// Maintain the range [min-max] that needs to be inspected to resolve cycles.
+  /// This is the range of Metadata that have involved forward reference during
+  /// loading and that needs to be inspected to resolve cycles. It is purely an
+  /// optimization to avoid spending time resolving cycles outside of this
+  /// range, i.e. where there hasn't been any forward reference.
+  unsigned MinFwdRef = 0;
+  unsigned MaxFwdRef = 0;
+  /// Set to true if there was any FwdRef encountered. This is used to track if
+  /// we need to resolve cycles after loading metadatas.
+  bool AnyFwdRefs = false;
 
   /// Array of metadata references.
   ///
@@ -119,8 +127,7 @@ class BitcodeReaderMetadataList {
   LLVMContext &Context;
 
 public:
-  BitcodeReaderMetadataList(LLVMContext &C)
-      : NumFwdRefs(0), AnyFwdRefs(false), Context(C) {}
+  BitcodeReaderMetadataList(LLVMContext &C) : Context(C) {}
 
   // vector compatibility methods
   unsigned size() const { return MetadataPtrs.size(); }




More information about the llvm-commits mailing list