From 23423c0ea8d414e56081cb6a13bd8b2cc91513a9 Mon Sep 17 00:00:00 2001 From: Sheng Date: Tue, 22 Mar 2022 05:47:18 +0000 Subject: [PATCH] [TableGen] Fix a misuse of getValueAsBitsInit `getValueAsBitsInit` will assert when the "SoftFail" isn't presented. But given the 'if' statement below, we should've allowed this situation. This patch fix this. --- llvm/utils/TableGen/FixedLenDecoderEmitter.cpp | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/llvm/utils/TableGen/FixedLenDecoderEmitter.cpp b/llvm/utils/TableGen/FixedLenDecoderEmitter.cpp index d945da109b5cc..86591cb7bd523 100644 --- a/llvm/utils/TableGen/FixedLenDecoderEmitter.cpp +++ b/llvm/utils/TableGen/FixedLenDecoderEmitter.cpp @@ -427,9 +427,9 @@ class FilterChooser { // disassembler should return SoftFail instead of Success. // // This is used for marking UNPREDICTABLE instructions in the ARM world. - BitsInit *SFBits = - AllInstructions[Opcode].EncodingDef->getValueAsBitsInit("SoftFail"); - + const RecordVal *RV = + AllInstructions[Opcode].EncodingDef->getValue("SoftFail"); + const BitsInit *SFBits = RV ? dyn_cast(RV->getValue()) : nullptr; for (unsigned i = 0; i < BitWidth; ++i) { if (SFBits && bitFromBits(*SFBits, i) == BIT_TRUE) Insn.push_back(BIT_UNSET); @@ -1309,8 +1309,9 @@ void FilterChooser::emitPredicateTableEntry(DecoderTableInfo &TableInfo, void FilterChooser::emitSoftFailTableEntry(DecoderTableInfo &TableInfo, unsigned Opc) const { - BitsInit *SFBits = - AllInstructions[Opc].EncodingDef->getValueAsBitsInit("SoftFail"); + const RecordVal *RV = AllInstructions[Opc].EncodingDef->getValue("SoftFail"); + BitsInit *SFBits = RV ? dyn_cast(RV->getValue()) : nullptr; + if (!SFBits) return; BitsInit *InstBits = AllInstructions[Opc].EncodingDef->getValueAsBitsInit("Inst");