2011-06-02 06:03:25 +08:00
; RUN: llc < %s - | FileCheck %s
2013-05-30 06:03:55 +08:00
;
; FIXME: A potentially more interesting test case would be:
; %call = @bar()
; dbg.value j=0
; %call2 = @bar()
; dbg.value j=%call
;
; We cannot current handle the above sequence because codegenprepare
; hoists the second dbg.value above %call2, which then appears to
; conflict with j=0. It does this because SelectionDAG cannot handle
; global debug values.
2011-06-02 06:03:25 +08:00
target triple = "x86_64-apple-darwin10.0.0"
2014-04-12 01:49:47 +08:00
;CHECK: ## DW_OP_consts
2011-06-02 06:03:25 +08:00
;CHECK-NEXT: .byte 42
2015-11-06 06:03:56 +08:00
define i32 @foobar ( ) nounwind readonly noinline ssp !dbg !0 {
2011-06-02 06:03:25 +08:00
entry:
2015-04-30 00:38:44 +08:00
tail call void @llvm.dbg.value ( metadata i32 42 , i64 0 , metadata !6 , metadata !DIExpression ( ) ) , !dbg !9
2013-05-30 06:03:55 +08:00
%call = tail call i32 @bar ( ) , !dbg !11
2015-04-30 00:38:44 +08:00
tail call void @llvm.dbg.value ( metadata i32 %call , i64 0 , metadata !6 , metadata !DIExpression ( ) ) , !dbg !11
2013-05-30 06:03:55 +08:00
%call2 = tail call i32 @bar ( ) , !dbg !11
2011-06-02 06:03:25 +08:00
%add = add nsw i32 %call2 , %call , !dbg !12
ret i32 %add , !dbg !10
}
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.value ( metadata , i64 , metadata , metadata ) nounwind readnone
2011-06-02 06:03:25 +08:00
declare i32 @bar ( ) 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 = ! { !17 }
2011-06-02 06:03:25 +08:00
2016-04-15 23:57:41 +08:00
!0 = distinct !DISubprogram ( name: "foobar" , linkageName: "foobar" , line: 12 , isLocal: false , isDefinition: true , virtualIndex: 6 , isOptimized: true , unit: !2 , file: !15 , scope: !1 , type: !3 , variables: !14 )
2015-04-30 00:38:44 +08:00
!1 = !DIFile ( filename: "mu.c" , directory: "/private/tmp" )
2016-04-15 23:57:41 +08:00
!2 = distinct !DICompileUnit ( language: D W _ L A N G _ C 99 , producer: "clang version 2.9 (trunk 114183)" , isOptimized: true , emissionKind: F u l l D e b u g , file: !15 , enums: !16 , retainedTypes: !16 , 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 }
2015-04-30 00:38:44 +08:00
!5 = !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 )
2015-08-01 02:58:39 +08:00
!6 = !DILocalVariable ( name: "j" , line: 15 , scope: !7 , file: !1 , type: !5 )
2015-04-30 00:38:44 +08:00
!7 = distinct !DILexicalBlock ( line: 12 , column: 52 , file: !15 , scope: !0 )
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 = ! { i32 42 }
2015-04-30 00:38:44 +08:00
!9 = !DILocation ( line: 15 , column: 12 , scope: !7 )
!10 = !DILocation ( line: 23 , column: 3 , scope: !7 )
!11 = !DILocation ( line: 17 , column: 3 , scope: !7 )
!12 = !DILocation ( line: 18 , column: 3 , scope: !7 )
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
!14 = ! { !6 }
2015-04-30 00:38:44 +08:00
!15 = !DIFile ( filename: "mu.c" , directory: "/private/tmp" )
2015-03-28 04:46:33 +08:00
!16 = ! { }
2015-03-04 01:24:31 +08:00
!17 = ! { i32 1 , !"Debug Info Version" , i32 3 }