Skip to content

Commit 1209684

Browse files
committed
AMDGPU: Set CodePointerSize to 8 for amdgcn
llvm-svn: 300470
1 parent 18c18de commit 1209684

File tree

3 files changed

+76
-2
lines changed

3 files changed

+76
-2
lines changed

llvm/lib/Target/AMDGPU/MCTargetDesc/AMDGPUMCAsmInfo.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
using namespace llvm;
1515

1616
AMDGPUMCAsmInfo::AMDGPUMCAsmInfo(const Triple &TT) : MCAsmInfoELF() {
17+
CodePointerSize = (TT.getArch() == Triple::amdgcn) ? 8 : 4;
1718
HasSingleParameterDotFile = false;
1819
//===------------------------------------------------------------------===//
1920
MinInstAlignment = 4;
Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
; RUN: llc -O0 -mtriple=amdgcn--amdhsa -mcpu=fiji -filetype=obj < %s | llvm-dwarfdump -debug-dump=info - | FileCheck %s
2+
3+
; LLVM IR generated with the following command and OpenCL source:
4+
;
5+
; $clang -cl-std=CL2.0 -g -O0 -target amdgcn-amd-amdhsa -S -emit-llvm <path-to-file>
6+
;
7+
; kernel void kernel1(global int *A) {
8+
; *A = 11;
9+
; }
10+
;
11+
; kernel void kernel2(global int *B) {
12+
; *B = 12;
13+
; }
14+
15+
; Make sure that code pointer size is 8 bytes:
16+
; CHECK: .debug_info contents:
17+
; CHECK: addr_size = 0x08
18+
19+
declare void @llvm.dbg.declare(metadata, metadata, metadata)
20+
21+
define amdgpu_kernel void @kernel1(i32 addrspace(1)* %A) !dbg !7 {
22+
entry:
23+
%A.addr = alloca i32 addrspace(1)*, align 4
24+
store i32 addrspace(1)* %A, i32 addrspace(1)** %A.addr, align 4
25+
call void @llvm.dbg.declare(metadata i32 addrspace(1)** %A.addr, metadata !16, metadata !17), !dbg !18
26+
%0 = load i32 addrspace(1)*, i32 addrspace(1)** %A.addr, align 4, !dbg !19
27+
store i32 11, i32 addrspace(1)* %0, align 4, !dbg !20
28+
ret void, !dbg !21
29+
}
30+
31+
define amdgpu_kernel void @kernel2(i32 addrspace(1)* %B) !dbg !22 {
32+
entry:
33+
%B.addr = alloca i32 addrspace(1)*, align 4
34+
store i32 addrspace(1)* %B, i32 addrspace(1)** %B.addr, align 4
35+
call void @llvm.dbg.declare(metadata i32 addrspace(1)** %B.addr, metadata !23, metadata !17), !dbg !24
36+
%0 = load i32 addrspace(1)*, i32 addrspace(1)** %B.addr, align 4, !dbg !25
37+
store i32 12, i32 addrspace(1)* %0, align 4, !dbg !26
38+
ret void, !dbg !27
39+
}
40+
41+
!llvm.dbg.cu = !{!0}
42+
!opencl.ocl.version = !{!3, !3}
43+
!llvm.module.flags = !{!4, !5}
44+
!llvm.ident = !{!6}
45+
46+
!0 = distinct !DICompileUnit(language: DW_LANG_C99, file: !1, producer: "", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, enums: !2)
47+
!1 = !DIFile(filename: "dwarfdump-relocs.cl", directory: "/some/random/directory")
48+
!2 = !{}
49+
!3 = !{i32 2, i32 0}
50+
!4 = !{i32 2, !"Dwarf Version", i32 2}
51+
!5 = !{i32 2, !"Debug Info Version", i32 3}
52+
!6 = !{!""}
53+
!7 = distinct !DISubprogram(name: "kernel1", scope: !1, file: !1, line: 1, type: !8, isLocal: false, isDefinition: true, scopeLine: 1, flags: DIFlagPrototyped, isOptimized: false, unit: !0, variables: !2)
54+
!8 = !DISubroutineType(types: !9)
55+
!9 = !{null, !10}
56+
!10 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !11, size: 64)
57+
!11 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)
58+
!12 = !{i32 1}
59+
!13 = !{!"none"}
60+
!14 = !{!"int*"}
61+
!15 = !{!""}
62+
!16 = !DILocalVariable(name: "A", arg: 1, scope: !7, file: !1, line: 1, type: !10)
63+
!17 = !DIExpression(DW_OP_constu, 1, DW_OP_swap, DW_OP_xderef)
64+
!18 = !DILocation(line: 1, column: 33, scope: !7)
65+
!19 = !DILocation(line: 2, column: 4, scope: !7)
66+
!20 = !DILocation(line: 2, column: 6, scope: !7)
67+
!21 = !DILocation(line: 3, column: 1, scope: !7)
68+
!22 = distinct !DISubprogram(name: "kernel2", scope: !1, file: !1, line: 5, type: !8, isLocal: false, isDefinition: true, scopeLine: 5, flags: DIFlagPrototyped, isOptimized: false, unit: !0, variables: !2)
69+
!23 = !DILocalVariable(name: "B", arg: 1, scope: !22, file: !1, line: 5, type: !10)
70+
!24 = !DILocation(line: 5, column: 33, scope: !22)
71+
!25 = !DILocation(line: 6, column: 4, scope: !22)
72+
!26 = !DILocation(line: 6, column: 6, scope: !22)
73+
!27 = !DILocation(line: 7, column: 1, scope: !22)

llvm/test/DebugInfo/AMDGPU/variable-locations.ll

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ declare void @llvm.dbg.declare(metadata, metadata, metadata)
1919
; CHECK-NEXT: DW_AT_external
2020
; CHECK-NEXT: DW_AT_decl_file
2121
; CHECK-NEXT: DW_AT_decl_line
22-
; CHECK-NEXT: DW_AT_location [DW_FORM_block1] (<0x05> 03 00 00 00 00 )
22+
; CHECK-NEXT: DW_AT_location [DW_FORM_block1] (<0x09> 03 00 00 00 00 00 00 00 00 )
2323
@GlobA = common addrspace(1) global i32 0, align 4, !dbg !0
2424

2525
; CHECK: {{.*}}DW_TAG_variable
@@ -28,7 +28,7 @@ declare void @llvm.dbg.declare(metadata, metadata, metadata)
2828
; CHECK-NEXT: DW_AT_external
2929
; CHECK-NEXT: DW_AT_decl_file
3030
; CHECK-NEXT: DW_AT_decl_line
31-
; CHECK-NEXT: DW_AT_location [DW_FORM_block1] (<0x05> 03 00 00 00 00 )
31+
; CHECK-NEXT: DW_AT_location [DW_FORM_block1] (<0x09> 03 00 00 00 00 00 00 00 00 )
3232
@GlobB = common addrspace(1) global i32 0, align 4, !dbg !6
3333

3434
define amdgpu_kernel void @kernel1(

0 commit comments

Comments
 (0)