TableGen: Replace assertion with error for unexpected pattern inputs (#159687)
This commit is contained in:
parent
e7dcf7dc2e
commit
e79f4511a2
25
llvm/test/TableGen/dag-pattern-crash-on-set.td
Normal file
25
llvm/test/TableGen/dag-pattern-crash-on-set.td
Normal file
@ -0,0 +1,25 @@
|
||||
// RUN: not llvm-tblgen -gen-dag-isel -I %p/../../include -o /dev/null %s 2>&1 | FileCheck %s
|
||||
|
||||
include "llvm/Target/Target.td"
|
||||
|
||||
def MyTargetInstrInfo : InstrInfo;
|
||||
def MyTarget : Target {
|
||||
let InstructionSet = MyTargetInstrInfo;
|
||||
}
|
||||
|
||||
def R0 : Register<"r0">;
|
||||
def GPR : RegisterClass<"MyTarget", [i32], 32, (add R0)>;
|
||||
|
||||
def LOAD : Instruction {
|
||||
let Size = 2;
|
||||
let OutOperandList = (outs GPR:$dst);
|
||||
let InOperandList = (ins GPR:$addr);
|
||||
let AsmString = "movimm $dst, $addr";
|
||||
}
|
||||
|
||||
// CHECK: [[@LINE+1]]:5: error: In CrashPat: unknown node type 'set' in input pattern
|
||||
def CrashPat : Pat <
|
||||
(set R0, (load GPR:$addr)),
|
||||
(LOAD $addr)
|
||||
>;
|
||||
|
||||
@ -2795,7 +2795,11 @@ bool TreePatternNode::ApplyTypeConstraints(TreePattern &TP, bool NotRegisters) {
|
||||
return MadeChange;
|
||||
}
|
||||
|
||||
assert(getOperator()->isSubClassOf("SDNodeXForm") && "Unknown node type!");
|
||||
if (!getOperator()->isSubClassOf("SDNodeXForm")) {
|
||||
TP.error("unknown node type '" + getOperator()->getName() +
|
||||
"' in input pattern");
|
||||
return false;
|
||||
}
|
||||
|
||||
// Node transforms always take one operand.
|
||||
if (getNumChildren() != 1) {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user