[clang] [OpenCL] Put constant initializer globals into constant addrspace (PR #90048)

Changpeng Fang via cfe-commits cfe-commits at lists.llvm.org
Fri May 17 12:13:39 PDT 2024


================
@@ -535,20 +535,23 @@ void AggExprEmitter::EmitArrayInit(Address DestPtr, llvm::ArrayType *AType,
       elementType.isTriviallyCopyableType(CGF.getContext())) {
     CodeGen::CodeGenModule &CGM = CGF.CGM;
     ConstantEmitter Emitter(CGF);
-    LangAS AS = ArrayQTy.getAddressSpace();
+    QualType GVArrayQTy = CGM.getContext().getAddrSpaceQualType(
+        CGM.getContext().removeAddrSpaceQualType(ArrayQTy),
----------------
changpeng wrote:

Reduced further:

clang -c -Xclang -emit-llvm -O0 test.clcpp

__kernel void test(__global ulong *In, __global ulong *Out) {
   ulong m[4] = {  In[0], In[1], 0, 0 };                                                                                                        
   *Out = m[1];          
}

https://github.com/llvm/llvm-project/pull/90048


More information about the cfe-commits mailing list