[clang] [clang] put EmitParmDecl in the target-requested AS (PR #181256)
Jameson Nash via cfe-commits
cfe-commits at lists.llvm.org
Fri Feb 13 09:14:43 PST 2026
================
@@ -2766,9 +2757,26 @@ void CodeGenFunction::EmitParmDecl(const VarDecl &D, ParamValue Arg,
DeclPtr = OpenMPLocalAddr;
AllocaPtr = DeclPtr;
} else {
- // Otherwise, create a temporary to hold the value.
- DeclPtr = CreateMemTemp(Ty, getContext().getDeclAlign(&D),
- D.getName() + ".addr", &AllocaPtr);
+ // Otherwise, create a temporary to hold the value, respecting the
+ // requested AS of the destination type.
+ RawAddress Result = CreateTempAlloca(
+ ConvertTypeForMem(Ty), DestLangAS, getContext().getDeclAlign(&D),
+ D.getName() + ".addr", nullptr, &AllocaPtr);
+ if (Ty->isConstantMatrixType()) {
+ auto *ArrayTy = cast<llvm::ArrayType>(Result.getElementType());
+ auto *ArrayElementTy = ArrayTy->getElementType();
+ auto ArrayElements = ArrayTy->getNumElements();
+ if (getContext().getLangOpts().HLSL) {
+ auto *VectorTy = cast<llvm::FixedVectorType>(ArrayElementTy);
+ ArrayElementTy = VectorTy->getElementType();
+ ArrayElements *= VectorTy->getNumElements();
+ }
+ auto *VectorTy =
+ llvm::FixedVectorType::get(ArrayElementTy, ArrayElements);
+
+ Result = Result.withElementType(VectorTy);
+ }
+ DeclPtr = Result;
----------------
vtjnash wrote:
Alternatively, this could be added as a parameter to `CreateMemTemp` to override the `Ty` addrspace for frontends that can't set this addrspace directly in their Sema
https://github.com/llvm/llvm-project/pull/181256
More information about the cfe-commits
mailing list