TableGen: Replace assertion with error for unexpected pattern inputs (#159687)

This commit is contained in:
Matt Arsenault 2025-09-19 12:57:50 +09:00 committed by GitHub
parent e7dcf7dc2e
commit e79f4511a2
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 30 additions and 1 deletions

View 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)
>;

View File

@ -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) {