diff options
author | Dimitry Andric <dim@FreeBSD.org> | 2016-01-06 20:01:02 +0000 |
---|---|---|
committer | Dimitry Andric <dim@FreeBSD.org> | 2016-01-06 20:01:02 +0000 |
commit | 8a6c1c25bce0267ee4072bd7b786b921e8a66a35 (patch) | |
tree | ea70b740d40cffe568a990c7aecd1acb5f83f786 /lib/Bitcode/Reader/BitcodeReader.cpp | |
parent | 84fe440ded1bfc237d720c49408b36798d67ceff (diff) |
Notes
Diffstat (limited to 'lib/Bitcode/Reader/BitcodeReader.cpp')
-rw-r--r-- | lib/Bitcode/Reader/BitcodeReader.cpp | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/lib/Bitcode/Reader/BitcodeReader.cpp b/lib/Bitcode/Reader/BitcodeReader.cpp index 2e670d584ecc0..c7606fd488a0a 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<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. @@ -3080,6 +3085,11 @@ void BitcodeReader::saveMetadataList( assert(MetadataToIDs[MD] == ID && "Inconsistent metadata value id"); continue; } + if (N && N->isTemporary()) + // Ensure that we assert if someone tries to RAUW this temporary + // metadata while it is the key of a map. The flag will be set back + // to true when the saved metadata list is destroyed. + N->setCanReplace(false); MetadataToIDs[MD] = ID; } } |