Skip to content

Commit e79f451

Browse files
authored
TableGen: Replace assertion with error for unexpected pattern inputs (#159687)
1 parent e7dcf7d commit e79f451

File tree

2 files changed

+30
-1
lines changed

2 files changed

+30
-1
lines changed
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
// RUN: not llvm-tblgen -gen-dag-isel -I %p/../../include -o /dev/null %s 2>&1 | FileCheck %s
2+
3+
include "llvm/Target/Target.td"
4+
5+
def MyTargetInstrInfo : InstrInfo;
6+
def MyTarget : Target {
7+
let InstructionSet = MyTargetInstrInfo;
8+
}
9+
10+
def R0 : Register<"r0">;
11+
def GPR : RegisterClass<"MyTarget", [i32], 32, (add R0)>;
12+
13+
def LOAD : Instruction {
14+
let Size = 2;
15+
let OutOperandList = (outs GPR:$dst);
16+
let InOperandList = (ins GPR:$addr);
17+
let AsmString = "movimm $dst, $addr";
18+
}
19+
20+
// CHECK: [[@LINE+1]]:5: error: In CrashPat: unknown node type 'set' in input pattern
21+
def CrashPat : Pat <
22+
(set R0, (load GPR:$addr)),
23+
(LOAD $addr)
24+
>;
25+

llvm/utils/TableGen/Common/CodeGenDAGPatterns.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2795,7 +2795,11 @@ bool TreePatternNode::ApplyTypeConstraints(TreePattern &TP, bool NotRegisters) {
27952795
return MadeChange;
27962796
}
27972797

2798-
assert(getOperator()->isSubClassOf("SDNodeXForm") && "Unknown node type!");
2798+
if (!getOperator()->isSubClassOf("SDNodeXForm")) {
2799+
TP.error("unknown node type '" + getOperator()->getName() +
2800+
"' in input pattern");
2801+
return false;
2802+
}
27992803

28002804
// Node transforms always take one operand.
28012805
if (getNumChildren() != 1) {

0 commit comments

Comments
 (0)