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