[clang] [CIR] cir.call with scalar return type (PR #135552)
Sirui Mu via cfe-commits
cfe-commits at lists.llvm.org
Tue Apr 15 08:54:11 PDT 2025
================
@@ -515,9 +519,32 @@ verifyCallCommInSymbolUses(mlir::Operation *op,
return op->emitOpError() << "'" << fnAttr.getValue()
<< "' does not reference a valid function";
- // TODO(cir): verify function arguments and return type
+ auto callIf = dyn_cast<cir::CIRCallOpInterface>(op);
+ assert(callIf && "expected CIR call interface to be always available");
+
+ // Verify that the operand and result types match the callee. Note that
+ // argument-checking is disabled for functions without a prototype.
+ auto fnType = fn.getFunctionType();
+
+ // TODO(cir): verify function arguments
assert(!cir::MissingFeatures::opCallArgs());
+ // Void function must not return any results.
+ if (fnType.hasVoidReturn() && op->getNumResults() != 0)
+ return op->emitOpError("callee returns void but call has results");
----------------
Lancern wrote:
Added tests for verifier errors in `invalid-calls.cir`.
https://github.com/llvm/llvm-project/pull/135552
More information about the cfe-commits
mailing list