From: Teresa Johnson Date: Wed, 30 Dec 2015 19:13:57 +0000 (+0000) Subject: [ThinLTO] Check MDNode values saved for metadata linking (NFC) X-Git-Url: http://plrg.eecs.uci.edu/git/?p=oota-llvm.git;a=commitdiff_plain;h=6e198168f880a21713c16701943a2f4b31e47be4;hp=8a487cdf19f846e91cfb3f85707728a4cb89c155 [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 resolved. Also add a comment clarifying why we may need to save off non-MDNode metadata. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@256646 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Bitcode/Reader/BitcodeReader.cpp b/lib/Bitcode/Reader/BitcodeReader.cpp index 2e670d584ec..824a3716b83 100644 --- a/lib/Bitcode/Reader/BitcodeReader.cpp +++ b/lib/Bitcode/Reader/BitcodeReader.cpp @@ -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(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.