2017-09-08 06:15:44 +08:00
; RUN: llc -filetype=obj -use-unknown-locations=Enable -mtriple=x86_64-unknown-linux %s -o %t
2017-09-12 06:59:45 +08:00
; RUN: llvm-dwarfdump -debug-line %t | FileCheck %s
2017-09-08 06:15:44 +08:00
define void @_Z3bazv ( ) !dbg !6 {
call void @_Z3foov ( ) , !dbg !9
call void @_Z3foov ( ) ; no !dbg, so will be marked as line 0
ret void , !dbg !11
}
declare void @_Z3foov ( )
!llvm.dbg.cu = ! { !0 }
!llvm.module.flags = ! { !3 , !4 }
!llvm.ident = ! { !5 }
!0 = distinct !DICompileUnit ( language: D W _ L A N G _ C _ p l u s _ p l u s , file: !1 , producer: "clang version 3.9.0 (trunk 267219)" , isOptimized: false , runtimeVersion: 0 , emissionKind: F u l l D e b u g , enums: !2 )
!1 = !DIFile ( filename: "test.cc" , directory: "." )
!2 = ! { }
!3 = ! { i32 2 , !"Dwarf Version" , i32 4 }
!4 = ! { i32 2 , !"Debug Info Version" , i32 3 }
!5 = ! { !"clang version 3.9.0 (trunk 267219)" }
[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
!6 = distinct !DISubprogram ( name: "baz" , linkageName: "_Z3bazv" , scope: !1 , file: !1 , line: 3 , type: !7 , isLocal: false , isDefinition: true , scopeLine: 3 , flags: D I F l a g P r o t o t y p e d , isOptimized: false , unit: !0 , retainedNodes: !2 )
2017-09-08 06:15:44 +08:00
!7 = !DISubroutineType ( types: !8 )
!8 = ! { null }
!9 = !DILocation ( line: 4 , column: 3 , scope: !10 )
!10 = !DILexicalBlockFile ( scope: !6 , file: !1 , discriminator: 1 )
!11 = !DILocation ( line: 6 , column: 1 , scope: !6 )
; Look at the lengths. We can't verify the line-number-program size
; directly, but the difference in the two lengths should not change
; unexpectedly.
2017-12-05 05:27:46 +08:00
; CHECK: total_length: 0x00000044
; CHECK: prologue_length: 0x0000001f
2017-09-08 06:15:44 +08:00
;
; Verify that we see a line entry with a discriminator, and the next entry
; has line 0 and no discriminator.
; line column file ISA discriminator
; CHECK: 4 3 1 0 1
; CHECK-NEXT: 0 3 1 0 0