summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Bitcode/Reader/BitcodeReader.cpp
diff options
context:
space:
mode:
authorTeresa Johnson <tejohnson@google.com>2015-12-30 19:13:57 +0000
committerTeresa Johnson <tejohnson@google.com>2015-12-30 19:13:57 +0000
commit26aa93586a998116c8bc8cb4ba7ea1a6accf269d (patch)
treefe19acf20746d870d2e7fef021546723724d66f7 /llvm/lib/Bitcode/Reader/BitcodeReader.cpp
parent16395dd7094ec479c774d6c4c2d69bdd352d4205 (diff)
downloadbcm5719-llvm-26aa93586a998116c8bc8cb4ba7ea1a6accf269d.tar.gz
bcm5719-llvm-26aa93586a998116c8bc8cb4ba7ea1a6accf269d.zip
[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. llvm-svn: 256646
Diffstat (limited to 'llvm/lib/Bitcode/Reader/BitcodeReader.cpp')
-rw-r--r--llvm/lib/Bitcode/Reader/BitcodeReader.cpp5
1 files changed, 5 insertions, 0 deletions
diff --git a/llvm/lib/Bitcode/Reader/BitcodeReader.cpp b/llvm/lib/Bitcode/Reader/BitcodeReader.cpp
index 2e670d584ec..824a3716b83 100644
--- a/llvm/lib/Bitcode/Reader/BitcodeReader.cpp
+++ b/llvm/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<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.
OpenPOWER on IntegriCloud