2016-08-16 02:18:26 +08:00
; Check that when variables are allocated on the stack we generate debug locations
; for the stack location directly instead of generating a register+offset indirection.
2016-08-16 06:54:26 +08:00
; RUN: llc -O2 -filetype=obj -disable-post-ra -mtriple=x86_64-unknown-linux-gnu < %s \
Re-commit "DWARF location lists: Add section index dumping"
This reapplies c0f6ad7d1f3ccb9d0b9ce9ef8dfa06409ccf1b3e with an
additional fix in test/DebugInfo/X86/constant-loclist.ll, which had a
slightly different output on windows targets. The test now accounts for
this difference.
The original commit message follows.
Summary:
As discussed in D70081, this adds the ability to dump section
names/indices to the location list dumper. It does this by moving the
range specific logic from DWARFDie.cpp:dumpRanges into the
DWARFAddressRange class.
The trickiest part of this patch is the backflip in the meanings of the
two dump flags for the location list sections.
The dumping of "raw" location list data is now controlled by
"DisplayRawContents" flag. This frees up the "Verbose" flag to be used
to control whether we print the section index. Additionally, the
DisplayRawContents flag is set for section-based dumps whenever the
--verbose option is passed, but this is not done for the "inline" dumps.
Also note that the index dumping currently does not work for the DWARF
v5 location lists, as the parser does not fill out the appropriate
fields. This will be done in a separate patch.
Reviewers: dblaikie, probinson, JDevlieghere, SouraVX
Subscribers: sdardis, hiraditya, jrtc27, atanasyan, arphaman, aprantl, llvm-commits
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D70227
2019-11-14 18:22:00 +08:00
; RUN: | llvm-dwarfdump - | FileCheck %s
2016-08-16 02:18:26 +08:00
;
; int data = 17;
; int sum = 0;
; int zero = 0;
; int *ptr;
;
; extern void foo(int i, int *p);
;
; int main()
; {
; int val;
; val = data;
; foo(1, &val);
; foo(2, &data);
; return zero;
; }
;
; CHECK: .debug_info contents
; CHECK: DW_TAG_subprogram
; CHECK-NOT: NULL
; CHECK: DW_TAG_variable
Re-commit "DWARF location lists: Add section index dumping"
This reapplies c0f6ad7d1f3ccb9d0b9ce9ef8dfa06409ccf1b3e with an
additional fix in test/DebugInfo/X86/constant-loclist.ll, which had a
slightly different output on windows targets. The test now accounts for
this difference.
The original commit message follows.
Summary:
As discussed in D70081, this adds the ability to dump section
names/indices to the location list dumper. It does this by moving the
range specific logic from DWARFDie.cpp:dumpRanges into the
DWARFAddressRange class.
The trickiest part of this patch is the backflip in the meanings of the
two dump flags for the location list sections.
The dumping of "raw" location list data is now controlled by
"DisplayRawContents" flag. This frees up the "Verbose" flag to be used
to control whether we print the section index. Additionally, the
DisplayRawContents flag is set for section-based dumps whenever the
--verbose option is passed, but this is not done for the "inline" dumps.
Also note that the index dumping currently does not work for the DWARF
v5 location lists, as the parser does not fill out the appropriate
fields. This will be done in a separate patch.
Reviewers: dblaikie, probinson, JDevlieghere, SouraVX
Subscribers: sdardis, hiraditya, jrtc27, atanasyan, arphaman, aprantl, llvm-commits
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D70227
2019-11-14 18:22:00 +08:00
; CHECK: DW_AT_location ({{.*}}
2018-01-16 19:17:57 +08:00
; CHECK-NEXT: [{{0x.*}}, {{0x.*}}): DW_OP_reg0 RAX
2018-07-27 04:56:53 +08:00
;
; Note: This is a location, so we don't want an extra DW_OP_deref at the end.
; LLDB gets the location right without it:
; Variable: ... name = "val", type = "int", location = [rsp+4], decl = frame.c:10
; Adding the deref actually creates an invalid location:
; ... [rsp+4] DW_OP_deref
;
; CHECK-NEXT: [{{0x.*}}, {{0x.*}}): DW_OP_breg7 RSP+4)
Re-commit "DWARF location lists: Add section index dumping"
This reapplies c0f6ad7d1f3ccb9d0b9ce9ef8dfa06409ccf1b3e with an
additional fix in test/DebugInfo/X86/constant-loclist.ll, which had a
slightly different output on windows targets. The test now accounts for
this difference.
The original commit message follows.
Summary:
As discussed in D70081, this adds the ability to dump section
names/indices to the location list dumper. It does this by moving the
range specific logic from DWARFDie.cpp:dumpRanges into the
DWARFAddressRange class.
The trickiest part of this patch is the backflip in the meanings of the
two dump flags for the location list sections.
The dumping of "raw" location list data is now controlled by
"DisplayRawContents" flag. This frees up the "Verbose" flag to be used
to control whether we print the section index. Additionally, the
DisplayRawContents flag is set for section-based dumps whenever the
--verbose option is passed, but this is not done for the "inline" dumps.
Also note that the index dumping currently does not work for the DWARF
v5 location lists, as the parser does not fill out the appropriate
fields. This will be done in a separate patch.
Reviewers: dblaikie, probinson, JDevlieghere, SouraVX
Subscribers: sdardis, hiraditya, jrtc27, atanasyan, arphaman, aprantl, llvm-commits
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D70227
2019-11-14 18:22:00 +08:00
; CHECK-NEXT: DW_AT_name ("val")
2016-08-16 02:18:26 +08:00
; ModuleID = 'frame.c'
source_filename = "frame.c"
2016-12-22 08:45:21 +08:00
@data = global i32 17 , align 4 , !dbg !0
2016-09-13 09:12:59 +08:00
@sum = local_unnamed_addr global i32 0 , align 4 , !dbg !6
2016-12-22 08:45:21 +08:00
@zero = local_unnamed_addr global i32 0 , align 4 , !dbg !9
@ptr = common local_unnamed_addr global i32 * null , align 8 , !dbg !11
2016-08-16 02:18:26 +08:00
2016-12-22 08:45:21 +08:00
define i32 @main ( ) local_unnamed_addr !dbg !17 {
2016-08-16 02:18:26 +08:00
entry:
%val = alloca i32 , align 4
2016-12-22 08:45:21 +08:00
%0 = bitcast i32 * %val to i8 * , !dbg !22
call void @llvm.lifetime.start ( i64 4 , i8 * %0 ) , !dbg !22
%1 = load i32 , i32 * @data , align 4 , !dbg !23 , !tbaa !24
2017-07-29 04:21:02 +08:00
tail call void @llvm.dbg.value ( metadata i32 %1 , metadata !21 , metadata !28 ) , !dbg !29
2016-12-22 08:45:21 +08:00
store i32 %1 , i32 * %val , align 4 , !dbg !30 , !tbaa !24
2017-07-29 04:21:02 +08:00
tail call void @llvm.dbg.value ( metadata i32 * %val , metadata !21 , metadata !31 ) , !dbg !29
2016-12-22 08:45:21 +08:00
call void @foo ( i32 1 , i32 * nonnull %val ) , !dbg !32
call void @foo ( i32 2 , i32 * nonnull @data ) , !dbg !33
%2 = load i32 , i32 * @zero , align 4 , !dbg !34 , !tbaa !24
call void @llvm.lifetime.end ( i64 4 , i8 * %0 ) , !dbg !35
ret i32 %2 , !dbg !36
2016-08-16 02:18:26 +08:00
}
; Function Attrs: argmemonly nounwind
2016-12-22 08:45:21 +08:00
declare void @llvm.lifetime.start ( i64 , i8 * nocapture ) #0
2016-08-16 02:18:26 +08:00
declare void @foo ( i32 , i32 * ) local_unnamed_addr
; Function Attrs: argmemonly nounwind
2016-12-22 08:45:21 +08:00
declare void @llvm.lifetime.end ( i64 , i8 * nocapture ) #0
2016-08-16 02:18:26 +08:00
; Function Attrs: nounwind readnone
2017-07-29 04:21:02 +08:00
declare void @llvm.dbg.value ( metadata , metadata , metadata ) #1
2016-08-16 02:18:26 +08:00
2016-12-22 08:45:21 +08:00
attributes #0 = { argmemonly nounwind }
attributes #1 = { nounwind readnone }
!llvm.dbg.cu = ! { !2 }
!llvm.module.flags = ! { !14 , !15 }
!llvm.ident = ! { !16 }
2017-08-31 02:06:51 +08:00
!0 = distinct !DIGlobalVariableExpression ( var: !1 , expr: !DIExpression ( ) )
2016-12-22 08:45:21 +08:00
!1 = !DIGlobalVariable ( name: "data" , scope: !2 , file: !3 , line: 1 , type: !8 , isLocal: false , isDefinition: true )
!2 = distinct !DICompileUnit ( language: D W _ L A N G _ C 99 , file: !3 , producer: "clang version 3.9.0 (trunk 273961)" , isOptimized: true , runtimeVersion: 0 , emissionKind: F u l l D e b u g , enums: !4 , globals: !5 )
!3 = !DIFile ( filename: "frame.c" , directory: "/home/user/test" )
!4 = ! { }
!5 = ! { !0 , !6 , !9 , !11 }
2017-08-31 02:06:51 +08:00
!6 = distinct !DIGlobalVariableExpression ( var: !7 , expr: !DIExpression ( ) )
2016-12-22 08:45:21 +08:00
!7 = !DIGlobalVariable ( name: "sum" , scope: !2 , file: !3 , line: 2 , type: !8 , isLocal: false , isDefinition: true )
!8 = !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
!9 = distinct !DIGlobalVariableExpression ( var: !10 , expr: !DIExpression ( ) )
2016-12-22 08:45:21 +08:00
!10 = !DIGlobalVariable ( name: "zero" , scope: !2 , file: !3 , line: 3 , type: !8 , isLocal: false , isDefinition: true )
2017-08-31 02:06:51 +08:00
!11 = distinct !DIGlobalVariableExpression ( var: !12 , expr: !DIExpression ( ) )
2016-12-22 08:45:21 +08:00
!12 = !DIGlobalVariable ( name: "ptr" , scope: !2 , file: !3 , line: 4 , type: !13 , isLocal: false , isDefinition: true )
!13 = !DIDerivedType ( tag: D W _ T A G _ p o i n t e r _ type , baseType: !8 , size: 64 , align: 64 )
!14 = ! { i32 2 , !"Dwarf Version" , i32 4 }
!15 = ! { i32 2 , !"Debug Info Version" , i32 3 }
!16 = ! { !"clang version 3.9.0 (trunk 273961)" }
[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
!17 = distinct !DISubprogram ( name: "main" , scope: !3 , file: !3 , line: 8 , type: !18 , isLocal: false , isDefinition: true , scopeLine: 9 , isOptimized: true , unit: !2 , retainedNodes: !20 )
2016-12-22 08:45:21 +08:00
!18 = !DISubroutineType ( types: !19 )
!19 = ! { !8 }
!20 = ! { !21 }
!21 = !DILocalVariable ( name: "val" , scope: !17 , file: !3 , line: 10 , type: !8 )
!22 = !DILocation ( line: 10 , column: 3 , scope: !17 )
!23 = !DILocation ( line: 11 , column: 9 , scope: !17 )
!24 = ! { !25 , !25 , i64 0 }
!25 = ! { !"int" , !26 , i64 0 }
!26 = ! { !"omnipotent char" , !27 , i64 0 }
!27 = ! { !"Simple C/C++ TBAA" }
!28 = !DIExpression ( )
!29 = !DILocation ( line: 10 , column: 7 , scope: !17 )
!30 = !DILocation ( line: 11 , column: 7 , scope: !17 )
!31 = !DIExpression ( D W _ O P _ d e r e f )
!32 = !DILocation ( line: 12 , column: 3 , scope: !17 )
!33 = !DILocation ( line: 13 , column: 3 , scope: !17 )
!34 = !DILocation ( line: 14 , column: 10 , scope: !17 )
!35 = !DILocation ( line: 15 , column: 1 , scope: !17 )
!36 = !DILocation ( line: 14 , column: 3 , scope: !17 )
2016-08-16 02:18:26 +08:00