[clang] [clang] put EmitParmDecl in the target-requested AS (PR #181256)
Jameson Nash via cfe-commits
cfe-commits at lists.llvm.org
Wed Feb 18 07:01:27 PST 2026
================
@@ -2706,14 +2700,16 @@ void CodeGenFunction::EmitParmDecl(const VarDecl &D, ParamValue Arg,
bool DoStore = false;
bool IsScalar = hasScalarEvaluationKind(Ty);
bool UseIndirectDebugAddress = false;
+ LangAS DestLangAS = getLangOpts().OpenCL ? LangAS::opencl_private
----------------
vtjnash wrote:
I completely agree, and that was my intent with this PR. This code is already modal on those two languages (in opposite directions, with opencl not adding implicit `__private` when it should and OpenMP adding implicit `__private` when it should not). My hope was that by landing this PR, we can then separately address each of OpenMP and OpenCL's (and also WebAsm) producing Sema results that are inconsistent with what they wanted to happen here.
FWIW, I think the sticking point for the qualifiers is that the meaning of `&char []` depends on context so it _should_ affect the deep type when describing a variable but _not_ when it is a parameter, and presently Sema can currently only represent the former and not the later:
```
| Context | Type of a | Type of &a |
|------------------------|----------------------|------------|
| void f(char a[]) | char * (adjusted) | char ** |
| void f() { char a[]; } | char [] (unadjusted) | char (*)[] |
```
IIUC, in both cases, the qualifier can be written inside the `[]` instead if the intent is to affect the outer type per C11 6.7.6.2p7, but Sema can't yet handle that for addrspace written there as it only implements space for const/volatile/static attributes to appear there.
https://github.com/llvm/llvm-project/pull/181256
More information about the cfe-commits
mailing list