Skip to content

Commit

Permalink
X86FoldTablesEmitter - fix static analyzer potential invalid iterator…
Browse files Browse the repository at this point in the history
… warning. NFCI.
  • Loading branch information
RKSimon committed Nov 6, 2019
1 parent 37cdac6 commit cfc385d
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions llvm/utils/TableGen/X86FoldTablesEmitter.cpp
Expand Up @@ -618,14 +618,14 @@ void X86FoldTablesEmitter::run(formatted_raw_ostream &OS) {
uint8_t Opc =
getValueFromBitsInit(MemInst->TheDef->getValueAsBitsInit("Opcode"));

if (RegInsts.count(Opc) == 0)
auto RegInstsIt = RegInsts.find(Opc);
if (RegInstsIt == RegInsts.end())
continue;

// Two forms (memory & register) of the same instruction must have the same
// opcode. try matching only with register form instructions with the same
// opcode.
std::vector<const CodeGenInstruction *> &OpcRegInsts =
RegInsts.find(Opc)->second;
std::vector<const CodeGenInstruction *> &OpcRegInsts = RegInstsIt->second;

auto Match = find_if(OpcRegInsts, IsMatch(MemInst, Records));
if (Match != OpcRegInsts.end()) {
Expand Down

0 comments on commit cfc385d

Please sign in to comment.