2013-06-20 08:25:24 +08:00
; RUN: llc < %s -o %t -filetype=obj
2017-09-12 06:59:45 +08:00
; RUN: llvm-dwarfdump -debug-info %t | FileCheck %s
2013-06-20 08:25:24 +08:00
; RUN: llc < %s -o %t -filetype=obj -regalloc=basic
2017-09-12 06:59:45 +08:00
; RUN: llvm-dwarfdump -debug-info %t | FileCheck %s
2013-06-20 08:25:24 +08:00
2011-02-05 06:57:18 +08:00
target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64"
target triple = "x86_64-apple-darwin8"
2017-06-17 06:40:04 +08:00
; Test that consecutive, identical DBG_VALUEs are merged.
[dwarfdump] Pretty print location expressions and location lists
Summary:
Based on Fred's patch here: https://reviews.llvm.org/D6771
I can't seem to commandeer the old review, so I'm creating a new one.
With that change the locations exrpessions are pretty printed inline in the
DIE tree. The output looks like this for debug_loc entries:
DW_AT_location [DW_FORM_data4] (0x00000000
0x0000000000000001 - 0x000000000000000b: DW_OP_consts +3
0x000000000000000b - 0x0000000000000012: DW_OP_consts +7
0x0000000000000012 - 0x000000000000001b: DW_OP_reg0 RAX, DW_OP_piece 0x4
0x000000000000001b - 0x0000000000000024: DW_OP_breg5 RDI+0)
And like this for debug_loc.dwo entries:
DW_AT_location [DW_FORM_sec_offset] (0x00000000
Addr idx 2 (w/ length 190): DW_OP_consts +0, DW_OP_stack_value
Addr idx 3 (w/ length 23): DW_OP_reg0 RAX, DW_OP_piece 0x4)
Simple locations without ranges are printed inline:
DW_AT_location [DW_FORM_block1] (DW_OP_reg4 RSI, DW_OP_piece 0x4, DW_OP_bit_piece 0x20 0x0)
The debug_loc(.dwo) dumping in changed accordingly to factor the code.
Reviewers: dblaikie, aprantl, friss
Subscribers: mgorny, javed.absar, hiraditya, llvm-commits, JDevlieghere
Differential Revision: https://reviews.llvm.org/D37123
llvm-svn: 312042
2017-08-30 05:41:21 +08:00
; CHECK: DW_AT_location{{.*}}(DW_OP_reg5 RDI)
2011-02-05 06:57:18 +08:00
%0 = type { i64 , i1 }
2011-02-08 02:24:18 +08:00
@__clz_tab = external constant [ 256 x i8 ]
2011-02-05 06:57:18 +08:00
2015-11-06 06:03:56 +08:00
define hidden i128 @__divti3 ( i128 %u , i128 %v ) nounwind readnone !dbg !9 {
2011-02-05 06:57:18 +08:00
entry:
2017-07-29 04:21:02 +08:00
tail call void @llvm.dbg.value ( metadata i128 %u , metadata !14 , metadata !DIExpression ( ) ) , !dbg !15
tail call void @llvm.dbg.value ( metadata i64 0 , metadata !17 , metadata !DIExpression ( ) ) , !dbg !21
2011-02-08 02:24:18 +08:00
br i1 undef , label %bb2 , label %bb4 , !dbg !22
2011-02-05 06:57:18 +08:00
2011-02-08 02:24:18 +08:00
bb2: ; preds = %entry
2017-07-29 04:21:02 +08:00
tail call void @llvm.dbg.value ( metadata i128 %u , metadata !14 , metadata !DIExpression ( ) ) , !dbg !15
2011-02-08 02:24:18 +08:00
br label %bb4 , !dbg !23
2011-02-05 06:57:18 +08:00
2011-02-08 02:24:18 +08:00
bb4: ; preds = %bb2, %entry
br i1 undef , label %__udivmodti4.exit , label %bb82.i , !dbg !24
2011-02-05 06:57:18 +08:00
2011-02-08 02:24:18 +08:00
bb82.i: ; preds = %bb4
unreachable
2011-02-05 06:57:18 +08:00
2011-02-08 02:24:18 +08:00
__udivmodti4.exit: ; preds = %bb4
ret i128 undef , !dbg !27
2011-02-05 06:57:18 +08:00
}
Move the complex address expression out of DIVariable and into an extra
argument of the llvm.dbg.declare/llvm.dbg.value intrinsics.
Previously, DIVariable was a variable-length field that has an optional
reference to a Metadata array consisting of a variable number of
complex address expressions. In the case of OpPiece expressions this is
wasting a lot of storage in IR, because when an aggregate type is, e.g.,
SROA'd into all of its n individual members, the IR will contain n copies
of the DIVariable, all alike, only differing in the complex address
reference at the end.
By making the complex address into an extra argument of the
dbg.value/dbg.declare intrinsics, all of the pieces can reference the
same variable and the complex address expressions can be uniqued across
the CU, too.
Down the road, this will allow us to move other flags, such as
"indirection" out of the DIVariable, too.
The new intrinsics look like this:
declare void @llvm.dbg.declare(metadata %storage, metadata %var, metadata %expr)
declare void @llvm.dbg.value(metadata %storage, i64 %offset, metadata %var, metadata %expr)
This patch adds a new LLVM-local tag to DIExpressions, so we can detect
and pretty-print DIExpression metadata nodes.
What this patch doesn't do:
This patch does not touch the "Indirect" field in DIVariable; but moving
that into the expression would be a natural next step.
http://reviews.llvm.org/D4919
rdar://problem/17994491
Thanks to dblaikie and dexonsmith for reviewing this patch!
Note: I accidentally committed a bogus older version of this patch previously.
llvm-svn: 218787
2014-10-02 02:55:02 +08:00
declare void @llvm.dbg.declare ( metadata , metadata , metadata ) nounwind readnone
2011-02-05 06:57:18 +08:00
2017-07-29 04:21:02 +08:00
declare void @llvm.dbg.value ( metadata , metadata , metadata ) nounwind readnone
2011-02-05 06:57:18 +08:00
declare %0 @llvm.uadd.with.overflow.i64 ( i64 , i64 ) nounwind readnone
2013-03-08 08:23:31 +08:00
!llvm.dbg.cu = ! { !2 }
2013-11-23 05:49:45 +08:00
!llvm.module.flags = ! { !32 }
2011-02-05 06:57:18 +08:00
2016-04-15 23:57:41 +08:00
!0 = distinct !DISubprogram ( name: "__udivmodti4" , line: 879 , isLocal: true , isDefinition: true , virtualIndex: 6 , flags: D I F l a g P r o t o t y p e d , isOptimized: true , unit: !2 , scopeLine: 879 , file: !29 , scope: !1 , type: !3 )
2015-04-30 00:38:44 +08:00
!1 = !DIFile ( filename: "foobar.c" , directory: "/tmp" )
2016-04-15 23:57:41 +08:00
!2 = distinct !DICompileUnit ( language: D W _ L A N G _ C 89 , producer: "4.2.1 (Based on Apple Inc. build 5658) (LLVM build)" , isOptimized: true , emissionKind: F u l l D e b u g , file: !29 , enums: !31 , retainedTypes: !31 , imports: null )
2015-04-30 00:38:44 +08:00
!3 = !DISubroutineType ( types: !4 )
IR: Make metadata typeless in assembly
Now that `Metadata` is typeless, reflect that in the assembly. These
are the matching assembly changes for the metadata/value split in
r223802.
- Only use the `metadata` type when referencing metadata from a call
intrinsic -- i.e., only when it's used as a `Value`.
- Stop pretending that `ValueAsMetadata` is wrapped in an `MDNode`
when referencing it from call intrinsics.
So, assembly like this:
define @foo(i32 %v) {
call void @llvm.foo(metadata !{i32 %v}, metadata !0)
call void @llvm.foo(metadata !{i32 7}, metadata !0)
call void @llvm.foo(metadata !1, metadata !0)
call void @llvm.foo(metadata !3, metadata !0)
call void @llvm.foo(metadata !{metadata !3}, metadata !0)
ret void, !bar !2
}
!0 = metadata !{metadata !2}
!1 = metadata !{i32* @global}
!2 = metadata !{metadata !3}
!3 = metadata !{}
turns into this:
define @foo(i32 %v) {
call void @llvm.foo(metadata i32 %v, metadata !0)
call void @llvm.foo(metadata i32 7, metadata !0)
call void @llvm.foo(metadata i32* @global, metadata !0)
call void @llvm.foo(metadata !3, metadata !0)
call void @llvm.foo(metadata !{!3}, metadata !0)
ret void, !bar !2
}
!0 = !{!2}
!1 = !{i32* @global}
!2 = !{!3}
!3 = !{}
I wrote an upgrade script that handled almost all of the tests in llvm
and many of the tests in cfe (even handling many `CHECK` lines). I've
attached it (or will attach it in a moment if you're speedy) to PR21532
to help everyone update their out-of-tree testcases.
This is part of PR21532.
llvm-svn: 224257
2014-12-16 03:07:53 +08:00
!4 = ! { !5 , !5 , !5 , !8 }
2015-04-30 00:38:44 +08:00
!5 = !DIDerivedType ( tag: D W _ T A G _ t y p e d e f , name: "UTItype" , line: 166 , file: !30 , scope: !6 , baseType: !7 )
!6 = !DIFile ( filename: "foobar.h" , directory: "/tmp" )
!7 = !DIBasicType ( tag: D W _ T A G _ b a s e _ type , size: 128 , align: 128 , encoding: D W _ A T E _ u n s i g n e d )
!8 = !DIDerivedType ( tag: D W _ T A G _ p o i n t e r _ type , size: 64 , align: 64 , file: !29 , scope: !1 , baseType: !5 )
2016-04-15 23:57:41 +08:00
!9 = distinct !DISubprogram ( name: "__divti3" , linkageName: "__divti3" , line: 1094 , isLocal: false , isDefinition: true , virtualIndex: 6 , flags: D I F l a g P r o t o t y p e d , isOptimized: true , unit: !2 , scopeLine: 1094 , file: !29 , scope: !1 , type: !10 )
2015-04-30 00:38:44 +08:00
!10 = !DISubroutineType ( types: !11 )
IR: Make metadata typeless in assembly
Now that `Metadata` is typeless, reflect that in the assembly. These
are the matching assembly changes for the metadata/value split in
r223802.
- Only use the `metadata` type when referencing metadata from a call
intrinsic -- i.e., only when it's used as a `Value`.
- Stop pretending that `ValueAsMetadata` is wrapped in an `MDNode`
when referencing it from call intrinsics.
So, assembly like this:
define @foo(i32 %v) {
call void @llvm.foo(metadata !{i32 %v}, metadata !0)
call void @llvm.foo(metadata !{i32 7}, metadata !0)
call void @llvm.foo(metadata !1, metadata !0)
call void @llvm.foo(metadata !3, metadata !0)
call void @llvm.foo(metadata !{metadata !3}, metadata !0)
ret void, !bar !2
}
!0 = metadata !{metadata !2}
!1 = metadata !{i32* @global}
!2 = metadata !{metadata !3}
!3 = metadata !{}
turns into this:
define @foo(i32 %v) {
call void @llvm.foo(metadata i32 %v, metadata !0)
call void @llvm.foo(metadata i32 7, metadata !0)
call void @llvm.foo(metadata i32* @global, metadata !0)
call void @llvm.foo(metadata !3, metadata !0)
call void @llvm.foo(metadata !{!3}, metadata !0)
ret void, !bar !2
}
!0 = !{!2}
!1 = !{i32* @global}
!2 = !{!3}
!3 = !{}
I wrote an upgrade script that handled almost all of the tests in llvm
and many of the tests in cfe (even handling many `CHECK` lines). I've
attached it (or will attach it in a moment if you're speedy) to PR21532
to help everyone update their out-of-tree testcases.
This is part of PR21532.
llvm-svn: 224257
2014-12-16 03:07:53 +08:00
!11 = ! { !12 , !12 , !12 }
2015-04-30 00:38:44 +08:00
!12 = !DIDerivedType ( tag: D W _ T A G _ t y p e d e f , name: "TItype" , line: 160 , file: !30 , scope: !6 , baseType: !13 )
!13 = !DIBasicType ( tag: D W _ T A G _ b a s e _ type , size: 128 , align: 128 , encoding: D W _ A T E _ s i g n e d )
2015-08-01 02:58:39 +08:00
!14 = !DILocalVariable ( name: "u" , line: 1093 , arg: 1 , scope: !9 , file: !1 , type: !12 )
2015-04-30 00:38:44 +08:00
!15 = !DILocation ( line: 1093 , scope: !9 )
IR: Make metadata typeless in assembly
Now that `Metadata` is typeless, reflect that in the assembly. These
are the matching assembly changes for the metadata/value split in
r223802.
- Only use the `metadata` type when referencing metadata from a call
intrinsic -- i.e., only when it's used as a `Value`.
- Stop pretending that `ValueAsMetadata` is wrapped in an `MDNode`
when referencing it from call intrinsics.
So, assembly like this:
define @foo(i32 %v) {
call void @llvm.foo(metadata !{i32 %v}, metadata !0)
call void @llvm.foo(metadata !{i32 7}, metadata !0)
call void @llvm.foo(metadata !1, metadata !0)
call void @llvm.foo(metadata !3, metadata !0)
call void @llvm.foo(metadata !{metadata !3}, metadata !0)
ret void, !bar !2
}
!0 = metadata !{metadata !2}
!1 = metadata !{i32* @global}
!2 = metadata !{metadata !3}
!3 = metadata !{}
turns into this:
define @foo(i32 %v) {
call void @llvm.foo(metadata i32 %v, metadata !0)
call void @llvm.foo(metadata i32 7, metadata !0)
call void @llvm.foo(metadata i32* @global, metadata !0)
call void @llvm.foo(metadata !3, metadata !0)
call void @llvm.foo(metadata !{!3}, metadata !0)
ret void, !bar !2
}
!0 = !{!2}
!1 = !{i32* @global}
!2 = !{!3}
!3 = !{}
I wrote an upgrade script that handled almost all of the tests in llvm
and many of the tests in cfe (even handling many `CHECK` lines). I've
attached it (or will attach it in a moment if you're speedy) to PR21532
to help everyone update their out-of-tree testcases.
This is part of PR21532.
llvm-svn: 224257
2014-12-16 03:07:53 +08:00
!16 = ! { i64 0 }
2015-08-01 02:58:39 +08:00
!17 = !DILocalVariable ( name: "c" , line: 1095 , scope: !18 , file: !1 , type: !19 )
2015-04-30 00:38:44 +08:00
!18 = distinct !DILexicalBlock ( line: 1094 , column: 0 , file: !29 , scope: !9 )
!19 = !DIDerivedType ( tag: D W _ T A G _ t y p e d e f , name: "word_type" , line: 424 , file: !30 , scope: !6 , baseType: !20 )
!20 = !DIBasicType ( tag: D W _ T A G _ b a s e _ type , name: "long int" , size: 64 , align: 64 , encoding: D W _ A T E _ s i g n e d )
!21 = !DILocation ( line: 1095 , scope: !18 )
!22 = !DILocation ( line: 1103 , scope: !18 )
!23 = !DILocation ( line: 1104 , scope: !18 )
!24 = !DILocation ( line: 1003 , scope: !25 , inlinedAt: !26 )
!25 = distinct !DILexicalBlock ( line: 879 , column: 0 , file: !29 , scope: !0 )
!26 = !DILocation ( line: 1107 , scope: !18 )
!27 = !DILocation ( line: 1111 , scope: !18 )
!29 = !DIFile ( filename: "foobar.c" , directory: "/tmp" )
!30 = !DIFile ( filename: "foobar.h" , directory: "/tmp" )
2015-03-28 04:46:33 +08:00
!31 = ! { }
2015-03-04 01:24:31 +08:00
!32 = ! { i32 1 , !"Debug Info Version" , i32 3 }