2014-12-16 08:08:19 +01:00
; RUN: opt -S -O3 < %s | FileCheck %s
2014-08-19 23:08:27 +02:00
; RUN: verify-uselistorder %s
2010-02-06 02:21:09 +01: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-darwin10.2"
%struct.anon = type { i32 , i32 }
%struct.test = type { i64 , %struct.anon , %struct.test * }
2015-03-13 19:20:45 +01:00
@TestArrayPtr = global %struct.test * getelementptr inbounds ( [ 10 x %struct.test ] , [ 10 x %struct.test ] * @TestArray , i64 0 , i64 3 ) ; <%struct.test**> [#uses=1]
2010-02-06 02:21:09 +01:00
@TestArray = common global [ 10 x %struct.test ] zeroinitializer , align 32 ; <[10 x %struct.test]*> [#uses=2]
2015-11-05 23:03:56 +01:00
define i32 @main ( ) nounwind readonly !dbg !1 {
2010-02-06 02:21:09 +01:00
%diff1 = alloca i64 ; <i64*> [#uses=2]
2014-12-16 08:08:19 +01:00
; CHECK: call void @llvm.dbg.value(metadata i64 72,
2015-04-29 18:38:44 +02:00
call void @llvm.dbg.declare ( metadata i64 * %diff1 , metadata !0 , metadata !DIExpression ( ) ) , !dbg !DILocation ( scope: !1 )
2010-02-06 02:21:09 +01:00
store i64 72 , i64 * %diff1 , align 8
2015-02-27 22:17:42 +01:00
%v1 = load %struct.test * , %struct.test * * @TestArrayPtr , align 8 ; <%struct.test*> [#uses=1]
2010-02-06 02:21:09 +01:00
%v2 = ptrtoint %struct.test * %v1 to i64 ; <i64> [#uses=1]
%v3 = sub i64 %v2 , ptrtoint ( [ 10 x %struct.test ] * @TestArray to i64 ) ; <i64> [#uses=1]
store i64 %v3 , i64 * %diff1 , align 8
2016-03-30 00:57:12 +02:00
ret i32 4 , !dbg !DILocation ( scope: !1 )
2010-02-06 02:21:09 +01:00
}
2016-04-06 01:37:08 +02:00
!llvm.dbg.cu = ! { !6 }
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-01 20:55:02 +02:00
declare void @llvm.dbg.declare ( metadata , metadata , metadata ) nounwind readnone
2010-02-06 02:21:09 +01:00
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-15 20:07:53 +01:00
!7 = ! { !1 }
2016-04-15 17:57:41 +02:00
!6 = distinct !DICompileUnit ( language: D W _ L A N G _ C 99 , producer: "clang version 3.0 (trunk 131941)" , isOptimized: true , emissionKind: F u l l D e b u g , file: !8 , enums: !9 , retainedTypes: !9 )
2015-07-31 20:58:39 +02:00
!0 = !DILocalVariable ( name: "c" , line: 2 , scope: !1 , file: !2 , type: !5 )
2016-04-15 17:57:41 +02:00
!1 = distinct !DISubprogram ( name: "main" , line: 1 , 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: !6 , scopeLine: 1 , file: !8 , scope: !2 , type: !3 )
2015-04-29 18:38:44 +02:00
!2 = !DIFile ( filename: "/d/j/debug-test.c" , directory: "/Volumes/Data/b" )
!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-15 20:07:53 +01:00
!4 = ! { !5 }
2015-04-29 18:38:44 +02: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 )
!8 = !DIFile ( filename: "/d/j/debug-test.c" , directory: "/Volumes/Data/b" )
2016-04-06 01:37:08 +02:00
!9 = ! { }
2014-12-16 08:08:19 +01:00
!llvm.module.flags = ! { !10 }
2015-03-03 18:24:31 +01:00
!10 = ! { i32 1 , !"Debug Info Version" , i32 3 }