Ensure MDNode used as key in metadata linking map cannot be RAUWed
As suggested in review for r255909, add a way to ensure that temporary MD used as keys in the MetadataToID map during ThinLTO importing are not RAUWed. Add support for marking an MDNode as not replaceable. Clear the new CanReplace flag when adding a temporary MD node to the MetadataToID map and clear it when destroying the map. llvm-svn: 256648
This commit is contained in:
@@ -3085,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;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user