ValueMapperFlags = ValueMapperFlags | RF_HaveUnmaterializedMetadata;
}
+ ~IRLinker() {
+ // In the case where we are not linking metadata, we unset the CanReplace
+ // flag on all temporary metadata in the MetadataToIDs map to ensure
+ // none was replaced while being a map key. Now that we are destructing
+ // the map, set the flag back to true, so that it is replaceable during
+ // metadata linking.
+ if (!shouldLinkMetadata()) {
+ for (auto MDI : MetadataToIDs) {
+ Metadata *MD = const_cast<Metadata *>(MDI.first);
+ MDNode *Node = dyn_cast<MDNode>(MD);
+ assert((Node && Node->isTemporary()) &&
+ "Found non-temp metadata in map when not linking metadata");
+ Node->setCanReplace(true);
+ }
+ }
+ }
+
bool run();
Value *materializeDeclFor(Value *V, bool ForAlias);
void materializeInitFor(GlobalValue *New, GlobalValue *Old, bool ForAlias);