[llvm] r274819 - Add an assertion for the value enumerator (bitcode writer) NFC

Mehdi Amini via llvm-commits llvm-commits at lists.llvm.org
Thu Jul 7 18:13:41 PDT 2016


Author: mehdi_amini
Date: Thu Jul  7 20:13:41 2016
New Revision: 274819

URL: http://llvm.org/viewvc/llvm-project?rev=274819&view=rev
Log:
Add an assertion for the value enumerator (bitcode writer) NFC

I have an LTO snapshot (for which I don't have sources) that can't
be read back by LLVM. It seems the writer emitted broken bitcode
and this assertions aims at catching such cases.

Modified:
    llvm/trunk/lib/Bitcode/Writer/ValueEnumerator.cpp

Modified: llvm/trunk/lib/Bitcode/Writer/ValueEnumerator.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Bitcode/Writer/ValueEnumerator.cpp?rev=274819&r1=274818&r2=274819&view=diff
==============================================================================
--- llvm/trunk/lib/Bitcode/Writer/ValueEnumerator.cpp (original)
+++ llvm/trunk/lib/Bitcode/Writer/ValueEnumerator.cpp Thu Jul  7 20:13:41 2016
@@ -957,8 +957,13 @@ void ValueEnumerator::incorporateFunctio
   }
 
   // Add all of the function-local metadata.
-  for (unsigned i = 0, e = FnLocalMDVector.size(); i != e; ++i)
+  for (unsigned i = 0, e = FnLocalMDVector.size(); i != e; ++i) {
+    // At this point, every local values have been incorporated, we shouldn't
+    // have a metadata operand that references a value that hasn't been seen.
+    assert(ValueMap.count(FnLocalMDVector[i]->getValue()) &&
+           "Missing value for metadata operand");
     EnumerateFunctionLocalMetadata(F, FnLocalMDVector[i]);
+  }
 }
 
 void ValueEnumerator::purgeFunction() {




More information about the llvm-commits mailing list