[clang] [OpenCL] Put constant initializer globals into constant addrspace (PR #90048)
Eli Friedman via cfe-commits
cfe-commits at lists.llvm.org
Thu Apr 25 11:53:13 PDT 2024
================
@@ -536,6 +536,8 @@ void AggExprEmitter::EmitArrayInit(Address DestPtr, llvm::ArrayType *AType,
CodeGen::CodeGenModule &CGM = CGF.CGM;
ConstantEmitter Emitter(CGF);
LangAS AS = ArrayQTy.getAddressSpace();
+ if (CGF.getLangOpts().OpenCL)
+ AS = LangAS::opencl_constant;
if (llvm::Constant *C =
Emitter.tryEmitForInitializer(ExprToVisit, AS, ArrayQTy)) {
auto GV = new llvm::GlobalVariable(
----------------
efriedma-quic wrote:
In the call to MakeAddrLValue, do we need to fix the address-space of ArrayQTy? Maybe it happens to work at the moment because we infer the address-space for the memcpy itself from the LLVM pointer type. But I'd prefer to fix it properly in case it ends up mattering in the future.
https://github.com/llvm/llvm-project/pull/90048
More information about the cfe-commits
mailing list