2012-12-04 02:45:45 +08:00
|
|
|
; For http://llvm.org/bugs/show_bug.cgi?id=12942
|
|
|
|
; There are two CUs coming from /tmp/foo.c in this module. Make sure it doesn't
|
|
|
|
; blow llc up and produces something reasonable.
|
|
|
|
;
|
|
|
|
|
2013-04-11 03:53:26 +08:00
|
|
|
; REQUIRES: object-emission
|
|
|
|
|
2014-01-30 09:39:17 +08:00
|
|
|
; RUN: %llc_dwarf %s -o %t -filetype=obj -O0
|
2013-01-26 05:44:53 +08:00
|
|
|
; RUN: llvm-dwarfdump -debug-dump=info %t | FileCheck %s
|
2012-12-04 02:45:45 +08:00
|
|
|
|
|
|
|
; ModuleID = 'test.bc'
|
|
|
|
|
|
|
|
@str = private unnamed_addr constant [4 x i8] c"FOO\00"
|
|
|
|
@str1 = private unnamed_addr constant [6 x i8] c"Main!\00"
|
|
|
|
|
|
|
|
define void @foo() nounwind {
|
|
|
|
entry:
|
|
|
|
%puts = tail call i32 @puts(i8* getelementptr inbounds ([4 x i8]* @str, i32 0, i32 0)), !dbg !23
|
|
|
|
ret void, !dbg !25
|
|
|
|
}
|
|
|
|
|
|
|
|
declare i32 @puts(i8* nocapture) nounwind
|
|
|
|
|
|
|
|
define i32 @main(i32 %argc, i8** nocapture %argv) nounwind {
|
|
|
|
entry:
|
2014-10-03 06:15:31 +08:00
|
|
|
tail call void @llvm.dbg.value(metadata !{i32 %argc}, i64 0, metadata !21, metadata !{i32 786690}), !dbg !26
|
|
|
|
tail call void @llvm.dbg.value(metadata !{i8** %argv}, i64 0, metadata !22, metadata !{i32 786690}), !dbg !27
|
2012-12-04 02:45:45 +08:00
|
|
|
%puts = tail call i32 @puts(i8* getelementptr inbounds ([6 x i8]* @str1, i32 0, i32 0)), !dbg !28
|
|
|
|
tail call void @foo() nounwind, !dbg !30
|
|
|
|
ret i32 0, !dbg !31
|
|
|
|
}
|
|
|
|
|
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
|
2012-12-04 02:45:45 +08:00
|
|
|
|
|
|
|
!llvm.dbg.cu = !{!0, !9}
|
2013-11-23 05:49:45 +08:00
|
|
|
!llvm.module.flags = !{!33}
|
2012-12-04 02:45:45 +08:00
|
|
|
|
2014-10-03 06:15:31 +08:00
|
|
|
!0 = metadata !{i32 786449, metadata !32, i32 12, metadata !"clang version 3.2 (trunk 156513)", i1 true, metadata !"", i32 0, metadata !1, metadata !1, metadata !3, metadata !1, metadata !1, metadata !"", i32 1} ; [ DW_TAG_compile_unit ]
|
2014-02-04 09:23:52 +08:00
|
|
|
!1 = metadata !{}
|
2013-02-02 13:56:24 +08:00
|
|
|
!3 = metadata !{metadata !5}
|
2014-10-03 06:15:31 +08:00
|
|
|
!5 = metadata !{i32 786478, metadata !32, metadata !6, metadata !"foo", metadata !"foo", metadata !"", i32 5, metadata !7, i1 false, i1 true, i32 0, i32 0, null, i32 256, i1 true, void ()* @foo, null, null, metadata !1, i32 5} ; [ DW_TAG_subprogram ]
|
|
|
|
!6 = metadata !{i32 786473, metadata !32} ; [ DW_TAG_file_type ]
|
|
|
|
!7 = metadata !{i32 786453, i32 0, null, metadata !"", i32 0, i64 0, i64 0, i64 0, i32 0, null, metadata !8, i32 0, null, null, null} ; [ DW_TAG_subroutine_type ] [line 0, size 0, align 0, offset 0] [from ]
|
2012-12-04 02:45:45 +08:00
|
|
|
!8 = metadata !{null}
|
2014-10-03 06:15:31 +08:00
|
|
|
!9 = metadata !{i32 786449, metadata !32, i32 12, metadata !"clang version 3.2 (trunk 156513)", i1 true, metadata !"", i32 0, metadata !1, metadata !1, metadata !10, metadata !1, metadata !1, metadata !"", i32 1} ; [ DW_TAG_compile_unit ]
|
2013-02-02 13:56:24 +08:00
|
|
|
!10 = metadata !{metadata !12}
|
2014-10-03 06:15:31 +08:00
|
|
|
!12 = metadata !{i32 786478, metadata !32, metadata !6, metadata !"main", metadata !"main", metadata !"", i32 11, metadata !13, i1 false, i1 true, i32 0, i32 0, null, i32 256, i1 true, i32 (i32, i8**)* @main, null, null, metadata !19, i32 11} ; [ DW_TAG_subprogram ]
|
|
|
|
!13 = metadata !{i32 786453, i32 0, null, metadata !"", i32 0, i64 0, i64 0, i64 0, i32 0, null, metadata !14, i32 0, null, null, null} ; [ DW_TAG_subroutine_type ] [line 0, size 0, align 0, offset 0] [from ]
|
2012-12-04 02:45:45 +08:00
|
|
|
!14 = metadata !{metadata !15, metadata !15, metadata !16}
|
2014-10-03 06:15:31 +08:00
|
|
|
!15 = metadata !{i32 786468, null, null, metadata !"int", i32 0, i64 32, i64 32, i64 0, i32 0, i32 5} ; [ DW_TAG_base_type ]
|
|
|
|
!16 = metadata !{i32 786447, null, null, metadata !"", i32 0, i64 32, i64 32, i64 0, i32 0, metadata !17} ; [ DW_TAG_pointer_type ]
|
|
|
|
!17 = metadata !{i32 786447, null, null, metadata !"", i32 0, i64 32, i64 32, i64 0, i32 0, metadata !18} ; [ DW_TAG_pointer_type ]
|
|
|
|
!18 = metadata !{i32 786468, null, null, metadata !"char", i32 0, i64 8, i64 8, i64 0, i32 0, i32 6} ; [ DW_TAG_base_type ]
|
2014-05-15 05:52:46 +08:00
|
|
|
!19 = metadata !{metadata !21, metadata !22}
|
2014-10-03 06:15:31 +08:00
|
|
|
!21 = metadata !{i32 786689, metadata !12, metadata !"argc", metadata !6, i32 16777227, metadata !15, i32 0, i32 0} ; [ DW_TAG_arg_variable ]
|
|
|
|
!22 = metadata !{i32 786689, metadata !12, metadata !"argv", metadata !6, i32 33554443, metadata !16, i32 0, i32 0} ; [ DW_TAG_arg_variable ]
|
2012-12-04 02:45:45 +08:00
|
|
|
!23 = metadata !{i32 6, i32 3, metadata !24, null}
|
2014-10-03 06:15:31 +08:00
|
|
|
!24 = metadata !{i32 786443, metadata !32, metadata !5, i32 5, i32 16, i32 0} ; [ DW_TAG_lexical_block ]
|
2012-12-04 02:45:45 +08:00
|
|
|
!25 = metadata !{i32 7, i32 1, metadata !24, null}
|
|
|
|
!26 = metadata !{i32 11, i32 14, metadata !12, null}
|
|
|
|
!27 = metadata !{i32 11, i32 26, metadata !12, null}
|
|
|
|
!28 = metadata !{i32 12, i32 3, metadata !29, null}
|
2014-10-03 06:15:31 +08:00
|
|
|
!29 = metadata !{i32 786443, metadata !32, metadata !12, i32 11, i32 34, i32 0} ; [ DW_TAG_lexical_block ]
|
2012-12-04 02:45:45 +08:00
|
|
|
!30 = metadata !{i32 13, i32 3, metadata !29, null}
|
|
|
|
!31 = metadata !{i32 14, i32 3, metadata !29, null}
|
2013-03-18 05:13:55 +08:00
|
|
|
!32 = metadata !{metadata !"foo.c", metadata !"/tmp"}
|
2012-12-04 02:45:45 +08:00
|
|
|
|
2012-12-04 03:58:12 +08:00
|
|
|
; This test is simple to be cross platform (many targets don't yet have
|
|
|
|
; sufficiently good DWARF emission and/or dumping)
|
|
|
|
; CHECK: {{DW_TAG_compile_unit}}
|
|
|
|
; CHECK: {{foo\.c}}
|
2012-12-04 02:45:45 +08:00
|
|
|
|
2014-10-03 06:15:31 +08:00
|
|
|
!33 = metadata !{i32 1, metadata !"Debug Info Version", i32 1}
|