diff --git a/llvm/utils/TableGen/CallingConvEmitter.cpp b/llvm/utils/TableGen/CallingConvEmitter.cpp index 444b10719cb03..b315aa7d86fe9 100644 --- a/llvm/utils/TableGen/CallingConvEmitter.cpp +++ b/llvm/utils/TableGen/CallingConvEmitter.cpp @@ -378,10 +378,11 @@ void CallingConvEmitter::emitArgRegisterLists(raw_ostream &O) { const std::string &InnerCCName = InnerEntry.first; std::set &InnerRegisters = InnerEntry.second; - if (InnerRegisters.find(CCName) != InnerRegisters.end()) { - AssignedRegsMap[InnerCCName].insert(AssignedRegsMap[CCName].begin(), - AssignedRegsMap[CCName].end()); - InnerRegisters.erase(CCName); + auto It = InnerRegisters.find(CCName); + if (It != InnerRegisters.end()) { + const auto &Src = AssignedRegsMap[CCName]; + AssignedRegsMap[InnerCCName].insert(Src.begin(), Src.end()); + InnerRegisters.erase(It); } }