Skip to content

Commit cfb7599

Browse files
committed
FuncToEmitC: fix crash when there are no results
1 parent 4c78a3d commit cfb7599

File tree

1 file changed

+5
-8
lines changed

1 file changed

+5
-8
lines changed

mlir/lib/Conversion/FuncToEmitC/FuncToEmitC.cpp

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -37,16 +37,13 @@ class CallOpConversion final : public OpConversionPattern<func::CallOp> {
3737
callOp, "only functions with zero or one result can be converted");
3838

3939
// Convert the original function results.
40-
Type resultTy = nullptr;
41-
if (callOp.getNumResults()) {
42-
resultTy = typeConverter->convertType(callOp.getResult(0).getType());
43-
if (!resultTy)
44-
return rewriter.notifyMatchFailure(
45-
callOp, "function return type conversion failed");
40+
SmallVector<Type> types;
41+
if (failed(typeConverter->convertTypes(callOp.getResultTypes(), types))) {
42+
return rewriter.notifyMatchFailure(
43+
callOp, "function return type conversion failed");
4644
}
47-
4845
rewriter.replaceOpWithNewOp<emitc::CallOp>(
49-
callOp, resultTy, adaptor.getOperands(), callOp->getAttrs());
46+
callOp, types, adaptor.getOperands(), callOp->getAttrs());
5047

5148
return success();
5249
}

0 commit comments

Comments
 (0)