Skip to content

Commit a86f21a

Browse files
author
git apple-llvm automerger
committed
Merge commit 'dc1037335aca' from llvm.org/main into next
2 parents 1eb058a + dc10373 commit a86f21a

File tree

3 files changed

+66
-3
lines changed

3 files changed

+66
-3
lines changed
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
// RUN: not llvm-tblgen -gen-disassembler -I %p/../../../include %s 2>&1 \
2+
// RUN: | FileCheck %s --implicit-check-not=error:
3+
4+
include "llvm/Target/Target.td"
5+
6+
def R0 : Register<"r0">;
7+
def RC : RegisterClass<"MyTarget", [i32], 32, (add R0)>;
8+
9+
// Used to crash.
10+
// CHECK: error: In instruction 'I', operand #0 has 1 sub-arg names, but no sub-operands
11+
12+
def I : Instruction {
13+
let Size = 1;
14+
bits<8> Inst;
15+
bits<1> r;
16+
17+
let Inst{0} = 0;
18+
let Inst{1} = r;
19+
20+
let OutOperandList = (outs);
21+
let InOperandList = (ins (RC $r):$op);
22+
}
23+
24+
def II : InstrInfo;
25+
26+
def MyTarget : Target {
27+
let InstructionSet = II;
28+
}
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
// RUN: not llvm-tblgen -gen-disassembler -I %p/../../../include %s 2>&1 \
2+
// RUN: | FileCheck %s --implicit-check-not=error:
3+
4+
include "llvm/Target/Target.td"
5+
6+
def CustomOp : Operand<i32>;
7+
8+
// Used to crash.
9+
// CHECK: error: In instruction 'I', operand #0 has 1 sub-arg names, expected 0
10+
11+
def I : Instruction {
12+
let Size = 1;
13+
bits<8> Inst;
14+
bits<1> i;
15+
16+
let Inst{0} = 0;
17+
let Inst{1} = i;
18+
19+
let OutOperandList = (outs);
20+
let InOperandList = (ins (CustomOp $i):$op);
21+
}
22+
23+
def II : InstrInfo;
24+
25+
def MyTarget : Target {
26+
let InstructionSet = II;
27+
}

llvm/utils/TableGen/Common/CodeGenInstruction.cpp

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -143,12 +143,20 @@ CGIOperandList::CGIOperandList(const Record *R) : TheDef(R) {
143143
MIOperandNo, NumOps, MIOpInfo);
144144

145145
if (SubArgDag) {
146-
if (SubArgDag->getNumArgs() != NumOps) {
146+
if (!MIOpInfo) {
147147
PrintFatalError(R->getLoc(), "In instruction '" + R->getName() +
148148
"', operand #" + Twine(i) + " has " +
149149
Twine(SubArgDag->getNumArgs()) +
150-
" sub-arg names, expected " +
151-
Twine(NumOps) + ".");
150+
" sub-arg names, but no sub-operands");
151+
}
152+
153+
unsigned NumSubArgs = SubArgDag->getNumArgs();
154+
unsigned NumSubOps = MIOpInfo->getNumArgs();
155+
if (NumSubArgs != NumSubOps) {
156+
PrintFatalError(R->getLoc(),
157+
"In instruction '" + R->getName() + "', operand #" +
158+
Twine(i) + " has " + Twine(NumSubArgs) +
159+
" sub-arg names, expected " + Twine(NumSubOps));
152160
}
153161

154162
for (unsigned j = 0; j < NumOps; ++j) {

0 commit comments

Comments
 (0)