[PATCH] D18213: Add a module Hash in the bitcode and the combined index.

Teresa Johnson via llvm-commits llvm-commits at lists.llvm.org
Mon Mar 28 07:17:30 PDT 2016


tejohnson added inline comments.

================
Comment at: include/llvm/IR/ModuleSummaryIndex.h:312
@@ -306,6 +311,3 @@
 
-  /// Iterator to allow writer to walk through table during emission.
-  iterator_range<StringMap<uint64_t>::const_iterator>
-  modPathStringEntries() const {
-    return llvm::make_range(ModulePathStringTable.begin(),
-                            ModulePathStringTable.end());
+  /// Table of module, containing module hash and id.
+  const StringMap<std::pair<uint64_t, ModuleHash>> &modulePaths() const {
----------------
s/Table of module/Table of modules/ (here and below)

================
Comment at: include/llvm/IR/ModuleSummaryIndex.h:351
@@ +350,3 @@
+  /// Add a new module path with the given \p Hash, mapped to the given \p
+  /// ModID, and return a StringRef to the copy of \p ModPath owned by the
+  // index.
----------------
Now returns iterator not StringRef.

================
Comment at: lib/Bitcode/Reader/BitcodeReader.cpp:5927
@@ +5926,3 @@
+        return error("Invalid hash length " + Twine(Record.size()).str());
+      if (LastSeenModulePath == TheIndex->modulePaths().end())
+        return error("Invalid hash that does not follow a module path");
----------------
In order for this check to work after the first module id + hash is encountered, LastSeenModulePath needs to be set to the end() after it is used in the for loop below. Otherwise it will silently overwrite the earlier module path's values if not preceded by a new module path.

================
Comment at: lib/Bitcode/Writer/BitcodeWriter.cpp:2829
@@ -2828,3 +2828,3 @@
 
-  SmallVector<unsigned, 64> NameVals;
-  for (const StringMapEntry<uint64_t> &MPSE : I.modPathStringEntries()) {
+  // Module Hash, 160 bits SHA1. Emitted after each MST_CODE_ENTRY.
+  Abbv = new BitCodeAbbrev();
----------------
"Optionally emitted after..."


http://reviews.llvm.org/D18213





More information about the llvm-commits mailing list