[X86][NFC] MnemonicTables: only access RI fields if they're initialized

Fix an issue reported by UBSan.

Test Plan:
Configure with `-DLLVM_USE_SANITIZER="Address;Undefined"`
`ninja llc`

Differential Revision: https://reviews.llvm.org/D122140
This commit is contained in:
Amir Ayupov 2022-03-21 07:43:08 -07:00
parent 0239976bec
commit 442e9e1389
1 changed files with 2 additions and 5 deletions

View File

@ -49,18 +49,15 @@ void X86MnemonicTablesEmitter::run(raw_ostream &OS) {
const CodeGenInstruction *I = NumberedInstructions[II];
X86Disassembler::RecognizableInstr RI(Tables, *I, II);
Record *Def = I->TheDef;
bool IsCodeGenOnly = RI.IsCodeGenOnly;
bool ForceDisassemble = RI.ForceDisassemble;
uint8_t Form = RI.Form;
if ( // Filter non-X86 instructions
!Def->isSubClassOf("X86Inst") ||
// Skip pseudo instructions as they may contain non-alnum characters in
// mnemonic
(IsCodeGenOnly && !ForceDisassemble) ||
(RI.IsCodeGenOnly && !RI.ForceDisassemble) ||
// Non-parsable instruction defs contain prefix as part of AsmString
Def->getValueAsString("AsmVariantName") == "NonParsable" ||
// Skip CodeGenInstructions that are not real standalone instructions
Form == X86Local::PrefixByte || Form == X86Local::Pseudo)
RI.Form == X86Local::PrefixByte || RI.Form == X86Local::Pseudo)
continue;
// Flatten an instruction assembly string.
std::string AsmString = I->FlattenAsmStringVariants(I->AsmString, Variant);