2014-03-21 03:16:16 +08:00
|
|
|
; RUN: llc %s -filetype=obj -O0 -mtriple=i386-unknown-linux-gnu -dwarf-version=4 -o %t
|
|
|
|
; RUN: llvm-dwarfdump %t | FileCheck %s
|
|
|
|
|
|
|
|
; From the code:
|
|
|
|
|
2014-06-10 05:53:47 +08:00
|
|
|
; debug-loc-offset1.cc
|
2014-03-21 03:16:16 +08:00
|
|
|
; int bar (int b) {
|
|
|
|
; return b+4;
|
|
|
|
; }
|
|
|
|
|
2014-06-10 05:53:47 +08:00
|
|
|
; debug-loc-offset2.cc
|
2014-03-21 03:16:16 +08:00
|
|
|
; struct A {
|
2014-06-10 05:53:47 +08:00
|
|
|
; int var;
|
|
|
|
; virtual char foo();
|
2014-03-21 03:16:16 +08:00
|
|
|
; };
|
|
|
|
|
2014-06-10 05:53:47 +08:00
|
|
|
; void baz(struct A a) {
|
|
|
|
; int z = 2;
|
|
|
|
; if (a.var > 2)
|
|
|
|
; z++;
|
|
|
|
; if (a.foo() == 'a')
|
|
|
|
; z++;
|
2014-03-21 03:16:16 +08:00
|
|
|
; }
|
|
|
|
|
|
|
|
; Compiled separately for i386-pc-linux-gnu and linked together.
|
|
|
|
; This ensures that we have multiple compile units so that we can verify that
|
|
|
|
; debug_loc entries are relative to the low_pc of the CU. The loc entry for
|
|
|
|
; the byval argument in foo.cpp is in the second CU and so should have
|
|
|
|
; an offset relative to that CU rather than from the beginning of the text
|
|
|
|
; section.
|
|
|
|
|
|
|
|
; Checking that we have two compile units with two sets of high/lo_pc.
|
|
|
|
; CHECK: .debug_info contents
|
|
|
|
; CHECK: DW_TAG_compile_unit
|
|
|
|
; CHECK: DW_AT_low_pc
|
|
|
|
; CHECK: DW_AT_high_pc
|
|
|
|
|
|
|
|
; CHECK: DW_TAG_compile_unit
|
|
|
|
; CHECK: DW_AT_low_pc
|
|
|
|
; CHECK: DW_AT_high_pc
|
|
|
|
|
|
|
|
; CHECK: DW_TAG_subprogram
|
2014-05-24 05:11:46 +08:00
|
|
|
; CHECK-NOT: DW_TAG
|
2014-06-10 05:53:47 +08:00
|
|
|
; CHECK: DW_AT_MIPS_linkage_name [DW_FORM_strp]{{.*}}"_Z3baz1A"
|
2014-05-24 05:11:46 +08:00
|
|
|
; CHECK-NOT: {{DW_TAG|NULL}}
|
2014-03-21 03:16:16 +08:00
|
|
|
; CHECK: DW_TAG_formal_parameter
|
2014-06-14 06:18:23 +08:00
|
|
|
; CHECK-NOT: DW_TAG
|
2014-03-21 03:16:16 +08:00
|
|
|
; CHECK: DW_AT_location [DW_FORM_sec_offset] (0x00000000)
|
2014-06-14 06:18:23 +08:00
|
|
|
; CHECK-NOT: DW_TAG
|
|
|
|
; CHECK: DW_AT_name [DW_FORM_strp]{{.*}}"a"
|
2014-06-10 05:53:47 +08:00
|
|
|
|
|
|
|
; CHECK: DW_TAG_variable
|
|
|
|
; CHECK: DW_AT_location [DW_FORM_exprloc]
|
2014-03-21 03:16:16 +08:00
|
|
|
; CHECK-NOT: DW_AT_location
|
|
|
|
|
|
|
|
; CHECK: .debug_loc contents:
|
|
|
|
; CHECK: 0x00000000: Beginning address offset: 0x0000000000000000
|
2014-06-10 05:53:47 +08:00
|
|
|
; CHECK: Ending address offset: 0x000000000000001a
|
2014-03-21 03:16:16 +08:00
|
|
|
|
2014-06-10 05:53:47 +08:00
|
|
|
%struct.A = type { i32 (...)**, i32 }
|
2014-03-21 03:16:16 +08:00
|
|
|
|
|
|
|
; Function Attrs: nounwind
|
|
|
|
define i32 @_Z3bari(i32 %b) #0 {
|
|
|
|
entry:
|
|
|
|
%b.addr = alloca i32, align 4
|
|
|
|
store i32 %b, i32* %b.addr, align 4
|
2014-10-04 04:01:09 +08:00
|
|
|
call void @llvm.dbg.declare(metadata !{i32* %b.addr}, metadata !21, metadata !{metadata !"0x102"}), !dbg !22
|
2014-06-10 05:53:47 +08:00
|
|
|
%0 = load i32* %b.addr, align 4, !dbg !23
|
|
|
|
%add = add nsw i32 %0, 4, !dbg !23
|
|
|
|
ret i32 %add, !dbg !23
|
2014-03-21 03:16:16 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
; 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.declare(metadata, metadata, metadata) #1
|
2014-03-21 03:16:16 +08:00
|
|
|
|
2014-06-10 05:53:47 +08:00
|
|
|
define void @_Z3baz1A(%struct.A* %a) #2 {
|
2014-03-21 03:16:16 +08:00
|
|
|
entry:
|
2014-06-10 05:53:47 +08:00
|
|
|
%z = alloca i32, align 4
|
2014-10-04 04:01:09 +08:00
|
|
|
call void @llvm.dbg.declare(metadata !{%struct.A* %a}, metadata !24, metadata !{metadata !"0x102"}), !dbg !25
|
|
|
|
call void @llvm.dbg.declare(metadata !{i32* %z}, metadata !26, metadata !{metadata !"0x102"}), !dbg !27
|
2014-06-10 05:53:47 +08:00
|
|
|
store i32 2, i32* %z, align 4, !dbg !27
|
|
|
|
%var = getelementptr inbounds %struct.A* %a, i32 0, i32 1, !dbg !28
|
|
|
|
%0 = load i32* %var, align 4, !dbg !28
|
|
|
|
%cmp = icmp sgt i32 %0, 2, !dbg !28
|
|
|
|
br i1 %cmp, label %if.then, label %if.end, !dbg !28
|
|
|
|
|
|
|
|
if.then: ; preds = %entry
|
|
|
|
%1 = load i32* %z, align 4, !dbg !30
|
|
|
|
%inc = add nsw i32 %1, 1, !dbg !30
|
|
|
|
store i32 %inc, i32* %z, align 4, !dbg !30
|
|
|
|
br label %if.end, !dbg !30
|
|
|
|
|
|
|
|
if.end: ; preds = %if.then, %entry
|
|
|
|
%call = call signext i8 @_ZN1A3fooEv(%struct.A* %a), !dbg !31
|
|
|
|
%conv = sext i8 %call to i32, !dbg !31
|
|
|
|
%cmp1 = icmp eq i32 %conv, 97, !dbg !31
|
|
|
|
br i1 %cmp1, label %if.then2, label %if.end4, !dbg !31
|
|
|
|
|
|
|
|
if.then2: ; preds = %if.end
|
|
|
|
%2 = load i32* %z, align 4, !dbg !33
|
|
|
|
%inc3 = add nsw i32 %2, 1, !dbg !33
|
|
|
|
store i32 %inc3, i32* %z, align 4, !dbg !33
|
|
|
|
br label %if.end4, !dbg !33
|
|
|
|
|
|
|
|
if.end4: ; preds = %if.then2, %if.end
|
|
|
|
ret void, !dbg !34
|
2014-03-21 03:16:16 +08:00
|
|
|
}
|
|
|
|
|
2014-06-10 05:53:47 +08:00
|
|
|
declare signext i8 @_ZN1A3fooEv(%struct.A*) #2
|
|
|
|
|
2014-03-21 03:16:16 +08:00
|
|
|
attributes #0 = { nounwind "less-precise-fpmad"="false" "no-frame-pointer-elim"="true" "no-frame-pointer-elim-non-leaf" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "stack-protector-buffer-size"="8" "unsafe-fp-math"="false" "use-soft-float"="false" }
|
|
|
|
attributes #1 = { nounwind readnone }
|
2014-06-10 05:53:47 +08:00
|
|
|
attributes #2 = { "less-precise-fpmad"="false" "no-frame-pointer-elim"="true" "no-frame-pointer-elim-non-leaf" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "stack-protector-buffer-size"="8" "unsafe-fp-math"="false" "use-soft-float"="false" }
|
2014-03-21 03:16:16 +08:00
|
|
|
|
|
|
|
!llvm.dbg.cu = !{!0, !9}
|
2014-06-10 05:53:47 +08:00
|
|
|
!llvm.module.flags = !{!18, !19}
|
|
|
|
!llvm.ident = !{!20, !20}
|
2014-03-21 03:16:16 +08:00
|
|
|
|
2014-10-04 04:01:09 +08:00
|
|
|
!0 = metadata !{metadata !"0x11\004\00clang version 3.5.0 (210479)\000\00\000\00\001", metadata !1, metadata !2, metadata !2, metadata !3, metadata !2, metadata !2} ; [ DW_TAG_compile_unit ] [/llvm_cmake_gcc/debug-loc-offset1.cc] [DW_LANG_C_plus_plus]
|
2014-06-10 05:53:47 +08:00
|
|
|
!1 = metadata !{metadata !"debug-loc-offset1.cc", metadata !"/llvm_cmake_gcc"}
|
2014-03-21 03:16:16 +08:00
|
|
|
!2 = metadata !{}
|
|
|
|
!3 = metadata !{metadata !4}
|
2014-10-04 04:01:09 +08:00
|
|
|
!4 = metadata !{metadata !"0x2e\00bar\00bar\00_Z3bari\001\000\001\000\006\00256\000\001", metadata !1, metadata !5, metadata !6, null, i32 (i32)* @_Z3bari, null, null, metadata !2} ; [ DW_TAG_subprogram ] [line 1] [def] [bar]
|
|
|
|
!5 = metadata !{metadata !"0x29", metadata !1} ; [ DW_TAG_file_type ] [/llvm_cmake_gcc/debug-loc-offset1.cc]
|
|
|
|
!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-03-21 03:16:16 +08:00
|
|
|
!7 = metadata !{metadata !8, 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]
|
|
|
|
!9 = metadata !{metadata !"0x11\004\00clang version 3.5.0 (210479)\000\00\000\00\001", metadata !10, metadata !2, metadata !11, metadata !13, metadata !2, metadata !2} ; [ DW_TAG_compile_unit ] [/llvm_cmake_gcc/debug-loc-offset2.cc] [DW_LANG_C_plus_plus]
|
2014-06-10 05:53:47 +08:00
|
|
|
!10 = metadata !{metadata !"debug-loc-offset2.cc", metadata !"/llvm_cmake_gcc"}
|
2014-03-21 03:16:16 +08:00
|
|
|
!11 = metadata !{metadata !12}
|
2014-10-04 04:01:09 +08:00
|
|
|
!12 = metadata !{metadata !"0x13\00A\001\000\000\000\004\000", metadata !10, null, null, null, null, null, metadata !"_ZTS1A"} ; [ DW_TAG_structure_type ] [A] [line 1, size 0, align 0, offset 0] [decl] [from ]
|
2014-06-10 05:53:47 +08:00
|
|
|
!13 = metadata !{metadata !14}
|
2014-10-04 04:01:09 +08:00
|
|
|
!14 = metadata !{metadata !"0x2e\00baz\00baz\00_Z3baz1A\006\000\001\000\006\00256\000\006", metadata !10, metadata !15, metadata !16, null, void (%struct.A*)* @_Z3baz1A, null, null, metadata !2} ; [ DW_TAG_subprogram ] [line 6] [def] [baz]
|
|
|
|
!15 = metadata !{metadata !"0x29", metadata !10} ; [ DW_TAG_file_type ] [/llvm_cmake_gcc/debug-loc-offset2.cc]
|
|
|
|
!16 = metadata !{metadata !"0x15\00\000\000\000\000\000\000", i32 0, null, null, metadata !17, null, null, null} ; [ DW_TAG_subroutine_type ] [line 0, size 0, align 0, offset 0] [from ]
|
2014-06-10 05:53:47 +08:00
|
|
|
!17 = metadata !{null, metadata !12}
|
|
|
|
!18 = metadata !{i32 2, metadata !"Dwarf Version", i32 4}
|
2014-10-04 04:01:09 +08:00
|
|
|
!19 = metadata !{i32 2, metadata !"Debug Info Version", i32 2}
|
2014-06-10 05:53:47 +08:00
|
|
|
!20 = metadata !{metadata !"clang version 3.5.0 (210479)"}
|
2014-10-04 04:01:09 +08:00
|
|
|
!21 = metadata !{metadata !"0x101\00b\0016777217\000", metadata !4, metadata !5, metadata !8} ; [ DW_TAG_arg_variable ] [b] [line 1]
|
2014-06-10 05:53:47 +08:00
|
|
|
!22 = metadata !{i32 1, i32 0, metadata !4, null}
|
|
|
|
!23 = metadata !{i32 2, i32 0, metadata !4, null}
|
2014-10-04 04:01:09 +08:00
|
|
|
!24 = metadata !{metadata !"0x101\00a\0016777222\008192", metadata !14, metadata !15, metadata !"_ZTS1A"} ; [ DW_TAG_arg_variable ] [a] [line 6]
|
2014-06-10 05:53:47 +08:00
|
|
|
!25 = metadata !{i32 6, i32 0, metadata !14, null}
|
2014-10-04 04:01:09 +08:00
|
|
|
!26 = metadata !{metadata !"0x100\00z\007\000", metadata !14, metadata !15, metadata !8} ; [ DW_TAG_auto_variable ] [z] [line 7]
|
2014-06-10 05:53:47 +08:00
|
|
|
!27 = metadata !{i32 7, i32 0, metadata !14, null}
|
2014-10-04 04:01:09 +08:00
|
|
|
!28 = metadata !{i32 8, i32 0, metadata !29, null}
|
|
|
|
!29 = metadata !{metadata !"0xb\008\000\000", metadata !10, metadata !14} ; [ DW_TAG_lexical_block ] [/llvm_cmake_gcc/debug-loc-offset2.cc]
|
2014-06-10 05:53:47 +08:00
|
|
|
!30 = metadata !{i32 9, i32 0, metadata !29, null}
|
|
|
|
!31 = metadata !{i32 10, i32 0, metadata !32, null}
|
2014-10-04 04:01:09 +08:00
|
|
|
!32 = metadata !{metadata !"0xb\0010\000\000", metadata !10, metadata !14} ; [ DW_TAG_lexical_block ] [/llvm_cmake_gcc/debug-loc-offset2.cc]
|
2014-06-10 05:53:47 +08:00
|
|
|
!33 = metadata !{i32 11, i32 0, metadata !32, null}
|
|
|
|
!34 = metadata !{i32 12, i32 0, metadata !14, null}
|