[DebugInfo] Don't turn dbg.declare into DBG_VALUE for static allocas
Summary:
We already have information about static alloca stack locations in our
side table. Emitting instructions for them is inefficient, and it only
happens when the address of the alloca has been materialized within the
current block, which isn't often.
Reviewers: aprantl, probinson, dblaikie
Subscribers: jfb, dschuff, sbc100, jgravelle-google, hiraditya, llvm-commits, aheejin
Differential Revision: https://reviews.llvm.org/D36117
llvm-svn: 309729
2017-08-02 03:45:09 +08:00
; RUN: llc < %s -O0 -mtriple x86_64-apple-darwin | FileCheck %s
; RUN: llc < %s -O0 -mtriple x86_64-apple-darwin -filetype=obj \
2017-09-12 07:05:20 +08:00
; RUN: | llvm-dwarfdump -v - --debug-info | FileCheck %s --check-prefix=DWARF
2012-03-30 08:05:02 +08:00
; <rdar://problem/11134152>
[DebugInfo] Don't turn dbg.declare into DBG_VALUE for static allocas
Summary:
We already have information about static alloca stack locations in our
side table. Emitting instructions for them is inefficient, and it only
happens when the address of the alloca has been materialized within the
current block, which isn't often.
Reviewers: aprantl, probinson, dblaikie
Subscribers: jfb, dschuff, sbc100, jgravelle-google, hiraditya, llvm-commits, aheejin
Differential Revision: https://reviews.llvm.org/D36117
llvm-svn: 309729
2017-08-02 03:45:09 +08:00
; CHECK-LABEL: _foo:
; CHECK-NOT: #DEBUG_VALUE
; "[DW_FORM_exprloc] <0x2> 91 XX" means fbreg uleb(XX)
; DWARF-LABEL: DW_TAG_formal_parameter
[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
; DWARF-NEXT: DW_AT_location [DW_FORM_exprloc] (DW_OP_fbreg -16)
[DebugInfo] Don't turn dbg.declare into DBG_VALUE for static allocas
Summary:
We already have information about static alloca stack locations in our
side table. Emitting instructions for them is inefficient, and it only
happens when the address of the alloca has been materialized within the
current block, which isn't often.
Reviewers: aprantl, probinson, dblaikie
Subscribers: jfb, dschuff, sbc100, jgravelle-google, hiraditya, llvm-commits, aheejin
Differential Revision: https://reviews.llvm.org/D36117
llvm-svn: 309729
2017-08-02 03:45:09 +08:00
; DWARF-NEXT: DW_AT_name [DW_FORM_strp] ( {{.*}} = "x")
; FIXME: There is no debug info to describe "a".
2015-11-06 06:03:56 +08:00
define i32 @foo ( i32 * %x ) nounwind uwtable ssp !dbg !5 {
2012-03-30 08:05:02 +08:00
entry:
%x.addr = alloca i32 * , align 8
%saved_stack = alloca i8 *
%cleanup.dest.slot = alloca i32
store i32 * %x , i32 * * %x.addr , align 8
2015-04-30 00:38:44 +08:00
call void @llvm.dbg.declare ( metadata i32 * * %x.addr , metadata !14 , metadata !DIExpression ( ) ) , !dbg !15
2015-02-28 05:17:42 +08:00
%0 = load i32 * , i32 * * %x.addr , align 8 , !dbg !16
%1 = load i32 , i32 * %0 , align 4 , !dbg !16
2012-03-30 08:05:02 +08:00
%2 = zext i32 %1 to i64 , !dbg !16
%3 = call i8 * @llvm.stacksave ( ) , !dbg !16
store i8 * %3 , i8 * * %saved_stack , !dbg !16
%vla = alloca i8 , i64 %2 , align 16 , !dbg !16
2015-04-30 00:38:44 +08:00
call void @llvm.dbg.declare ( metadata i8 * %vla , metadata !18 , metadata !DIExpression ( ) ) , !dbg !23
2012-03-30 08:05:02 +08:00
store i32 1 , i32 * %cleanup.dest.slot
2015-02-28 05:17:42 +08:00
%4 = load i8 * , i8 * * %saved_stack , !dbg !24
2012-03-30 08:05:02 +08:00
call void @llvm.stackrestore ( i8 * %4 ) , !dbg !24
ret i32 0 , !dbg !25
}
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
2012-03-30 08:05:02 +08:00
declare i8 * @llvm.stacksave ( ) nounwind
declare void @llvm.stackrestore ( i8 * ) nounwind
!llvm.dbg.cu = ! { !0 }
2013-11-23 05:49:45 +08:00
!llvm.module.flags = ! { !27 }
2012-03-30 08:05:02 +08:00
2016-04-15 23:57:41 +08:00
!0 = distinct !DICompileUnit ( language: D W _ L A N G _ C 99 , producer: "clang version 3.1 (trunk 153698)" , isOptimized: false , emissionKind: F u l l D e b u g , file: !26 , enums: !1 , retainedTypes: !1 , globals: !1 )
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
!1 = ! { }
2016-04-15 23:57:41 +08:00
!5 = distinct !DISubprogram ( name: "foo" , line: 6 , isLocal: false , isDefinition: true , virtualIndex: 6 , flags: D I F l a g P r o t o t y p e d , isOptimized: false , unit: !0 , file: !26 , scope: !0 , type: !7 )
2015-04-30 00:38:44 +08:00
!6 = !DIFile ( filename: "20020104-2.c" , directory: "/Volumes/Sandbox/llvm" )
!7 = !DISubroutineType ( types: !8 )
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
!8 = ! { !9 , !10 }
2015-04-30 00:38:44 +08:00
!9 = !DIBasicType ( tag: D W _ T A G _ b a s e _ type , name: "int" , size: 32 , align: 32 , encoding: D W _ A T E _ s i g n e d )
!10 = !DIDerivedType ( tag: D W _ T A G _ p o i n t e r _ type , size: 64 , align: 64 , baseType: !11 )
!11 = !DIDerivedType ( tag: D W _ T A G _ c o n s t _ type , baseType: !9 )
2015-08-01 02:58:39 +08:00
!14 = !DILocalVariable ( name: "x" , line: 5 , arg: 1 , scope: !5 , file: !6 , type: !10 )
2015-04-30 00:38:44 +08:00
!15 = !DILocation ( line: 5 , column: 21 , scope: !5 )
!16 = !DILocation ( line: 7 , column: 13 , scope: !17 )
!17 = distinct !DILexicalBlock ( line: 6 , column: 1 , file: !26 , scope: !5 )
2015-08-01 02:58:39 +08:00
!18 = !DILocalVariable ( name: "a" , line: 7 , scope: !17 , file: !6 , type: !19 )
2015-04-30 00:38:44 +08:00
!19 = !DICompositeType ( tag: D W _ T A G _ a r r a y _ type , align: 8 , baseType: !20 , elements: !21 )
!20 = !DIBasicType ( tag: D W _ T A G _ b a s e _ type , name: "char" , size: 8 , align: 8 , encoding: D W _ A T E _ s i g n e d _ c h a r )
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
!21 = ! { !22 }
2015-04-30 00:38:44 +08:00
!22 = !DISubrange ( count: -1 )
!23 = !DILocation ( line: 7 , column: 8 , scope: !17 )
!24 = !DILocation ( line: 9 , column: 1 , scope: !17 )
!25 = !DILocation ( line: 8 , column: 3 , scope: !17 )
!26 = !DIFile ( filename: "20020104-2.c" , directory: "/Volumes/Sandbox/llvm" )
2015-03-04 01:24:31 +08:00
!27 = ! { i32 1 , !"Debug Info Version" , i32 3 }