[llvm] r256646 - [ThinLTO] Check MDNode values saved for metadata linking (NFC)

Teresa Johnson via llvm-commits llvm-commits at lists.llvm.org
Wed Dec 30 11:13:58 PST 2015

Author: tejohnson
Date: Wed Dec 30 13:13:57 2015
New Revision: 256646

URL: http://llvm.org/viewvc/llvm-project?rev=256646&view=rev
[ThinLTO] Check MDNode values saved for metadata linking (NFC)

Add an assert suggested in review for r255909 to ensure that MDNodes
saved in the map used for metadata linking are either temporary or

Also add a comment clarifying why we may need to save off non-MDNode


Modified: llvm/trunk/lib/Bitcode/Reader/BitcodeReader.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Bitcode/Reader/BitcodeReader.cpp?rev=256646&r1=256645&r2=256646&view=diff
--- llvm/trunk/lib/Bitcode/Reader/BitcodeReader.cpp (original)
+++ llvm/trunk/lib/Bitcode/Reader/BitcodeReader.cpp Wed Dec 30 13:13:57 2015
@@ -3071,7 +3071,12 @@ void BitcodeReader::saveMetadataList(
   for (unsigned ID = 0; ID < MetadataList.size(); ++ID) {
     Metadata *MD = MetadataList[ID];
     auto *N = dyn_cast_or_null<MDNode>(MD);
+    assert((!N || (N->isResolved() || N->isTemporary())) &&
+           "Found non-resolved non-temp MDNode while saving metadata");
     // Save all values if !OnlyTempMD, otherwise just the temporary metadata.
+    // Note that in the !OnlyTempMD case we need to save all Metadata, not
+    // just MDNode, as we may have references to other types of module-level
+    // metadata (e.g. ValueAsMetadata) from instructions.
     if (!OnlyTempMD || (N && N->isTemporary())) {
       // Will call this after materializing each function, in order to
       // handle remapping of the function's instructions/metadata.

More information about the llvm-commits mailing list