[clang] [CIR] Upstream emitAndUpdateRetAlloca (PR #129933)

Andy Kaylor via cfe-commits cfe-commits at lists.llvm.org
Wed Mar 5 15:02:19 PST 2025


================
@@ -195,7 +195,16 @@ void CIRGenFunction::startFunction(GlobalDecl gd, QualType returnType,
     mlir::Location fnBodyBegin = getLoc(fd->getBody()->getBeginLoc());
     builder.CIRBaseBuilderTy::createStore(fnBodyBegin, paramVal, addrVal);
   }
+
   assert(builder.getInsertionBlock() && "Should be valid");
+
+  auto fnEndLoc = getLoc(fd->getBody()->getEndLoc());
+
+  // When the current function is not void, create an address to store the
+  // result value.
+  if (fnRetCIRTy.has_value())
----------------
andykaylor wrote:

This seems to be mimicking what the LLVM IR codegen does with ReturnValue, but I agree that it's not necessary. All we really need to do here is check that the return type isn't void.

https://github.com/llvm/llvm-project/pull/129933


More information about the cfe-commits mailing list