2013-07-30 02:12:58 +08:00
; RUN: opt < %s -mem2reg -S | FileCheck %s
2010-01-26 10:42:15 +08:00
2015-11-06 06:03:56 +08:00
define double @testfunc ( i32 %i , double %j ) nounwind ssp !dbg !1 {
2010-05-08 04:34:00 +08:00
entry:
%i_addr = alloca i32 ; <i32*> [#uses=2]
%j_addr = alloca double ; <double*> [#uses=2]
%retval = alloca double ; <double*> [#uses=2]
%0 = alloca double ; <double*> [#uses=2]
%"alloca point" = bitcast i32 0 to i32 ; <i32> [#uses=0]
2015-04-30 00:38:44 +08:00
call void @llvm.dbg.declare ( metadata i32 * %i_addr , metadata !0 , metadata !DIExpression ( ) ) , !dbg !8
2017-07-29 04:21:02 +08:00
; CHECK: call void @llvm.dbg.value(metadata i32 %i, metadata ![[IVAR:[0-9]*]], metadata {{.*}})
; CHECK: call void @llvm.dbg.value(metadata double %j, metadata ![[JVAR:[0-9]*]], metadata {{.*}})
2015-08-01 02:58:39 +08:00
; CHECK: ![[IVAR]] = !DILocalVariable(name: "i"
; CHECK: ![[JVAR]] = !DILocalVariable(name: "j"
2010-05-08 04:34:00 +08:00
store i32 %i , i32 * %i_addr
2015-04-30 00:38:44 +08:00
call void @llvm.dbg.declare ( metadata double * %j_addr , metadata !9 , metadata !DIExpression ( ) ) , !dbg !8
2010-05-08 04:34:00 +08:00
store double %j , double * %j_addr
2015-02-28 05:17:42 +08:00
%1 = load i32 , i32 * %i_addr , align 4 , !dbg !10 ; <i32> [#uses=1]
2010-05-08 04:34:00 +08:00
%2 = add nsw i32 %1 , 1 , !dbg !10 ; <i32> [#uses=1]
%3 = sitofp i32 %2 to double , !dbg !10 ; <double> [#uses=1]
2015-02-28 05:17:42 +08:00
%4 = load double , double * %j_addr , align 8 , !dbg !10 ; <double> [#uses=1]
2010-05-08 04:34:00 +08:00
%5 = fadd double %3 , %4 , !dbg !10 ; <double> [#uses=1]
store double %5 , double * %0 , align 8 , !dbg !10
2015-02-28 05:17:42 +08:00
%6 = load double , double * %0 , align 8 , !dbg !10 ; <double> [#uses=1]
2010-05-08 04:34:00 +08:00
store double %6 , double * %retval , align 8 , !dbg !10
br label %return , !dbg !10
return: ; preds = %entry
2015-02-28 05:17:42 +08:00
%retval1 = load double , double * %retval , !dbg !10 ; <double> [#uses=1]
2010-05-08 04:34:00 +08:00
ret double %retval1 , !dbg !10
2010-01-26 10:42:15 +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
2010-01-26 10:42:15 +08:00
2013-03-14 06:05:21 +08:00
!llvm.dbg.cu = ! { !3 }
2013-11-23 05:49:45 +08:00
!llvm.module.flags = ! { !14 }
2013-03-14 06:05:21 +08:00
2015-08-01 02:58:39 +08:00
!0 = !DILocalVariable ( name: "i" , line: 2 , arg: 1 , scope: !1 , file: !2 , type: !7 )
2016-04-15 23:57:41 +08:00
!1 = distinct !DISubprogram ( name: "testfunc" , linkageName: "testfunc" , line: 2 , isLocal: false , isDefinition: true , virtualIndex: 6 , isOptimized: false , unit: !3 , scopeLine: 2 , file: !12 , scope: !2 , type: !4 )
2015-04-30 00:38:44 +08:00
!2 = !DIFile ( filename: "testfunc.c" , directory: "/tmp" )
2016-04-15 23:57:41 +08:00
!3 = 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: !12 , enums: !13 , retainedTypes: !13 )
2015-04-30 00:38:44 +08:00
!4 = !DISubroutineType ( types: !5 )
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
!5 = ! { !6 , !7 , !6 }
2015-04-30 00:38:44 +08:00
!6 = !DIBasicType ( tag: D W _ T A G _ b a s e _ type , name: "double" , size: 64 , align: 64 , encoding: D W _ A T E _ float )
!7 = !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 = !DILocation ( line: 2 , scope: !1 )
2015-08-01 02:58:39 +08:00
!9 = !DILocalVariable ( name: "j" , line: 2 , arg: 2 , scope: !1 , file: !2 , type: !6 )
2015-04-30 00:38:44 +08:00
!10 = !DILocation ( line: 3 , scope: !11 )
!11 = distinct !DILexicalBlock ( line: 2 , column: 0 , file: !12 , scope: !1 )
!12 = !DIFile ( filename: "testfunc.c" , directory: "/tmp" )
2015-03-28 04:46:33 +08:00
!13 = ! { }
2015-03-04 01:24:31 +08:00
!14 = ! { i32 1 , !"Debug Info Version" , i32 3 }