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

Amir Ayupov via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Mar 21 07:46:04 PDT 2022


Amir created this revision.
Amir added reviewers: skan, craig.topper, MaskRay.
Herald added a project: All.
Amir requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Fix an issue reported by UBSan.

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


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D122140

Files:
  llvm/utils/TableGen/X86MnemonicTables.cpp


Index: llvm/utils/TableGen/X86MnemonicTables.cpp
===================================================================
--- llvm/utils/TableGen/X86MnemonicTables.cpp
+++ llvm/utils/TableGen/X86MnemonicTables.cpp
@@ -49,18 +49,15 @@
     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);


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D122140.416938.patch
Type: text/x-patch
Size: 1304 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220321/f45595a4/attachment.bin>


More information about the llvm-commits mailing list