2014-04-02 05:04:18 +08:00
|
|
|
; RUN: llc -O1 -filetype=obj -o - %s | llvm-dwarfdump -debug-dump=all - | FileCheck %s
|
|
|
|
; Generated with -O1 from:
|
|
|
|
; int f1();
|
|
|
|
; void f2(int*);
|
|
|
|
; int f3(int);
|
|
|
|
;
|
|
|
|
; int foo() {
|
|
|
|
; int i = 3;
|
|
|
|
; f3(i);
|
|
|
|
; i = 7;
|
|
|
|
; i = f1();
|
|
|
|
; f2(&i);
|
|
|
|
; return 0;
|
|
|
|
; }
|
|
|
|
;
|
|
|
|
; Test that we generate valid debug info for optimized code,
|
2014-04-09 22:47:27 +08:00
|
|
|
; particularly variables that are described as constants and passed
|
2014-04-02 05:04:18 +08:00
|
|
|
; by reference.
|
|
|
|
; rdar://problem/14874886
|
|
|
|
;
|
|
|
|
; CHECK: .debug_info contents:
|
|
|
|
; CHECK: DW_TAG_variable
|
|
|
|
; CHECK-NOT: DW_TAG
|
|
|
|
; CHECK: DW_AT_location [DW_FORM_data4] ([[LOC:.*]])
|
2014-06-14 06:18:23 +08:00
|
|
|
; CHECK-NOT: DW_TAG
|
|
|
|
; CHECK: DW_AT_name{{.*}}"i"
|
2014-04-02 05:04:18 +08:00
|
|
|
; CHECK: .debug_loc contents:
|
|
|
|
; CHECK: [[LOC]]:
|
2014-04-12 01:49:47 +08:00
|
|
|
; consts 0x00000003
|
2014-04-02 05:04:18 +08:00
|
|
|
; CHECK: Beginning address offset: 0x0000000000000{{.*}}
|
|
|
|
; CHECK: Ending address offset: [[C1:.*]]
|
2014-04-12 01:49:47 +08:00
|
|
|
; CHECK: Location description: 11 03
|
|
|
|
; consts 0x00000007
|
2014-04-02 05:04:18 +08:00
|
|
|
; CHECK: Beginning address offset: [[C1]]
|
|
|
|
; CHECK: Ending address offset: [[C2:.*]]
|
2014-04-12 01:49:47 +08:00
|
|
|
; CHECK: Location description: 11 07
|
2014-04-02 05:04:18 +08:00
|
|
|
; rax, piece 0x00000004
|
|
|
|
; CHECK: Beginning address offset: [[C2]]
|
|
|
|
; CHECK: Ending address offset: [[R1:.*]]
|
|
|
|
; CHECK: Location description: 50 93 04
|
2014-04-26 04:49:25 +08:00
|
|
|
; rdi+0
|
|
|
|
; CHECK: Beginning address offset: [[R1]]
|
|
|
|
; CHECK: Ending address offset: [[R2:.*]]
|
|
|
|
; CHECK: Location description: 75 00
|
2014-04-02 05:04:18 +08:00
|
|
|
;
|
|
|
|
target datalayout = "e-m:o-i64:64-f80:128-n8:16:32:64-S128"
|
|
|
|
target triple = "x86_64-apple-macosx10.9.0"
|
|
|
|
|
|
|
|
; Function Attrs: nounwind ssp uwtable
|
|
|
|
define i32 @foo() #0 {
|
|
|
|
entry:
|
|
|
|
%i = alloca i32, align 4
|
2014-10-04 04:01:09 +08:00
|
|
|
call void @llvm.dbg.value(metadata !14, i64 0, metadata !10, metadata !{metadata !"0x102"}), !dbg !15
|
2014-04-02 05:04:18 +08:00
|
|
|
%call = call i32 @f3(i32 3) #3, !dbg !16
|
2014-10-04 04:01:09 +08:00
|
|
|
call void @llvm.dbg.value(metadata !17, i64 0, metadata !10, metadata !{metadata !"0x102"}), !dbg !18
|
2014-04-02 05:04:18 +08:00
|
|
|
%call1 = call i32 (...)* @f1() #3, !dbg !19
|
2014-10-04 04:01:09 +08:00
|
|
|
call void @llvm.dbg.value(metadata !{i32 %call1}, i64 0, metadata !10, metadata !{metadata !"0x102"}), !dbg !19
|
2014-04-02 05:04:18 +08:00
|
|
|
store i32 %call1, i32* %i, align 4, !dbg !19, !tbaa !20
|
2014-10-04 04:01:09 +08:00
|
|
|
call void @llvm.dbg.value(metadata !{i32* %i}, i64 0, metadata !10, metadata !{metadata !"0x102"}), !dbg !24
|
2014-04-02 05:04:18 +08:00
|
|
|
call void @f2(i32* %i) #3, !dbg !24
|
|
|
|
ret i32 0, !dbg !25
|
|
|
|
}
|
|
|
|
|
|
|
|
declare i32 @f3(i32)
|
|
|
|
|
|
|
|
declare i32 @f1(...)
|
|
|
|
|
|
|
|
declare void @f2(i32*)
|
|
|
|
|
|
|
|
; Function Attrs: nounwind readnone
|
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) #2
|
2014-04-02 05:04:18 +08:00
|
|
|
|
|
|
|
attributes #0 = { nounwind ssp uwtable }
|
|
|
|
attributes #2 = { nounwind readnone }
|
|
|
|
attributes #3 = { nounwind }
|
|
|
|
|
|
|
|
!llvm.dbg.cu = !{!0}
|
|
|
|
!llvm.module.flags = !{!11, !12}
|
|
|
|
!llvm.ident = !{!13}
|
|
|
|
|
2014-10-04 04:01:09 +08:00
|
|
|
!0 = metadata !{metadata !"0x11\0012\00clang version 3.5.0 \001\00\000\00\001", metadata !1, metadata !2, metadata !2, metadata !3, metadata !2, metadata !2} ; [ DW_TAG_compile_unit ] [dbg-value-const-byref.c] [DW_LANG_C99]
|
2014-04-02 05:04:18 +08:00
|
|
|
!1 = metadata !{metadata !"dbg-value-const-byref.c", metadata !""}
|
|
|
|
!2 = metadata !{}
|
|
|
|
!3 = metadata !{metadata !4}
|
2014-10-04 04:01:09 +08:00
|
|
|
!4 = metadata !{metadata !"0x2e\00foo\00foo\00\005\000\001\000\006\000\001\005", metadata !1, metadata !5, metadata !6, null, i32 ()* @foo, null, null, metadata !9} ; [ DW_TAG_subprogram ] [line 5] [def] [foo]
|
|
|
|
!5 = metadata !{metadata !"0x29", metadata !1} ; [ DW_TAG_file_type ] [dbg-value-const-byref.c]
|
|
|
|
!6 = metadata !{metadata !"0x15\00\000\000\000\000\000\000", i32 0, null, null, metadata !7, null, null, null} ; [ DW_TAG_subroutine_type ] [line 0, size 0, align 0, offset 0] [from ]
|
2014-04-02 05:04:18 +08:00
|
|
|
!7 = metadata !{metadata !8}
|
2014-10-04 04:01:09 +08:00
|
|
|
!8 = metadata !{metadata !"0x24\00int\000\0032\0032\000\000\005", null, null} ; [ DW_TAG_base_type ] [int] [line 0, size 32, align 32, offset 0, enc DW_ATE_signed]
|
2014-04-02 05:04:18 +08:00
|
|
|
!9 = metadata !{metadata !10}
|
2014-10-04 04:01:09 +08:00
|
|
|
!10 = metadata !{metadata !"0x100\00i\006\000", metadata !4, metadata !5, metadata !8} ; [ DW_TAG_auto_variable ] [i] [line 6]
|
2014-04-02 05:04:18 +08:00
|
|
|
!11 = metadata !{i32 2, metadata !"Dwarf Version", i32 2}
|
2014-10-04 04:01:09 +08:00
|
|
|
!12 = metadata !{i32 1, metadata !"Debug Info Version", i32 2}
|
2014-04-02 05:04:18 +08:00
|
|
|
!13 = metadata !{metadata !"clang version 3.5.0 "}
|
|
|
|
!14 = metadata !{i32 3}
|
|
|
|
!15 = metadata !{i32 6, i32 0, metadata !4, null}
|
|
|
|
!16 = metadata !{i32 7, i32 0, metadata !4, null}
|
|
|
|
!17 = metadata !{i32 7}
|
2014-10-04 04:01:09 +08:00
|
|
|
!18 = metadata !{i32 8, i32 0, metadata !4, null}
|
2014-04-02 05:04:18 +08:00
|
|
|
!19 = metadata !{i32 9, i32 0, metadata !4, null}
|
|
|
|
!20 = metadata !{metadata !21, metadata !21, i64 0}
|
|
|
|
!21 = metadata !{metadata !"int", metadata !22, i64 0}
|
|
|
|
!22 = metadata !{metadata !"omnipotent char", metadata !23, i64 0}
|
|
|
|
!23 = metadata !{metadata !"Simple C/C++ TBAA"}
|
|
|
|
!24 = metadata !{i32 10, i32 0, metadata !4, null}
|
|
|
|
!25 = metadata !{i32 11, i32 0, metadata !4, null}
|