2018-11-15 10:32:43 +08:00
; RUN: llc -mtriple=amdgcn-amd-amdhsa -mcpu=gfx700 -mattr=-code-object-v3,+amdgpu-debugger-emit-prologue,+amdgpu-debugger-insert-nops -filetype=obj -o - < %s | llvm-readobj -elf-output-style=GNU -notes | FileCheck --check-prefix=CHECK --check-prefix=GFX700 --check-prefix=NOTES %s
; RUN: llc -mtriple=amdgcn-amd-amdhsa -mcpu=gfx802 -mattr=-code-object-v3,+amdgpu-debugger-emit-prologue,+amdgpu-debugger-insert-nops -filetype=obj -o - < %s | llvm-readobj -elf-output-style=GNU -notes | FileCheck --check-prefix=CHECK --check-prefix=GFX802 --check-prefix=NOTES %s
; RUN: llc -mtriple=amdgcn-amd-amdhsa -mcpu=gfx900 -mattr=-code-object-v3,+amdgpu-debugger-emit-prologue,+amdgpu-debugger-insert-nops -filetype=obj -o - < %s | llvm-readobj -elf-output-style=GNU -notes | FileCheck --check-prefix=CHECK --check-prefix=GFX900 --check-prefix=NOTES %s
2017-11-16 10:54:49 +08:00
target datalayout = "A5"
2017-03-23 07:10:46 +08:00
declare void @llvm.dbg.declare ( metadata , metadata , metadata )
; CHECK: ---
; CHECK: Version: [ 1, 0 ]
; CHECK: Kernels:
2017-10-15 03:03:51 +08:00
; CHECK: - Name: test
; CHECK: SymbolName: 'test@kd'
2017-03-23 07:10:46 +08:00
; CHECK: DebugProps:
; CHECK: DebuggerABIVersion: [ 1, 0 ]
; CHECK: PrivateSegmentBufferSGPR: 0
; CHECK: WavefrontPrivateSegmentOffsetSGPR: 11
define amdgpu_kernel void @test ( i32 addrspace ( 1 ) * %A ) #0 !dbg !7 !kernel_arg_addr_space !12 !kernel_arg_access_qual !13 !kernel_arg_type !14 !kernel_arg_base_type !14 !kernel_arg_type_qual !15 {
entry:
2017-11-16 10:54:49 +08:00
%A.addr = alloca i32 addrspace ( 1 ) * , align 4 , addrspace ( 5 )
store i32 addrspace ( 1 ) * %A , i32 addrspace ( 1 ) * addrspace ( 5 ) * %A.addr , align 4
call void @llvm.dbg.declare ( metadata i32 addrspace ( 1 ) * addrspace ( 5 ) * %A.addr , metadata !16 , metadata !17 ) , !dbg !18
%0 = load i32 addrspace ( 1 ) * , i32 addrspace ( 1 ) * addrspace ( 5 ) * %A.addr , align 4 , !dbg !19
2017-03-23 07:10:46 +08:00
%arrayidx = getelementptr inbounds i32 , i32 addrspace ( 1 ) * %0 , i64 0 , !dbg !19
store i32 777 , i32 addrspace ( 1 ) * %arrayidx , align 4 , !dbg !20
2017-11-16 10:54:49 +08:00
%1 = load i32 addrspace ( 1 ) * , i32 addrspace ( 1 ) * addrspace ( 5 ) * %A.addr , align 4 , !dbg !21
2017-03-23 07:10:46 +08:00
%arrayidx1 = getelementptr inbounds i32 , i32 addrspace ( 1 ) * %1 , i64 1 , !dbg !21
store i32 888 , i32 addrspace ( 1 ) * %arrayidx1 , align 4 , !dbg !22
2017-11-16 10:54:49 +08:00
%2 = load i32 addrspace ( 1 ) * , i32 addrspace ( 1 ) * addrspace ( 5 ) * %A.addr , align 4 , !dbg !23
2017-03-23 07:10:46 +08:00
%arrayidx2 = getelementptr inbounds i32 , i32 addrspace ( 1 ) * %2 , i64 2 , !dbg !23
store i32 999 , i32 addrspace ( 1 ) * %arrayidx2 , align 4 , !dbg !24
ret void , !dbg !25
}
2018-11-15 10:32:43 +08:00
attributes #0 = { noinline nounwind "correctly-rounded-divide-sqrt-fp-math" = "false" "disable-tail-calls" = "false" "less-precise-fpmad" = "false" "no-frame-pointer-elim" = "true" "no-frame-pointer-elim-non-leaf" "no-infs-fp-math" = "false" "no-jump-tables" = "false" "no-nans-fp-math" = "false" "no-signed-zeros-fp-math" = "false" "no-trapping-math" = "false" "stack-protector-buffer-size" = "8" "target-cpu" = "gfx800" "target-features" = "+16-bit-insts,-code-object-v3,+amdgpu-debugger-emit-prologue,+amdgpu-debugger-insert-nops,+amdgpu-debugger-reserve-regs,+dpp,+fp64-fp16-denormals,+s-memrealtime,-fp32-denormals" "unsafe-fp-math" = "false" "use-soft-float" = "false" }
2017-03-23 07:10:46 +08:00
!llvm.dbg.cu = ! { !0 }
!opencl.ocl.version = ! { !3 }
!llvm.module.flags = ! { !4 , !5 }
!llvm.ident = ! { !6 }
!0 = distinct !DICompileUnit ( language: D W _ L A N G _ C 99 , file: !1 , producer: "clang version 5.0.0" , isOptimized: false , runtimeVersion: 0 , emissionKind: F u l l D e b u g , enums: !2 )
!1 = !DIFile ( filename: "code-object-metadata-kernel-debug-props.cl" , directory: "/some/random/directory" )
!2 = ! { }
!3 = ! { i32 1 , i32 0 }
!4 = ! { i32 2 , !"Dwarf Version" , i32 2 }
!5 = ! { i32 2 , !"Debug Info Version" , i32 3 }
!6 = ! { !"clang version 5.0.0" }
[DebugInfo] Add DILabel metadata and intrinsic llvm.dbg.label.
In order to set breakpoints on labels and list source code around
labels, we need collect debug information for labels, i.e., label
name, the function label belong, line number in the file, and the
address label located. In order to keep these information in LLVM
IR and to allow backend to generate debug information correctly.
We create a new kind of metadata for labels, DILabel. The format
of DILabel is
!DILabel(scope: !1, name: "foo", file: !2, line: 3)
We hope to keep debug information as much as possible even the
code is optimized. So, we create a new kind of intrinsic for label
metadata to avoid the metadata is eliminated with basic block.
The intrinsic will keep existing if we keep it from optimized out.
The format of the intrinsic is
llvm.dbg.label(metadata !1)
It has only one argument, that is the DILabel metadata. The
intrinsic will follow the label immediately. Backend could get the
label metadata through the intrinsic's parameter.
We also create DIBuilder API for labels to be used by Frontend.
Frontend could use createLabel() to allocate DILabel objects, and use
insertLabel() to insert llvm.dbg.label intrinsic in LLVM IR.
Differential Revision: https://reviews.llvm.org/D45024
Patch by Hsiangkai Wang.
llvm-svn: 331841
2018-05-09 10:40:45 +08:00
!7 = distinct !DISubprogram ( name: "test" , scope: !1 , file: !1 , line: 1 , type: !8 , isLocal: false , isDefinition: true , scopeLine: 1 , flags: D I F l a g P r o t o t y p e d , isOptimized: false , unit: !0 , retainedNodes: !2 )
2017-03-23 07:10:46 +08:00
!8 = !DISubroutineType ( types: !9 )
!9 = ! { null , !10 }
!10 = !DIDerivedType ( tag: D W _ T A G _ p o i n t e r _ type , baseType: !11 , size: 64 )
!11 = !DIBasicType ( name: "int" , size: 32 , encoding: D W _ A T E _ s i g n e d )
!12 = ! { i32 1 }
!13 = ! { !"none" }
2017-11-16 10:54:49 +08:00
!14 = ! { !"int addrspace(5)*" }
2017-03-23 07:10:46 +08:00
!15 = ! { !"" }
!16 = !DILocalVariable ( name: "A" , arg: 1 , scope: !7 , file: !1 , line: 1 , type: !10 )
!17 = !DIExpression ( D W _ O P _ c o n s t u , 1 , D W _ O P _ s w a p , D W _ O P _ x d e r e f )
!18 = !DILocation ( line: 1 , column: 30 , scope: !7 )
!19 = !DILocation ( line: 2 , column: 3 , scope: !7 )
!20 = !DILocation ( line: 2 , column: 8 , scope: !7 )
!21 = !DILocation ( line: 3 , column: 3 , scope: !7 )
!22 = !DILocation ( line: 3 , column: 8 , scope: !7 )
!23 = !DILocation ( line: 4 , column: 3 , scope: !7 )
!24 = !DILocation ( line: 4 , column: 8 , scope: !7 )
!25 = !DILocation ( line: 5 , column: 1 , scope: !7 )