1 ; RUN: llc -O0 -mtriple=amdgcn--amdhsa -mcpu=fiji -verify-machineinstrs -filetype=obj < %s | llvm-dwarfdump -v -debug-info - | FileCheck %s
3 ; LLVM IR generated with the following command and OpenCL source:
5 ; $clang -cl-std=CL2.0 -g -O0 -target amdgcn-amd-amdhsa -S -emit-llvm <path-to-file>
7 ; kernel void kernel1() {
8 ; global int addrspace(5)*FuncVar0 = 0;
9 ; constant int addrspace(5)*FuncVar1 = 0;
10 ; local int addrspace(5)*FuncVar2 = 0;
11 ; private int addrspace(5)*FuncVar3 = 0;
12 ; int addrspace(5)*FuncVar4 = 0;
15 ; CHECK: DW_AT_name {{.*}}"FuncVar0"
16 ; CHECK-NEXT: DW_AT_decl_file
17 ; CHECK-NEXT: DW_AT_decl_line
18 ; CHECK-NEXT: DW_AT_type [DW_FORM_ref4] (cu + 0x{{[a-f0-9]+}} => {0x[[NONE:[a-f0-9]+]]}
20 ; CHECK: DW_AT_name {{.*}}"FuncVar1"
21 ; CHECK-NEXT: DW_AT_decl_file
22 ; CHECK-NEXT: DW_AT_decl_line
23 ; CHECK-NEXT: DW_AT_type [DW_FORM_ref4] (cu + 0x{{[a-f0-9]+}} => {0x[[NONE]]}
25 ; CHECK: DW_AT_name {{.*}}"FuncVar2"
26 ; CHECK-NEXT: DW_AT_decl_file
27 ; CHECK-NEXT: DW_AT_decl_line
28 ; CHECK-NEXT: DW_AT_type [DW_FORM_ref4] (cu + 0x{{[a-f0-9]+}} => {0x[[LOCAL:[a-f0-9]+]]}
30 ; CHECK: DW_AT_name {{.*}}"FuncVar3"
31 ; CHECK-NEXT: DW_AT_decl_file
32 ; CHECK-NEXT: DW_AT_decl_line
33 ; CHECK-NEXT: DW_AT_type [DW_FORM_ref4] (cu + 0x{{[a-f0-9]+}} => {0x[[PRIVATE:[a-f0-9]+]]}
35 ; CHECK: DW_AT_name {{.*}}"FuncVar4"
36 ; CHECK-NEXT: DW_AT_decl_file
37 ; CHECK-NEXT: DW_AT_decl_line
38 ; CHECK-NEXT: DW_AT_type [DW_FORM_ref4] (cu + 0x{{[a-f0-9]+}} => {0x[[NONE]]}
40 ; CHECK: 0x[[NONE]]: DW_TAG_pointer_type
41 ; CHECK-NEXT: DW_AT_type
42 ; CHECK-NOT: DW_AT_address_class
44 ; CHECK: 0x[[LOCAL]]: DW_TAG_pointer_type
45 ; CHECK-NEXT: DW_AT_type
46 ; CHECK-NEXT: DW_AT_address_class [DW_FORM_data4] (0x00000002)
48 ; CHECK: 0x[[PRIVATE]]: DW_TAG_pointer_type
49 ; CHECK-NEXT: DW_AT_type
50 ; CHECK-NEXT: DW_AT_address_class [DW_FORM_data4] (0x00000001)
52 declare void @llvm.dbg.declare(metadata, metadata, metadata)
54 define amdgpu_kernel void @kernel1() !dbg !7 {
56 %FuncVar0 = alloca i32 addrspace(1)*, align 4, addrspace(5)
57 %FuncVar1 = alloca i32 addrspace(4)*, align 4, addrspace(5)
58 %FuncVar2 = alloca i32 addrspace(3)*, align 4, addrspace(5)
59 %FuncVar3 = alloca i32 addrspace(5)*, align 4, addrspace(5)
60 %FuncVar4 = alloca i32*, align 4, addrspace(5)
61 call void @llvm.dbg.declare(metadata i32 addrspace(1)* addrspace(5)* %FuncVar0, metadata !10, metadata !13), !dbg !14
62 store i32 addrspace(1)* null, i32 addrspace(1)* addrspace(5)* %FuncVar0, align 4, !dbg !14
63 call void @llvm.dbg.declare(metadata i32 addrspace(4)* addrspace(5)* %FuncVar1, metadata !15, metadata !13), !dbg !16
64 store i32 addrspace(4)* null, i32 addrspace(4)* addrspace(5)* %FuncVar1, align 4, !dbg !16
65 call void @llvm.dbg.declare(metadata i32 addrspace(3)* addrspace(5)* %FuncVar2, metadata !17, metadata !13), !dbg !19
66 store i32 addrspace(3)* addrspacecast (i32* null to i32 addrspace(3)*), i32 addrspace(3)* addrspace(5)* %FuncVar2, align 4, !dbg !19
67 call void @llvm.dbg.declare(metadata i32 addrspace(5)* addrspace(5)* %FuncVar3, metadata !20, metadata !13), !dbg !22
68 store i32 addrspace(5)* addrspacecast (i32* null to i32 addrspace(5)*), i32 addrspace(5)* addrspace(5)* %FuncVar3, align 4, !dbg !22
69 call void @llvm.dbg.declare(metadata i32* addrspace(5)* %FuncVar4, metadata !23, metadata !13), !dbg !24
70 store i32* null, i32* addrspace(5)* %FuncVar4, align 4, !dbg !24
75 !opencl.ocl.version = !{!3}
76 !llvm.module.flags = !{!4, !5}
79 !0 = distinct !DICompileUnit(language: DW_LANG_C99, file: !1, producer: "", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, enums: !2)
80 !1 = !DIFile(filename: "pointer-address-space.ll", directory: "/some/random/directory")
83 !4 = !{i32 2, !"Dwarf Version", i32 2}
84 !5 = !{i32 2, !"Debug Info Version", i32 3}
86 !7 = distinct !DISubprogram(name: "kernel1", scope: !1, file: !1, line: 1, type: !8, isLocal: false, isDefinition: true, scopeLine: 1, isOptimized: false, unit: !0, retainedNodes: !2)
87 !8 = !DISubroutineType(types: !9)
89 !10 = !DILocalVariable(name: "FuncVar0", scope: !7, file: !1, line: 2, type: !11)
90 !11 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !12, size: 64)
91 !12 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)
93 !14 = !DILocation(line: 2, column: 15, scope: !7)
94 !15 = !DILocalVariable(name: "FuncVar1", scope: !7, file: !1, line: 3, type: !11)
95 !16 = !DILocation(line: 3, column: 17, scope: !7)
96 !17 = !DILocalVariable(name: "FuncVar2", scope: !7, file: !1, line: 4, type: !18)
97 !18 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !12, size: 32, dwarfAddressSpace: 2)
98 !19 = !DILocation(line: 4, column: 14, scope: !7)
99 !20 = !DILocalVariable(name: "FuncVar3", scope: !7, file: !1, line: 5, type: !21)
100 !21 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !12, size: 32, dwarfAddressSpace: 1)
101 !22 = !DILocation(line: 5, column: 16, scope: !7)
102 !23 = !DILocalVariable(name: "FuncVar4", scope: !7, file: !1, line: 6, type: !11)
103 !24 = !DILocation(line: 6, column: 8, scope: !7)
104 !25 = !DILocation(line: 7, column: 1, scope: !7)