Skip to content

Commit 2ab414f

Browse files
committed
Revert "[mlir][spirv] Remove nonlocal call verification."
This reverts commit aed3836.
1 parent f0917d9 commit 2ab414f

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed

mlir/lib/Dialect/SPIRV/IR/ControlFlowOps.cpp

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,12 +160,42 @@ LogicalResult FunctionCallOp::verify() {
160160
<< fnName.getValue() << "' not found in nearest symbol table";
161161
}
162162

163+
auto functionType = funcOp.getFunctionType();
164+
163165
if (getNumResults() > 1) {
164166
return emitOpError(
165167
"expected callee function to have 0 or 1 result, but provided ")
166168
<< getNumResults();
167169
}
168170

171+
if (functionType.getNumInputs() != getNumOperands()) {
172+
return emitOpError("has incorrect number of operands for callee: expected ")
173+
<< functionType.getNumInputs() << ", but provided "
174+
<< getNumOperands();
175+
}
176+
177+
for (uint32_t i = 0, e = functionType.getNumInputs(); i != e; ++i) {
178+
if (getOperand(i).getType() != functionType.getInput(i)) {
179+
return emitOpError("operand type mismatch: expected operand type ")
180+
<< functionType.getInput(i) << ", but provided "
181+
<< getOperand(i).getType() << " for operand number " << i;
182+
}
183+
}
184+
185+
if (functionType.getNumResults() != getNumResults()) {
186+
return emitOpError(
187+
"has incorrect number of results has for callee: expected ")
188+
<< functionType.getNumResults() << ", but provided "
189+
<< getNumResults();
190+
}
191+
192+
if (getNumResults() &&
193+
(getResult(0).getType() != functionType.getResult(0))) {
194+
return emitOpError("result type mismatch: expected ")
195+
<< functionType.getResult(0) << ", but provided "
196+
<< getResult(0).getType();
197+
}
198+
169199
return success();
170200
}
171201

0 commit comments

Comments
 (0)