[llvm] r290408 - MetadataLoader: Add an assertion for the implicit invariant of PlaceHolder while loading Metadata (NFC)

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


Author: mehdi_amini
Date: Thu Dec 22 20:20:09 2016
New Revision: 290408

URL: http://llvm.org/viewvc/llvm-project?rev=290408&view=rev
Log:
MetadataLoader: Add an assertion for the implicit invariant of PlaceHolder while loading Metadata (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=290408&r1=290407&r2=290408&view=diff
==============================================================================
--- llvm/trunk/lib/Bitcode/Reader/MetadataLoader.cpp (original)
+++ llvm/trunk/lib/Bitcode/Reader/MetadataLoader.cpp Thu Dec 22 20:20:09 2016
@@ -372,8 +372,14 @@ DistinctMDOperandPlaceholder &Placeholde
 
 void PlaceholderQueue::flush(BitcodeReaderMetadataList &MetadataList) {
   while (!PHs.empty()) {
-    PHs.front().replaceUseWith(
-        MetadataList.getMetadataFwdRef(PHs.front().getID()));
+    auto *MD = MetadataList.getMetadataFwdRef(PHs.front().getID());
+#ifndef NDEBUG
+    if (auto MDN = dyn_cast<MDNode>(MD)) {
+      assert(MDN->isResolved() &&
+             "Flushing Placeholder while cycles aren't resolved");
+    }
+#endif
+    PHs.front().replaceUseWith(MD);
     PHs.pop_front();
   }
 }




More information about the llvm-commits mailing list