2014-02-14 09:26:55 +08:00
; RUN: llc -generate-arange-section < %s | FileCheck %s
2013-09-20 07:21:01 +08:00
; -- header --
2013-10-04 06:07:08 +08:00
; CHECK: .short 2 # DWARF Arange version number
2015-03-10 11:58:36 +08:00
; CHECK-NEXT: .long .Lcu_begin0
2013-10-04 06:07:08 +08:00
; CHECK-NEXT: .byte 8 # Address Size (in bytes)
; CHECK-NEXT: .byte 0 # Segment Size (in bytes)
2013-09-20 07:21:01 +08:00
; -- alignment --
2014-01-08 03:28:14 +08:00
; CHECK-NEXT: .zero 4,255
2013-09-20 07:21:01 +08:00
2015-03-10 06:08:37 +08:00
; <data section> - it should have made one span covering all vars in this CU.
; CHECK-NEXT: .quad some_data
2015-03-24 05:22:04 +08:00
; CHECK-NEXT: .quad .Lsec_end0-some_data
2015-03-10 06:08:37 +08:00
; <other sections> - it should have made one span covering all vars in this CU.
; CHECK-NEXT: .quad some_other
2015-03-24 05:22:04 +08:00
; CHECK-NEXT: .quad .Lsec_end1-some_other
2015-03-10 06:08:37 +08:00
2013-10-04 06:07:08 +08:00
; <common symbols> - it should have made one span for each symbol.
; CHECK-NEXT: .quad some_bss
; CHECK-NEXT: .quad 4
2013-09-20 07:21:01 +08:00
2013-10-04 06:07:08 +08:00
; <text section> - it should have made one span covering all functions in this CU.
; CHECK-NEXT: .quad .Lfunc_begin0
2015-03-24 05:22:04 +08:00
; CHECK-NEXT: .quad .Lsec_end2-.Lfunc_begin0
2013-09-20 07:21:01 +08:00
2013-10-04 06:07:08 +08:00
; -- finish --
; CHECK-NEXT: # ARange terminator
2013-09-20 07:21:01 +08:00
; -- source code --
; Generated from: "clang -c -g -emit-llvm"
;
; int some_data = 4;
; int some_bss;
2013-10-04 06:07:08 +08:00
; int some_other __attribute__ ((section ("strange+section"))) = 5;
2013-09-20 07:21:01 +08:00
;
; void some_code()
; {
; some_bss += some_data + some_other;
; }
2016-12-22 08:45:21 +08:00
source_filename = "test/DebugInfo/X86/dwarf-aranges.ll"
2013-09-20 07:21:01 +08:00
target triple = "x86_64-unknown-linux-gnu"
2016-12-22 08:45:21 +08:00
@some_data = global i32 4 , align 4 , !dbg !0
@some_other = global i32 5 , section "strange+section" , align 4 , !dbg !4
@some_bss = common global i32 0 , align 4 , !dbg !6
2013-09-20 07:21:01 +08:00
2016-12-22 08:45:21 +08:00
define void @some_code ( ) !dbg !13 {
2013-09-20 07:21:01 +08:00
entry:
2016-12-22 08:45:21 +08:00
%0 = load i32 , i32 * @some_data , align 4 , !dbg !16
%1 = load i32 , i32 * @some_other , align 4 , !dbg !16
%add = add nsw i32 %0 , %1 , !dbg !16
%2 = load i32 , i32 * @some_bss , align 4 , !dbg !16
%add1 = add nsw i32 %2 , %add , !dbg !16
store i32 %add1 , i32 * @some_bss , align 4 , !dbg !16
ret void , !dbg !17
2013-09-20 07:21:01 +08:00
}
2016-12-22 08:45:21 +08:00
!llvm.dbg.cu = ! { !8 }
!llvm.module.flags = ! { !11 , !12 }
2017-08-31 02:06:51 +08:00
!0 = !DIGlobalVariableExpression ( var: !1 , expr: !DIExpression ( ) )
2016-12-22 08:45:21 +08:00
!1 = !DIGlobalVariable ( name: "some_data" , scope: null , file: !2 , line: 1 , type: !3 , isLocal: false , isDefinition: true )
!2 = !DIFile ( filename: "test.c" , directory: "/home/kayamon" )
!3 = !DIBasicType ( name: "int" , size: 32 , align: 32 , encoding: D W _ A T E _ s i g n e d )
2017-08-31 02:06:51 +08:00
!4 = !DIGlobalVariableExpression ( var: !5 , expr: !DIExpression ( ) )
2016-12-22 08:45:21 +08:00
!5 = !DIGlobalVariable ( name: "some_other" , scope: null , file: !2 , line: 3 , type: !3 , isLocal: false , isDefinition: true )
2017-08-31 02:06:51 +08:00
!6 = !DIGlobalVariableExpression ( var: !7 , expr: !DIExpression ( ) )
2016-12-22 08:45:21 +08:00
!7 = !DIGlobalVariable ( name: "some_bss" , scope: null , file: !2 , line: 2 , type: !3 , isLocal: false , isDefinition: true )
!8 = distinct !DICompileUnit ( language: D W _ L A N G _ C 99 , file: !2 , producer: "clang version 3.4 " , isOptimized: false , runtimeVersion: 0 , emissionKind: F u l l D e b u g , enums: !9 , retainedTypes: !9 , globals: !10 , imports: !9 )
!9 = ! { }
!10 = ! { !0 , !4 , !6 }
!11 = ! { i32 2 , !"Dwarf Version" , i32 4 }
!12 = ! { i32 1 , !"Debug Info Version" , i32 3 }
[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
!13 = distinct !DISubprogram ( name: "some_code" , scope: !2 , file: !2 , line: 5 , type: !14 , isLocal: false , isDefinition: true , scopeLine: 6 , virtualIndex: 6 , isOptimized: false , unit: !8 , retainedNodes: !9 )
2016-12-22 08:45:21 +08:00
!14 = !DISubroutineType ( types: !15 )
!15 = ! { null }
!16 = !DILocation ( line: 7 , scope: !13 )
!17 = !DILocation ( line: 8 , scope: !13 )
2013-09-20 07:21:01 +08:00