diff --git a/llvm/lib/CodeGen/MIRParser/MIParser.cpp b/llvm/lib/CodeGen/MIRParser/MIParser.cpp index f77c4613ad801..19c73374c3703 100644 --- a/llvm/lib/CodeGen/MIRParser/MIParser.cpp +++ b/llvm/lib/CodeGen/MIRParser/MIParser.cpp @@ -1316,9 +1316,10 @@ bool MIParser::parseMachineMetadata() { assert(PFS.MachineMetadataNodes[ID] == MD && "Tracking VH didn't work"); } else { - if (PFS.MachineMetadataNodes.count(ID)) + auto [It, Inserted] = PFS.MachineMetadataNodes.try_emplace(ID); + if (!Inserted) return error("Metadata id is already used"); - PFS.MachineMetadataNodes[ID].reset(MD); + It->second.reset(MD); } return false;