================
@@ -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!");
   // Alloca always returns a pointer in alloca address space, which may
   // be different from the type defined by the language. For example,
   // in C++ the auto variables are in the default address space. Therefore
   // cast alloca to the default address space when necessary.
-  if (getASTAllocaAddressSpace() != LangAS::Default) {
+  if (!getLangOpts().OpenCL && getASTAllocaAddressSpace() != LangAS::Default) {
----------------
arsenm wrote:

Don't see why the language mode would factor in. The below code also seems more 
complex than necessary. I would expect there to be a language typed value, and 
there to be an IR value. You would simply insert the cast if they didn't match, 
so not sure what the performAddrSpaceCast hook is for. Is that a holdover from 
before addrspacecast existed? 

https://github.com/llvm/llvm-project/pull/113930
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to