[llvm] r374150 - [TableGen] Fix crash when using HwModes in CodeEmitterGen
James Molloy via llvm-commits
llvm-commits at lists.llvm.org
Wed Oct 9 02:15:34 PDT 2019
Author: jamesm
Date: Wed Oct 9 02:15:34 2019
New Revision: 374150
URL: http://llvm.org/viewvc/llvm-project?rev=374150&view=rev
Log:
[TableGen] Fix crash when using HwModes in CodeEmitterGen
When an instruction has an encoding definition for only a subset of
the available HwModes, ensure we just avoid generating an encoding
rather than crash.
Modified:
llvm/trunk/test/TableGen/HwModeEncodeDecode.td
llvm/trunk/utils/TableGen/CodeEmitterGen.cpp
Modified: llvm/trunk/test/TableGen/HwModeEncodeDecode.td
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/TableGen/HwModeEncodeDecode.td?rev=374150&r1=374149&r2=374150&view=diff
==============================================================================
--- llvm/trunk/test/TableGen/HwModeEncodeDecode.td (original)
+++ llvm/trunk/test/TableGen/HwModeEncodeDecode.td Wed Oct 9 02:15:34 2019
@@ -56,6 +56,15 @@ def bar: Instruction {
let Inst{1-0} = 0b10;
let AsmString = "bar $factor";
}
+
+def baz : Instruction {
+ let InOperandList = (ins i32imm:$factor);
+ bits<32> Inst;
+ let EncodingInfos = EncodingByHwMode<
+ [ModeB], [fooTypeEncA]
+ >;
+ let AsmString = "foo $factor";
+}
}
// DECODER-LABEL: DecoderTable_ModeA32[] =
Modified: llvm/trunk/utils/TableGen/CodeEmitterGen.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/CodeEmitterGen.cpp?rev=374150&r1=374149&r2=374150&view=diff
==============================================================================
--- llvm/trunk/utils/TableGen/CodeEmitterGen.cpp (original)
+++ llvm/trunk/utils/TableGen/CodeEmitterGen.cpp Wed Oct 9 02:15:34 2019
@@ -367,7 +367,8 @@ void CodeEmitterGen::emitInstructionBase
if (const RecordVal *RV = R->getValue("EncodingInfos")) {
if (auto *DI = dyn_cast_or_null<DefInit>(RV->getValue())) {
EncodingInfoByHwMode EBM(DI->getDef(), HWM);
- EncodingDef = EBM.get(HwMode);
+ if (EBM.hasMode(HwMode))
+ EncodingDef = EBM.get(HwMode);
}
}
BitsInit *BI = EncodingDef->getValueAsBitsInit("Inst");
More information about the llvm-commits
mailing list