]> granicus.if.org Git - llvm/commitdiff
MetadataLoader: Add an assertion for the implicit invariant of PlaceHolder while...
authorMehdi Amini <mehdi.amini@apple.com>
Fri, 23 Dec 2016 02:20:09 +0000 (02:20 +0000)
committerMehdi Amini <mehdi.amini@apple.com>
Fri, 23 Dec 2016 02:20:09 +0000 (02:20 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@290408 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Bitcode/Reader/MetadataLoader.cpp

index 1cfa1a821828019b1506481b7af00f4ab4e3ed14..93212b0aa77547896c8760cde00edb0b309fa5cc 100644 (file)
@@ -372,8 +372,14 @@ DistinctMDOperandPlaceholder &PlaceholderQueue::getPlaceholderOp(unsigned ID) {
 
 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();
   }
 }