[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:53:43 PDT 2025
================
@@ -87,9 +110,48 @@ RValue CIRGenFunction::emitCall(const CIRGenFunctionInfo &funcInfo,
assert(!cir::MissingFeatures::opCallMustTail());
assert(!cir::MissingFeatures::opCallReturn());
- // For now we just return nothing because we don't have support for return
- // values yet.
- RValue ret = RValue::get(nullptr);
+ RValue ret;
+ switch (retInfo.getKind()) {
+ case cir::ABIArgInfo::Direct: {
+ mlir::Type retCIRTy = convertType(retTy);
+ if (retInfo.getCoerceToType() == retCIRTy &&
+ retInfo.getDirectOffset() == 0) {
+ switch (getEvaluationKind(retTy)) {
+ case cir::TEK_Scalar: {
+ mlir::ResultRange results = theCall->getOpResults();
+ assert(results.size() == 1 && "unexpected number of returns");
+
+ // If the argument doesn't match, perform a bitcast to coerce it. This
+ // can happen due to trivial type mismatches.
+ if (results[0].getType() != retCIRTy) {
----------------
Lancern wrote:
Removed these unnecessary braces.
https://github.com/llvm/llvm-project/pull/135552
More information about the cfe-commits
mailing list