diff --git a/llvm/utils/TableGen/InstrInfoEmitter.cpp b/llvm/utils/TableGen/InstrInfoEmitter.cpp index 97c00ad492419..ecf30c95f4b76 100644 --- a/llvm/utils/TableGen/InstrInfoEmitter.cpp +++ b/llvm/utils/TableGen/InstrInfoEmitter.cpp @@ -300,8 +300,8 @@ void InstrInfoEmitter::emitOperandNameMappings( assert(MaxOperandNo <= INT16_MAX && "Too many operands for the operand name -> index table"); StringRef Type = MaxOperandNo <= INT8_MAX ? "int8_t" : "int16_t"; - OS << " static constexpr " << Type << " OperandMap[][" << NumOperandNames - << "] = {\n"; + OS << " static constexpr " << Type << " OperandMap[][" + << NumOperandNames + 1 << "] = {\n"; for (const auto &Entry : OperandMap) { const std::map &OpList = Entry.first; @@ -311,7 +311,8 @@ void InstrInfoEmitter::emitOperandNameMappings( auto Iter = OpList.find(ID); OS << (Iter != OpList.end() ? (int)Iter->second : -1) << ", "; } - OS << "},\n"; + // value for OPERAND_LAST + OS << "-1 },\n"; } OS << " };\n";