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

Alex Voicu via cfe-commits cfe-commits at lists.llvm.org
Mon Oct 28 14:12:40 PDT 2024


================
@@ -108,11 +108,15 @@ RawAddress CodeGenFunction::CreateTempAlloca(llvm::Type *Ty, CharUnits Align,
   if (AllocaAddr)
     *AllocaAddr = Alloca;
   llvm::Value *V = Alloca.getPointer();
+  assert((!getLangOpts().OpenCL ||
+          CGM.getTarget().getTargetAddressSpace(getASTAllocaAddressSpace()) ==
+              CGM.getTarget().getTargetAddressSpace(LangAS::opencl_private)) &&
+         "For OpenCL allocas must allocate in the private address space!");
----------------
AlexVlx wrote:

Are you certain? That's not how I'm reading its [ASMAP](https://github.com/llvm/llvm-project/blob/39303e24b6f628f3c080f1b54bd12383a55b9b3a/clang/lib/Basic/Targets/NVPTX.h#L31), think this'd work just fine it aliases generic and private (and appears they designed their ASMap to handle precisely this case). Am I missing something in particular? The above is only a concern in Clang, once it's made it to the BE it's free to do whatever, really.

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


More information about the cfe-commits mailing list