Index: lib/CodeGen/CGDebugInfo.cpp =================================================================== --- lib/CodeGen/CGDebugInfo.cpp +++ lib/CodeGen/CGDebugInfo.cpp @@ -670,7 +670,7 @@ uint64_t Align = CGM.getContext().getTypeAlign(Ty); return DBuilder.createPointerType(getOrCreateType(PointeeTy, Unit), Size, - Align); + Align, AS); } llvm::DIType *CGDebugInfo::getOrCreateStructPtrType(StringRef Name, @@ -1351,7 +1351,7 @@ llvm::DIType *SubTy = DBuilder.createSubroutineType(Unit, SElements); unsigned Size = Context.getTypeSize(Context.VoidPtrTy); llvm::DIType *vtbl_ptr_type = - DBuilder.createPointerType(SubTy, Size, 0, "__vtbl_ptr_type"); + DBuilder.createPointerType(SubTy, Size, 0, 0, "__vtbl_ptr_type"); VTablePtrType = DBuilder.createPointerType(vtbl_ptr_type, Size); return VTablePtrType; } Index: test/CodeGenOpenCL/addrspace-debug-info.cl =================================================================== --- /dev/null +++ test/CodeGenOpenCL/addrspace-debug-info.cl @@ -0,0 +1,36 @@ +// RUN: %clang_cc1 -cl-std=CL2.0 -g -triple amdgcn-unknown-amdhsa -S -emit-llvm -o - %s | FileCheck %s + +// FIXME: generic pointer getting wrong address space. + + +// CHECK-DAG: ![[GLOBALPTRTYPE:[0-9]+]] = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !{{[0-9]+}}, size: 64, align: 32, extraData: i32 1) +// CHECK-DAG: ![[CONSTANTPTRTYPE:[0-9]+]] = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !{{[0-9]+}}, size: 64, align: 32, extraData: i32 2) +// CHECK-DAG: ![[LOCALPTRTYPE:[0-9]+]] = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !{{[0-9]+}}, size: 32, align: 32, extraData: i32 3) +// CHECK-DAG: ![[PRIVATEPTRTYPE:[0-9]+]] = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !{{[0-9]+}}, size: 32, align: 32) + +// CHECK-DAG: !DILocalVariable(tag: DW_TAG_arg_variable, name: "globalptr_arg", arg: 1, scope: !{{[0-9]+}}, file: !{{[0-9]+}}, line: {{[0-9]+}}, type: ![[GLOBALPTRTYPE]]) +// CHECK-DAG: !DILocalVariable(tag: DW_TAG_arg_variable, name: "constantptr_arg", arg: 2, scope: !{{[0-9]+}}, file: !{{[0-9]+}}, line: {{[0-9]+}}, type: ![[CONSTANTPTRTYPE]]) +// CHECK-DAG: !DILocalVariable(tag: DW_TAG_arg_variable, name: "localptr_arg", arg: 3, scope: !{{[0-9]+}}, file: !{{[0-9]+}}, line: {{[0-9]+}}, type: ![[LOCALPTRTYPE]]) + +// CHECK-DAG: !DILocalVariable(tag: DW_TAG_auto_variable, name: "privateptr", scope: !{{[0-9]+}}, file: !{{[0-9]+}}, line: {{[0-9]+}}, type: ![[PRIVATEPTRTYPE]] + +// FIXME: This should not be the same as the private pointer type. +// CHECK-DAG: !DILocalVariable(tag: DW_TAG_auto_variable, name: "genericptr", scope: !{{[0-9]+}}, file: !{{[0-9]+}}, line: {{[0-9]+}}, type: ![[PRIVATEPTRTYPE]] + +// CHECK-DAG: !DIDerivedType(tag: DW_TAG_member, name: "memberptr", scope: !{{[0-9]+}}, file: !{{[0-9]+}}, line: {{[0-9]+}}, baseType: ![[CONSTANTPTRTYPE]], size: 64, align: 32) + +kernel void ptr_types_debuginfo(global int* globalptr_arg, + constant int* constantptr_arg, + local int* localptr_arg) +{ + private int* privateptr = 0; + int* genericptr = 0; +} + +struct Foo { + constant int* memberptr; +}; + +// FIXME: Address space for global variable seems to not be represented? +constant int gconstint = 2; +constant struct Foo globalstruct = { &gconstint };