llvm.org GIT mirror llvm / ff715b2
PR14566: Debug Info: Removing top level lexical blocks This adds support for LLVM to accept metadata that doesn't include a top level lexical block in a function. Specifically LLVM couldn't handle this when there were file changes relating to these blocks. I've updated a few test cases to ensure other functionality (such as inlining) isn't affected by this change, but haven't pervasively updated all the test cases. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@173592 91177308-0d34-0410-b5e6-96231b3b80d8 David Blaikie 7 years ago
4 changed file(s) with 83 addition(s) and 32 deletion(s). Raw diff Collapse all Expand all
733733 class DILexicalBlockFile : public DIScope {
734734 public:
735735 explicit DILexicalBlockFile(const MDNode *N = 0) : DIScope(N) {}
736 DIScope getContext() const { return getScope().getContext(); }
736 DIScope getContext() const { if (getScope().isSubprogram()) return getScope(); return getScope().getContext(); }
737737 unsigned getLineNumber() const { return getScope().getLineNumber(); }
738738 unsigned getColumnNumber() const { return getScope().getColumnNumber(); }
739739 StringRef getDirectory() const {
55 ; It's a lot easier to do this in two passes than in one.
66 ; PR14471
77
8 ; LLVM IR generated using: clang -emit-llvm -S
8 ; LLVM IR generated using: clang -emit-llvm -S -g
99 ; (with the Clang part of this patch applied).
1010 ;
1111 ; class C
4343 %retval = alloca i32, align 4
4444 %instance_C = alloca %class.C, align 4
4545 store i32 0, i32* %retval
46 call void @llvm.dbg.declare(metadata !{%class.C* %instance_C}, metadata !29), !dbg !31
47 %d = getelementptr inbounds %class.C* %instance_C, i32 0, i32 0, !dbg !32
48 store i32 8, i32* %d, align 4, !dbg !32
49 %0 = load i32* @_ZN1C1cE, align 4, !dbg !33
50 ret i32 %0, !dbg !33
46 call void @llvm.dbg.declare(metadata !{%class.C* %instance_C}, metadata !29), !dbg !30
47 %d = getelementptr inbounds %class.C* %instance_C, i32 0, i32 0, !dbg !31
48 store i32 8, i32* %d, align 4, !dbg !31
49 %0 = load i32* @_ZN1C1cE, align 4, !dbg !32
50 ret i32 %0, !dbg !32
5151 }
5252
5353 declare void @llvm.dbg.declare(metadata, metadata) nounwind readnone
5959 !2 = metadata !{i32 0}
6060 !3 = metadata !{metadata !4}
6161 !4 = metadata !{metadata !5}
62 !5 = metadata !{i32 786478, i32 0, metadata !6, metadata !"main", metadata !"main", metadata !"", metadata !6, i32 22, metadata !7, i1 false, i1 true, i32 0, i32 0, null, i32 256, i1 false, i32 ()* @main, null, null, metadata !1, i32 23} ; [ DW_TAG_subprogram ] [line 22] [def] [scope 23] [main]
62 !5 = metadata !{i32 786478, i32 0, metadata !6, metadata !"main", metadata !"main", metadata !"", metadata !6, i32 18, metadata !7, i1 false, i1 true, i32 0, i32 0, null, i32 256, i1 false, i32 ()* @main, null, null, metadata !1, i32 23} ; [ DW_TAG_subprogram ] [line 18] [def] [scope 23] [main]
6363 !6 = metadata !{i32 786473, metadata !"/usr/local/google/home/blaikie/Development/llvm/src/tools/clang/test/CodeGenCXX/debug-info-static-member.cpp", metadata !"/home/blaikie/local/Development/llvm/build/clang/x86-64/Debug/llvm", null} ; [ DW_TAG_file_type ]
6464 !7 = metadata !{i32 786453, i32 0, metadata !"", i32 0, i32 0, i64 0, i64 0, i64 0, i32 0, null, metadata !8, i32 0, i32 0} ; [ DW_TAG_subroutine_type ] [line 0, size 0, align 0, offset 0] [from ]
6565 !8 = metadata !{metadata !9}
6666 !9 = metadata !{i32 786468, null, metadata !"int", null, i32 0, i64 32, i64 32, i64 0, i32 0, i32 5} ; [ DW_TAG_base_type ] [int] [line 0, size 32, align 32, offset 0, enc DW_ATE_signed]
6767 !10 = metadata !{metadata !11}
6868 !11 = metadata !{metadata !12, metadata !27, metadata !28}
69 !12 = metadata !{i32 786484, i32 0, metadata !13, metadata !"a", metadata !"a", metadata !"_ZN1C1aE", metadata !6, i32 18, metadata !9, i32 0, i32 1, i32* @_ZN1C1aE, metadata !15} ; [ DW_TAG_variable ] [a] [line 18] [def]
70 !13 = metadata !{i32 786434, null, metadata !"C", metadata !6, i32 5, i64 32, i64 32, i32 0, i32 0, null, metadata !14, i32 0, null, null} ; [ DW_TAG_class_type ] [C] [line 5, size 32, align 32, offset 0] [from ]
69 !12 = metadata !{i32 786484, i32 0, metadata !13, metadata !"a", metadata !"a", metadata !"_ZN1C1aE", metadata !6, i32 14, metadata !9, i32 0, i32 1, i32* @_ZN1C1aE, metadata !15} ; [ DW_TAG_variable ] [a] [line 14] [def]
70 !13 = metadata !{i32 786434, null, metadata !"C", metadata !6, i32 1, i64 32, i64 32, i32 0, i32 0, null, metadata !14, i32 0, null, null} ; [ DW_TAG_class_type ] [C] [line 1, size 32, align 32, offset 0] [from ]
7171 !14 = metadata !{metadata !15, metadata !16, metadata !19, metadata !20, metadata !23, metadata !24, metadata !26}
72 !15 = metadata !{i32 786445, metadata !13, metadata !"a", metadata !6, i32 7, i64 0, i64 0, i64 0, i32 4097, metadata !9, null} ; [ DW_TAG_member ] [a] [line 7, size 0, align 0, offset 0] [private] [static] [from int]
73 !16 = metadata !{i32 786445, metadata !13, metadata !"const_a", metadata !6, i32 8, i64 0, i64 0, i64 0, i32 4097, metadata !17, i1 true} ; [ DW_TAG_member ] [const_a] [line 8, size 0, align 0, offset 0] [private] [static] [from ]
72 !15 = metadata !{i32 786445, metadata !13, metadata !"a", metadata !6, i32 3, i64 0, i64 0, i64 0, i32 4097, metadata !9, null} ; [ DW_TAG_member ] [a] [line 3, size 0, align 0, offset 0] [private] [static] [from int]
73 !16 = metadata !{i32 786445, metadata !13, metadata !"const_a", metadata !6, i32 4, i64 0, i64 0, i64 0, i32 4097, metadata !17, i1 true} ; [ DW_TAG_member ] [const_a] [line 4, size 0, align 0, offset 0] [private] [static] [from ]
7474 !17 = metadata !{i32 786470, null, metadata !"", null, i32 0, i64 0, i64 0, i64 0, i32 0, metadata !18} ; [ DW_TAG_const_type ] [line 0, size 0, align 0, offset 0] [from bool]
7575 !18 = metadata !{i32 786468, null, metadata !"bool", null, i32 0, i64 8, i64 8, i64 0, i32 0, i32 2} ; [ DW_TAG_base_type ] [bool] [line 0, size 8, align 8, offset 0, enc DW_ATE_boolean]
76 !19 = metadata !{i32 786445, metadata !13, metadata !"b", metadata !6, i32 10, i64 0, i64 0, i64 0, i32 4098, metadata !9, null} ; [ DW_TAG_member ] [b] [line 10, size 0, align 0, offset 0] [protected] [static] [from int]
77 !20 = metadata !{i32 786445, metadata !13, metadata !"const_b", metadata !6, i32 11, i64 0, i64 0, i64 0, i32 4098, metadata !21, float 0x40091EB860000000} ; [ DW_TAG_member ] [const_b] [line 11, size 0, align 0, offset 0] [protected] [static] [from ]
76 !19 = metadata !{i32 786445, metadata !13, metadata !"b", metadata !6, i32 6, i64 0, i64 0, i64 0, i32 4098, metadata !9, null} ; [ DW_TAG_member ] [b] [line 6, size 0, align 0, offset 0] [protected] [static] [from int]
77 !20 = metadata !{i32 786445, metadata !13, metadata !"const_b", metadata !6, i32 7, i64 0, i64 0, i64 0, i32 4098, metadata !21, float 0x40091EB860000000} ; [ DW_TAG_member ] [const_b] [line 7, size 0, align 0, offset 0] [protected] [static] [from ]
7878 !21 = metadata !{i32 786470, null, metadata !"", null, i32 0, i64 0, i64 0, i64 0, i32 0, metadata !22} ; [ DW_TAG_const_type ] [line 0, size 0, align 0, offset 0] [from float]
7979 !22 = metadata !{i32 786468, null, metadata !"float", null, i32 0, i64 32, i64 32, i64 0, i32 0, i32 4} ; [ DW_TAG_base_type ] [float] [line 0, size 32, align 32, offset 0, enc DW_ATE_float]
80 !23 = metadata !{i32 786445, metadata !13, metadata !"c", metadata !6, i32 13, i64 0, i64 0, i64 0, i32 4096, metadata !9, null} ; [ DW_TAG_member ] [c] [line 13, size 0, align 0, offset 0] [static] [from int]
81 !24 = metadata !{i32 786445, metadata !13, metadata !"const_c", metadata !6, i32 14, i64 0, i64 0, i64 0, i32 4096, metadata !25, i32 18} ; [ DW_TAG_member ] [const_c] [line 14, size 0, align 0, offset 0] [static] [from ]
80 !23 = metadata !{i32 786445, metadata !13, metadata !"c", metadata !6, i32 9, i64 0, i64 0, i64 0, i32 4096, metadata !9, null} ; [ DW_TAG_member ] [c] [line 9, size 0, align 0, offset 0] [static] [from int]
81 !24 = metadata !{i32 786445, metadata !13, metadata !"const_c", metadata !6, i32 10, i64 0, i64 0, i64 0, i32 4096, metadata !25, i32 18} ; [ DW_TAG_member ] [const_c] [line 10, size 0, align 0, offset 0] [static] [from ]
8282 !25 = metadata !{i32 786470, null, metadata !"", null, i32 0, i64 0, i64 0, i64 0, i32 0, metadata !9} ; [ DW_TAG_const_type ] [line 0, size 0, align 0, offset 0] [from int]
83 !26 = metadata !{i32 786445, metadata !13, metadata !"d", metadata !6, i32 15, i64 32, i64 32, i64 0, i32 0, metadata !9} ; [ DW_TAG_member ] [d] [line 15, size 32, align 32, offset 0] [from int]
84 !27 = metadata !{i32 786484, i32 0, metadata !13, metadata !"b", metadata !"b", metadata !"_ZN1C1bE", metadata !6, i32 19, metadata !9, i32 0, i32 1, i32* @_ZN1C1bE, metadata !19} ; [ DW_TAG_variable ] [b] [line 19] [def]
85 !28 = metadata !{i32 786484, i32 0, metadata !13, metadata !"c", metadata !"c", metadata !"_ZN1C1cE", metadata !6, i32 20, metadata !9, i32 0, i32 1, i32* @_ZN1C1cE, metadata !23} ; [ DW_TAG_variable ] [c] [line 20] [def]
86 !29 = metadata !{i32 786688, metadata !30, metadata !"instance_C", metadata !6, i32 24, metadata !13, i32 0, i32 0} ; [ DW_TAG_auto_variable ] [instance_C] [line 24]
87 !30 = metadata !{i32 786443, metadata !5, i32 23, i32 0, metadata !6, i32 0} ; [ DW_TAG_lexical_block ] [/home/blaikie/local/Development/llvm/build/clang/x86-64/Debug/llvm//usr/local/google/home/blaikie/Development/llvm/src/tools/clang/test/CodeGenCXX/debug-info-static-member.cpp]
88 !31 = metadata !{i32 24, i32 0, metadata !30, null}
89 !32 = metadata !{i32 25, i32 0, metadata !30, null}
90 !33 = metadata !{i32 26, i32 0, metadata !30, null}
83 !26 = metadata !{i32 786445, metadata !13, metadata !"d", metadata !6, i32 11, i64 32, i64 32, i64 0, i32 0, metadata !9} ; [ DW_TAG_member ] [d] [line 11, size 32, align 32, offset 0] [from int]
84 !27 = metadata !{i32 786484, i32 0, metadata !13, metadata !"b", metadata !"b", metadata !"_ZN1C1bE", metadata !6, i32 15, metadata !9, i32 0, i32 1, i32* @_ZN1C1bE, metadata !19} ; [ DW_TAG_variable ] [b] [line 15] [def]
85 !28 = metadata !{i32 786484, i32 0, metadata !13, metadata !"c", metadata !"c", metadata !"_ZN1C1cE", metadata !6, i32 16, metadata !9, i32 0, i32 1, i32* @_ZN1C1cE, metadata !23} ; [ DW_TAG_variable ] [c] [line 16] [def]
86 !29 = metadata !{i32 786688, metadata !5, metadata !"instance_C", metadata !6, i32 20, metadata !13, i32 0, i32 0} ; [ DW_TAG_auto_variable ] [instance_C] [line 20]
87 !30 = metadata !{i32 20, i32 0, metadata !5, null}
88 !31 = metadata !{i32 21, i32 0, metadata !5, null}
89 !32 = metadata !{i32 22, i32 0, metadata !5, null}
9190 ; PRESENT verifies that static member declarations have these attributes:
9291 ; external, declaration, accessibility, and either DW_AT_MIPS_linkage_name
9392 ; (for variables) or DW_AT_const_value (for constants).
3838 ; ARGUMENT: {{.*Abbrev.*DW_TAG_formal_parameter}}
3939 ; ARGUMENT-NOT: {{.*Abbrev.*DW_TAG_formal_parameter}}
4040
41 !16 = metadata !{i32 786688, metadata !17, metadata !"local", metadata !6, i32 4, metadata !9, i32 0, i32 0} ; [ DW_TAG_auto_variable ]
41 !16 = metadata !{i32 786688, metadata !10, metadata !"local", metadata !6, i32 4, metadata !9, i32 0, i32 0} ; [ DW_TAG_auto_variable ]
4242
4343 ; Two DW_TAG_variable: one abstract and one inlined.
4444 ; VARIABLE: {{.*Abbrev.*DW_TAG_variable}}
4545 ; VARIABLE: {{.*Abbrev.*DW_TAG_variable}}
4646 ; VARIABLE-NOT: {{.*Abbrev.*DW_TAG_variable}}
4747
48 !17 = metadata !{i32 786443, metadata !10, i32 3, i32 35, metadata !6, i32 1} ; [ DW_TAG_lexical_block ]
4948 !18 = metadata !{i32 786689, metadata !10, metadata !"argument", metadata !6, i32 16777219, metadata !9, i32 0, metadata !19} ; [ DW_TAG_arg_variable ]
50 !19 = metadata !{i32 11, i32 10, metadata !20, null}
51 !20 = metadata !{i32 786443, metadata !5, i32 10, i32 12, metadata !6, i32 0} ; [ DW_TAG_lexical_block ]
49 !19 = metadata !{i32 11, i32 10, metadata !5, null}
5250 !21 = metadata !{i32 3, i32 25, metadata !10, metadata !19}
53 !22 = metadata !{i32 786688, metadata !17, metadata !"local", metadata !6, i32 4, metadata !9, i32 0, metadata !19} ; [ DW_TAG_auto_variable ]
54 !23 = metadata !{i32 4, i32 16, metadata !17, metadata !19}
55 !24 = metadata !{i32 5, i32 3, metadata !17, metadata !19}
56 !25 = metadata !{i32 6, i32 3, metadata !17, metadata !19}
51 !22 = metadata !{i32 786688, metadata !10, metadata !"local", metadata !6, i32 4, metadata !9, i32 0, metadata !19} ; [ DW_TAG_auto_variable ]
52 !23 = metadata !{i32 4, i32 16, metadata !10, metadata !19}
53 !24 = metadata !{i32 5, i32 3, metadata !10, metadata !19}
54 !25 = metadata !{i32 6, i32 3, metadata !10, metadata !19}
0 ; RUN: llc -filetype=obj -O0 < %s > %t
1 ; RUN: llvm-dwarfdump %t | FileCheck %s
2
3 ; CHECK: 2 0 1 0 is_stmt
4
5 ; IR generated from clang -g -emit-llvm with the following source:
6 ; list0.h:
7 ; int foo (int x) {
8 ; return ++x;
9 ; }
10 ; list0.c:
11 ; #include "list0.h"
12 ; int main() {
13 ; }
14
15 define i32 @foo(i32 %x) nounwind uwtable {
16 entry:
17 %x.addr = alloca i32, align 4
18 store i32 %x, i32* %x.addr, align 4
19 call void @llvm.dbg.declare(metadata !{i32* %x.addr}, metadata !14), !dbg !15
20 %0 = load i32* %x.addr, align 4, !dbg !16
21 %inc = add nsw i32 %0, 1, !dbg !16
22 store i32 %inc, i32* %x.addr, align 4, !dbg !16
23 ret i32 %inc, !dbg !16
24 }
25
26 declare void @llvm.dbg.declare(metadata, metadata) nounwind readnone
27
28 define i32 @main() nounwind uwtable {
29 entry:
30 ret i32 0, !dbg !17
31 }
32
33 !llvm.dbg.cu = !{!0}
34
35 !0 = metadata !{i32 786449, i32 0, i32 12, metadata !"list0.c", metadata !"/usr/local/google/home/blaikie/dev/scratch/pr14566", metadata !"clang version 3.3 ", i1 true, i1 false, metadata !"", i32 0, metadata !1, metadata !1, metadata !3, metadata !1} ; [ DW_TAG_compile_unit ] [/usr/local/google/home/blaikie/dev/scratch/pr14566/list0.c] [DW_LANG_C99]
36 !1 = metadata !{metadata !2}
37 !2 = metadata !{i32 0}
38 !3 = metadata !{metadata !4}
39 !4 = metadata !{metadata !5, metadata !10}
40 !5 = metadata !{i32 786478, i32 0, metadata !6, metadata !"foo", metadata !"foo", metadata !"", metadata !6, i32 1, metadata !7, i1 false, i1 true, i32 0, i32 0, null, i32 256, i1 false, i32 (i32)* @foo, null, null, metadata !1, i32 1} ; [ DW_TAG_subprogram ] [line 1] [def] [foo]
41 !6 = metadata !{i32 786473, metadata !"./list0.h", metadata !"/usr/local/google/home/blaikie/dev/scratch/pr14566", null} ; [ DW_TAG_file_type ]
42 !7 = metadata !{i32 786453, i32 0, metadata !"", i32 0, i32 0, i64 0, i64 0, i64 0, i32 0, null, metadata !8, i32 0, i32 0} ; [ DW_TAG_subroutine_type ] [line 0, size 0, align 0, offset 0] [from ]
43 !8 = metadata !{metadata !9, metadata !9}
44 !9 = metadata !{i32 786468, null, metadata !"int", null, i32 0, i64 32, i64 32, i64 0, i32 0, i32 5} ; [ DW_TAG_base_type ] [int] [line 0, size 32, align 32, offset 0, enc DW_ATE_signed]
45 !10 = metadata !{i32 786478, i32 0, metadata !11, metadata !"main", metadata !"main", metadata !"", metadata !11, i32 2, metadata !12, i1 false, i1 true, i32 0, i32 0, null, i32 0, i1 false, i32 ()* @main, null, null, metadata !1, i32 2} ; [ DW_TAG_subprogram ] [line 2] [def] [main]
46 !11 = metadata !{i32 786473, metadata !"list0.c", metadata !"/usr/local/google/home/blaikie/dev/scratch/pr14566", null} ; [ DW_TAG_file_type ]
47 !12 = metadata !{i32 786453, i32 0, metadata !"", i32 0, i32 0, i64 0, i64 0, i64 0, i32 0, null, metadata !13, i32 0, i32 0} ; [ DW_TAG_subroutine_type ] [line 0, size 0, align 0, offset 0] [from ]
48 !13 = metadata !{metadata !9}
49 !14 = metadata !{i32 786689, metadata !5, metadata !"x", metadata !6, i32 16777217, metadata !9, i32 0, i32 0} ; [ DW_TAG_arg_variable ] [x] [line 1]
50 !15 = metadata !{i32 1, i32 0, metadata !5, null}
51 !16 = metadata !{i32 2, i32 0, metadata !5, null}
52 !17 = metadata !{i32 3, i32 0, metadata !18, null}
53 !18 = metadata !{i32 786443, metadata !10, metadata !11} ; [ DW_TAG_lexical_block ] [/usr/local/google/home/blaikie/dev/scratch/pr14566/list0.c]