[clang] [clang] teach OpenCL to set the param addrspace before calling CG EmitParmDecl (PR #184264)
Jameson Nash via cfe-commits
cfe-commits at lists.llvm.org
Tue Mar 3 13:10:33 PST 2026
================
@@ -15798,6 +15770,20 @@ ParmVarDecl *Sema::CheckParameter(DeclContext *DC, SourceLocation StartLoc,
T = Context.getLifetimeQualifiedType(T, lifetime);
}
+ if (getLangOpts().OpenCL) {
+ assert(!isa<DecayedType>(T));
+ if (T->isArrayType() && !T.hasAddressSpace()) {
+ QualType ET = Context.getAsArrayType(T)->getElementType();
+ if (!ET.hasAddressSpace()) {
+ // Add the private address space to the contents of the pointer when a
+ // pointer parameter is declared as an array and not declared.
+ LangAS ImplAS = LangAS::opencl_private;
----------------
vtjnash wrote:
I'm fairly sure it should not have been defined this way, since `x[]` is supposed to be syntax sugar here for `x*`, but nothing I can do about that now: OpenCL instead defined that `f(int x[])` means `f(__local int *x)`. Changing that would seem likely a breaking change now (I would simply hope here to discourage other targets from making the same choice here)
https://github.com/llvm/llvm-project/pull/184264
More information about the cfe-commits
mailing list