[llvm] 442e9e1 - [X86][NFC] MnemonicTables: only access RI fields if they're initialized

Amir Ayupov via llvm-commits llvm-commits at lists.llvm.org
Mon Mar 21 09:25:33 PDT 2022


Author: Amir Ayupov
Date: 2022-03-21T09:25:29-07:00
New Revision: 442e9e1389b51ffb7abd8f59858d92954e53aa90

URL: https://github.com/llvm/llvm-project/commit/442e9e1389b51ffb7abd8f59858d92954e53aa90
DIFF: https://github.com/llvm/llvm-project/commit/442e9e1389b51ffb7abd8f59858d92954e53aa90.diff

LOG: [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

Added: 
    

Modified: 
    llvm/utils/TableGen/X86MnemonicTables.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/utils/TableGen/X86MnemonicTables.cpp b/llvm/utils/TableGen/X86MnemonicTables.cpp
index 8269e6b5b85c5..0b3f20ebc6c2f 100644
--- a/llvm/utils/TableGen/X86MnemonicTables.cpp
+++ b/llvm/utils/TableGen/X86MnemonicTables.cpp
@@ -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);


        


More information about the llvm-commits mailing list