Skip to content

Commit f8e4a61

Browse files
committed
Fix crash in CodeGenInstAlias
1 parent b286a3a commit f8e4a61

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

llvm/test/TableGen/RegClassByHwMode.td

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,8 @@ include "llvm/Target/Target.td"
7878
// ASMMATCHER: if (Operand.isReg()) {
7979

8080
// ASMMATCHER: static const MatchEntry MatchTable0[] = {
81+
// ASMMATCHER: /* also_my_load_1 */, MyTarget::MY_LOAD, Convert__RegByHwMode_XRegs_EvenIfRequired1_0__Imm1_1, AMFBS_None, { MCK_RegByHwMode_XRegs_EvenIfRequired, MCK_Imm }, },
82+
// ASMMATCHER: /* also_my_load_2 */, MyTarget::MY_LOAD, Convert__RegByHwMode_XRegs_EvenIfRequired1_0__Imm1_1, AMFBS_None, { MCK_RegByHwMode_XRegs_EvenIfRequired, MCK_Imm }, },
8183
// ASMMATCHER: /* always_all */, MyTarget::ALWAYS_ALL, Convert__Reg1_0, AMFBS_None, { MCK_XRegs }, },
8284
// ASMMATCHER: /* always_even */, MyTarget::ALWAYS_EVEN, Convert__Reg1_0, AMFBS_None, { MCK_XRegs_Even }, },
8385
// ASMMATCHER: /* custom_decode */, MyTarget::CUSTOM_DECODE, Convert__RegByHwMode_YRegs_EvenIfRequired1_0, AMFBS_None, { MCK_RegByHwMode_YRegs_EvenIfRequired }, },
@@ -412,6 +414,13 @@ def MY_LOAD : TestInstruction {
412414
let opcode = 6;
413415
}
414416

417+
// Direct RegClassByHwMode reference
418+
def MY_LOAD_ALIAS1 : InstAlias<"also_my_load_1 $dst, $src",
419+
(MY_LOAD XRegs_EvenIfRequired:$dst, MyPtrRC:$src)>;
420+
421+
// RegClassByHwMode wrapped in RegisterOperand
422+
def MY_LOAD_ALIAS2 : InstAlias<"also_my_load_2 $dst, $src",
423+
(MY_LOAD RegisterOperand<XRegs_EvenIfRequired>:$dst, PtrRegOperand:$src)>;
415424

416425
// Direct RegClassByHwMode usage
417426
def : Pat<

llvm/utils/TableGen/Common/CodeGenInstAlias.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,8 @@ CodeGenInstAlias::CodeGenInstAlias(const Record *R, const CodeGenTarget &T)
182182
PrintFatalError(R->getLoc(), "not enough arguments for instruction!");
183183

184184
const Record *Op = OpInfo.Rec;
185-
if (Op->isSubClassOf("Operand") && !OpInfo.MIOperandInfo->arg_empty()) {
185+
if (Op->isSubClassOf("Operand") && OpInfo.MIOperandInfo &&
186+
!OpInfo.MIOperandInfo->arg_empty()) {
186187
// Complex operand (a subclass of Operand with non-empty MIOperandInfo).
187188
// The argument can be a DAG or a subclass of Operand.
188189
if (auto *ArgDag = dyn_cast<DagInit>(Result->getArg(ArgIdx))) {

0 commit comments

Comments
 (0)