[clang] [clang][CodeGen][OpenCL] Fix `alloca` handling & `sret`when compiling for (PR #113930)

Matt Arsenault via cfe-commits cfe-commits at lists.llvm.org
Mon Oct 28 13:04:22 PDT 2024


================
@@ -1648,6 +1648,8 @@ CodeGenTypes::GetFunctionType(const CGFunctionInfo &FI) {
   // Add type for sret argument.
   if (IRFunctionArgs.hasSRetArg()) {
     QualType Ret = FI.getReturnType();
+    if (CGM.getLangOpts().OpenCL)
+      Ret = getContext().getAddrSpaceQualType(Ret, LangAS::opencl_private);
     unsigned AddressSpace = CGM.getTypes().getTargetAddressSpace(Ret);
----------------
arsenm wrote:

This seems like extra steps around directly calling getContext().getTargetAddressSpace(LangAS::opencl_private) 

But more importantly, I would expect this to have been handled by the target API lowering code. The language wouldn't factor in 

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


More information about the cfe-commits mailing list