================
@@ -6275,13 +6278,46 @@ static FunctionDecl *rewriteBuiltinFunctionDecl(Sema 
*Sema, ASTContext &Context,
     OverloadParams.push_back(Context.getPointerType(PointeeType));
   }
 
+  QualType ReturnTy = FT->getReturnType();
+  QualType OverloadReturnTy = ReturnTy;
+  if (ReturnTy->isPointerType() &&
+      !ReturnTy->getPointeeType().hasAddressSpace()) {
+    if (Sema->getLangOpts().OpenCL) {
+      NeedsNewDecl = true;
+
+      QualType ReturnPtTy = ReturnTy->getPointeeType();
+      unsigned BuiltinID = FDecl->getBuiltinID();
+      LangAS defClAS;
+
+      // __builtin_alloca* should always return pointer to stack/private
+      // Address Space, while for other builtins with return pointer type,
+      // it should depend on the OpenCL version.
+      switch (BuiltinID) {
----------------
AnastasiaStulova wrote:

Seems a bit unfortunate to have such specialised code in a generic function. 
Could we not create the function prototype with the right address space 
directly in the return type inside `SemaChecking.cpp` instead?

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

Reply via email to