2013-07-30 02:12:58 +08:00
; RUN: llc -mtriple=x86_64-apple-darwin < %s | FileCheck %s
; RUN: llc -mtriple=x86_64-apple-darwin -regalloc=basic < %s | FileCheck %s
2010-05-28 00:47:30 +08:00
; Test to check separate label for inlined function argument.
2010-06-02 07:01:43 +08:00
define i32 @foo ( i32 %y ) nounwind optsize ssp {
2010-05-28 00:47:30 +08:00
entry:
2014-10-04 04:01:09 +08:00
tail call void @llvm.dbg.value ( metadata ! { i32 %y } , i64 0 , metadata !0 , metadata ! { metadata !"0x102" } )
2010-06-02 07:01:43 +08:00
%0 = tail call i32 ( . . . ) * @zoo ( i32 %y ) nounwind , !dbg !9 ; <i32> [#uses=1]
ret i32 %0 , !dbg !9
}
declare i32 @zoo ( . . . )
2010-05-28 00:47:30 +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.value ( metadata , i64 , metadata , metadata ) nounwind readnone
2010-06-02 07:01:43 +08:00
define i32 @bar ( i32 %x ) nounwind optsize ssp {
entry:
2014-10-04 04:01:09 +08:00
tail call void @llvm.dbg.value ( metadata ! { i32 %x } , i64 0 , metadata !7 , metadata ! { metadata !"0x102" } )
tail call void @llvm.dbg.value ( metadata !11 , i64 0 , metadata !0 , metadata ! { metadata !"0x102" } ) nounwind
2010-06-02 07:01:43 +08:00
%0 = tail call i32 ( . . . ) * @zoo ( i32 1 ) nounwind , !dbg !12 ; <i32> [#uses=1]
%1 = add nsw i32 %0 , %x , !dbg !13 ; <i32> [#uses=1]
ret i32 %1 , !dbg !13
2010-05-28 00:47:30 +08:00
}
2013-03-08 08:23:31 +08:00
!llvm.dbg.cu = ! { !3 }
2013-11-23 05:49:45 +08:00
!llvm.module.flags = ! { !20 }
2010-05-28 00:47:30 +08:00
2014-10-04 04:01:09 +08:00
!0 = metadata ! { metadata !"0x101\00y\002\000" , metadata !1 , metadata !2 , metadata !6 } ; [ DW_TAG_arg_variable ]
!1 = metadata ! { metadata !"0x2e\00foo\00foo\00foo\002\000\001\000\006\000\001\002" , metadata !18 , metadata !2 , metadata !4 , null , i32 ( i32 ) * @foo , null , null , metadata !15 } ; [ DW_TAG_subprogram ]
!2 = metadata ! { metadata !"0x29" , metadata !18 } ; [ DW_TAG_file_type ]
!3 = metadata ! { metadata !"0x11\001\004.2.1 (Based on Apple Inc. build 5658) (LLVM build)\001\00\000\00\001" , metadata !18 , metadata !19 , metadata !19 , metadata !17 , null , null } ; [ DW_TAG_compile_unit ]
!4 = metadata ! { metadata !"0x15\00\000\000\000\000\000\000" , metadata !18 , metadata !2 , null , metadata !5 , null , null , null } ; [ DW_TAG_subroutine_type ] [line 0, size 0, align 0, offset 0] [from ]
2010-06-02 07:01:43 +08:00
!5 = metadata ! { metadata !6 , metadata !6 }
2014-10-04 04:01:09 +08:00
!6 = metadata ! { metadata !"0x24\00int\000\0032\0032\000\000\005" , metadata !18 , metadata !2 } ; [ DW_TAG_base_type ]
!7 = metadata ! { metadata !"0x101\00x\006\000" , metadata !8 , metadata !2 , metadata !6 } ; [ DW_TAG_arg_variable ]
!8 = metadata ! { metadata !"0x2e\00bar\00bar\00bar\006\000\001\000\006\000\001\006" , metadata !18 , metadata !2 , metadata !4 , null , i32 ( i32 ) * @bar , null , null , metadata !16 } ; [ DW_TAG_subprogram ]
2010-06-02 07:01:43 +08:00
!9 = metadata ! { i32 3 , i32 0 , metadata !10 , null }
2014-10-04 04:01:09 +08:00
!10 = metadata ! { metadata !"0xb\002\000\000" , metadata !18 , metadata !1 } ; [ DW_TAG_lexical_block ]
2010-06-02 07:01:43 +08:00
!11 = metadata ! { i32 1 }
!12 = metadata ! { i32 3 , i32 0 , metadata !10 , metadata !13 }
!13 = metadata ! { i32 7 , i32 0 , metadata !14 , null }
2014-10-04 04:01:09 +08:00
!14 = metadata ! { metadata !"0xb\006\000\000" , metadata !18 , metadata !8 } ; [ DW_TAG_lexical_block ]
2013-03-18 05:13:55 +08:00
!15 = metadata ! { metadata !0 }
!16 = metadata ! { metadata !7 }
!17 = metadata ! { metadata !1 , metadata !8 }
!18 = metadata ! { metadata !"f.c" , metadata !"/tmp" }
2013-07-30 02:12:58 +08:00
!19 = metadata ! { i32 0 }
2010-05-28 00:47:30 +08:00
2011-01-13 07:36:21 +08:00
;CHECK: DEBUG_VALUE: bar:x <- E
;CHECK: Ltmp
2013-06-16 00:02:44 +08:00
;CHECK: DEBUG_VALUE: foo:y <- 1{{$}}
2014-10-04 04:01:09 +08:00
!20 = metadata ! { i32 1 , metadata !"Debug Info Version" , i32 2 }