1 ; RUN: llc -O0 -mtriple=amdgcn-amd-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>
10 ; kernel void kernel1(unsigned int ArgN, global int addrspace(5)*ArgA, global int addrspace(5)*ArgB) {
11 ; ArgA[ArgN] += ArgB[ArgN];
14 declare void @llvm.dbg.declare(metadata, metadata, metadata)
16 ; CHECK: {{.*}}DW_TAG_variable
17 ; CHECK-NEXT: DW_AT_name {{.*}}"GlobA"
18 ; CHECK-NEXT: DW_AT_type
19 ; CHECK-NEXT: DW_AT_external
20 ; CHECK-NEXT: DW_AT_decl_file
21 ; CHECK-NEXT: DW_AT_decl_line
22 ; CHECK-NEXT: DW_AT_location [DW_FORM_block1] (DW_OP_addr 0x0)
23 @GlobA = common addrspace(1) global i32 0, align 4, !dbg !0
25 ; CHECK: {{.*}}DW_TAG_variable
26 ; CHECK-NEXT: DW_AT_name {{.*}}"GlobB"
27 ; CHECK-NEXT: DW_AT_type
28 ; CHECK-NEXT: DW_AT_external
29 ; CHECK-NEXT: DW_AT_decl_file
30 ; CHECK-NEXT: DW_AT_decl_line
31 ; CHECK-NEXT: DW_AT_location [DW_FORM_block1] (DW_OP_addr 0x0)
32 @GlobB = common addrspace(1) global i32 0, align 4, !dbg !6
34 ; CHECK: {{.*}}DW_TAG_subprogram
35 ; CHECK: DW_AT_frame_base [DW_FORM_block1] (DW_OP_reg9 SGPR9)
37 define amdgpu_kernel void @kernel1(
38 ; CHECK: {{.*}}DW_TAG_formal_parameter
39 ; CHECK-NEXT: DW_AT_location [DW_FORM_block1] (DW_OP_fbreg +4, DW_OP_lit1, DW_OP_swap, DW_OP_xderef)
40 ; CHECK-NEXT: DW_AT_name {{.*}}"ArgN"
42 ; CHECK: {{.*}}DW_TAG_formal_parameter
43 ; CHECK-NEXT: DW_AT_location [DW_FORM_block1] (DW_OP_fbreg +8, DW_OP_lit1, DW_OP_swap, DW_OP_xderef)
44 ; CHECK-NEXT: DW_AT_name {{.*}}"ArgA"
45 i32 addrspace(1)* %ArgA,
46 ; CHECK: {{.*}}DW_TAG_formal_parameter
47 ; CHECK-NEXT: DW_AT_location [DW_FORM_block1] (DW_OP_fbreg +16, DW_OP_lit1, DW_OP_swap, DW_OP_xderef)
48 ; CHECK-NEXT: DW_AT_name {{.*}}"ArgB"
49 i32 addrspace(1)* %ArgB) !dbg !13 {
51 %ArgN.addr = alloca i32, align 4, addrspace(5)
52 %ArgA.addr = alloca i32 addrspace(1)*, align 4, addrspace(5)
53 %ArgB.addr = alloca i32 addrspace(1)*, align 4, addrspace(5)
54 store i32 %ArgN, i32 addrspace(5)* %ArgN.addr, align 4
55 call void @llvm.dbg.declare(metadata i32 addrspace(5)* %ArgN.addr, metadata !22, metadata !23), !dbg !24
56 store i32 addrspace(1)* %ArgA, i32 addrspace(1)* addrspace(5)* %ArgA.addr, align 4
57 call void @llvm.dbg.declare(metadata i32 addrspace(1)* addrspace(5)* %ArgA.addr, metadata !25, metadata !23), !dbg !26
58 store i32 addrspace(1)* %ArgB, i32 addrspace(1)* addrspace(5)* %ArgB.addr, align 4
59 call void @llvm.dbg.declare(metadata i32 addrspace(1)* addrspace(5)* %ArgB.addr, metadata !27, metadata !23), !dbg !28
60 %0 = load i32 addrspace(1)*, i32 addrspace(1)* addrspace(5)* %ArgB.addr, align 4, !dbg !29
61 %1 = load i32, i32 addrspace(5)* %ArgN.addr, align 4, !dbg !30
62 %idxprom = zext i32 %1 to i64, !dbg !29
63 %arrayidx = getelementptr inbounds i32, i32 addrspace(1)* %0, i64 %idxprom, !dbg !29
64 %2 = load i32, i32 addrspace(1)* %arrayidx, align 4, !dbg !29
65 %3 = load i32 addrspace(1)*, i32 addrspace(1)* addrspace(5)* %ArgA.addr, align 4, !dbg !31
66 %4 = load i32, i32 addrspace(5)* %ArgN.addr, align 4, !dbg !32
67 %idxprom1 = zext i32 %4 to i64, !dbg !31
68 %arrayidx2 = getelementptr inbounds i32, i32 addrspace(1)* %3, i64 %idxprom1, !dbg !31
69 %5 = load i32, i32 addrspace(1)* %arrayidx2, align 4, !dbg !33
70 %add = add nsw i32 %5, %2, !dbg !33
71 store i32 %add, i32 addrspace(1)* %arrayidx2, align 4, !dbg !33
76 !opencl.ocl.version = !{!9}
77 !llvm.module.flags = !{!10, !11}
80 !0 = !DIGlobalVariableExpression(var: !1, expr: !DIExpression())
81 !1 = distinct !DIGlobalVariable(name: "GlobA", scope: !2, file: !3, line: 1, type: !8, isLocal: false, isDefinition: true)
82 !2 = distinct !DICompileUnit(language: DW_LANG_C99, file: !3, producer: "clang version 5.0.0", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, enums: !4, globals: !5)
83 !3 = !DIFile(filename: "variable-locations.cl", directory: "/some/random/directory")
86 !6 = !DIGlobalVariableExpression(var: !7, expr: !DIExpression())
87 !7 = distinct !DIGlobalVariable(name: "GlobB", scope: !2, file: !3, line: 2, type: !8, isLocal: false, isDefinition: true)
88 !8 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)
90 !10 = !{i32 2, !"Dwarf Version", i32 2}
91 !11 = !{i32 2, !"Debug Info Version", i32 3}
92 !12 = !{!"clang version 5.0.0"}
93 !13 = distinct !DISubprogram(name: "kernel1", scope: !3, file: !3, line: 4, type: !14, isLocal: false, isDefinition: true, scopeLine: 4, flags: DIFlagPrototyped, isOptimized: false, unit: !2, retainedNodes: !4)
94 !14 = !DISubroutineType(types: !15)
95 !15 = !{null, !16, !17, !17}
96 !16 = !DIBasicType(name: "unsigned int", size: 32, encoding: DW_ATE_unsigned)
97 !17 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !8, size: 64)
98 !18 = !{i32 0, i32 1, i32 1}
99 !19 = !{!"none", !"none", !"none"}
100 !20 = !{!"uint", !"int addrspace(5)*", !"int addrspace(5)*"}
101 !21 = !{!"", !"", !""}
102 !22 = !DILocalVariable(name: "ArgN", arg: 1, scope: !13, file: !3, line: 4, type: !16)
103 !23 = !DIExpression(DW_OP_constu, 1, DW_OP_swap, DW_OP_xderef)
104 !24 = !DILocation(line: 4, column: 34, scope: !13)
105 !25 = !DILocalVariable(name: "ArgA", arg: 2, scope: !13, file: !3, line: 4, type: !17)
106 !26 = !DILocation(line: 4, column: 52, scope: !13)
107 !27 = !DILocalVariable(name: "ArgB", arg: 3, scope: !13, file: !3, line: 4, type: !17)
108 !28 = !DILocation(line: 4, column: 70, scope: !13)
109 !29 = !DILocation(line: 5, column: 17, scope: !13)
110 !30 = !DILocation(line: 5, column: 22, scope: !13)
111 !31 = !DILocation(line: 5, column: 3, scope: !13)
112 !32 = !DILocation(line: 5, column: 8, scope: !13)
113 !33 = !DILocation(line: 5, column: 14, scope: !13)
114 !34 = !DILocation(line: 6, column: 1, scope: !13)