llvm.org GIT mirror llvm / 65794dd
Merging r227290: ------------------------------------------------------------------------ r227290 | dblaikie | 2015-01-27 18:34:53 -0800 (Tue, 27 Jan 2015) | 1 line PR22356: DebugInfo: Handle the size of a member where the type of that member is a typedef (or other sugar) of a declaration. ------------------------------------------------------------------------ git-svn-id: https://llvm.org/svn/llvm-project/llvm/branches/release_36@227492 91177308-0d34-0410-b5e6-96231b3b80d8 Hans Wennborg 5 years ago
2 changed file(s) with 83 addition(s) and 79 deletion(s). Raw diff Collapse all Expand all
625625
626626 DIType BaseType = DD->resolve(Ty.getTypeDerivedFrom());
627627
628 // If this type is not derived from any type or the type is a declaration then
629 // take conservative approach.
630 if (!BaseType.isValid() || BaseType.isForwardDecl())
631 return Ty.getSizeInBits();
628 assert(BaseType.isValid());
632629
633630 // If this is a derived type, go ahead and get the base type, unless it's a
634631 // reference then it's just the size of the field. Pointer types have no need
14721469 uint64_t FieldSize = getBaseTypeSize(DD, DT);
14731470 uint64_t OffsetInBytes;
14741471
1475 if (Size != FieldSize) {
1472 if (FieldSize && Size != FieldSize) {
14761473 // Handle bitfield, assume bytes are 8 bits.
14771474 addUInt(MemberDie, dwarf::DW_AT_byte_size, None, FieldSize/8);
14781475 addUInt(MemberDie, dwarf::DW_AT_bit_size, None, Size);
66 ; struct base {
77 ; virtual ~base();
88 ; };
9 ; typedef base base_type;
910 ; struct foo {
10 ; base b;
11 ; base_type b;
1112 ; };
1213 ; foo f;
1314
1920
2021 %struct.foo = type { %struct.base }
2122 %struct.base = type { i32 (...)** }
23
24 $_ZN3fooC2Ev = comdat any
25
26 $_ZN3fooD2Ev = comdat any
27
28 $_ZN4baseC2Ev = comdat any
29
2230 @f = global %struct.foo zeroinitializer, align 8
2331 @__dso_handle = external global i8
2432 @_ZTV4base = external unnamed_addr constant [4 x i8*]
25 @llvm.global_ctors = appending global [1 x { i32, void ()* }] [{ i32, void ()* } { i32 65535, void ()* @_GLOBAL__I_a }]
33 @llvm.global_ctors = appending global [1 x { i32, void ()*, i8* }] [{ i32, void ()*, i8* } { i32 65535, void ()* @_GLOBAL__sub_I_decl_derived_member.cpp, i8* null }]
2634
2735 define internal void @__cxx_global_var_init() section ".text.startup" {
2836 entry:
29 call void @_ZN3fooC2Ev(%struct.foo* @f) #2, !dbg !35
30 %0 = call i32 @__cxa_atexit(void (i8*)* bitcast (void (%struct.foo*)* @_ZN3fooD2Ev to void (i8*)*), i8* bitcast (%struct.foo* @f to i8*), i8* @__dso_handle) #2, !dbg !35
31 ret void, !dbg !35
37 call void @_ZN3fooC2Ev(%struct.foo* @f) #2, !dbg !33
38 %0 = call i32 @__cxa_atexit(void (i8*)* bitcast (void (%struct.foo*)* @_ZN3fooD2Ev to void (i8*)*), i8* bitcast (%struct.foo* @f to i8*), i8* @__dso_handle) #2, !dbg !33
39 ret void, !dbg !33
3240 }
3341
3442 ; Function Attrs: inlinehint nounwind uwtable
35 define linkonce_odr void @_ZN3fooC2Ev(%struct.foo* %this) unnamed_addr #0 align 2 {
43 define linkonce_odr void @_ZN3fooC2Ev(%struct.foo* %this) unnamed_addr #0 comdat align 2 {
3644 entry:
3745 %this.addr = alloca %struct.foo*, align 8
3846 store %struct.foo* %this, %struct.foo** %this.addr, align 8
39 call void @llvm.dbg.declare(metadata %struct.foo** %this.addr, metadata !36, metadata !{!"0x102"}), !dbg !38
47 call void @llvm.dbg.declare(metadata %struct.foo** %this.addr, metadata !34, metadata !36), !dbg !37
4048 %this1 = load %struct.foo** %this.addr
41 %b = getelementptr inbounds %struct.foo* %this1, i32 0, i32 0, !dbg !39
42 call void @_ZN4baseC2Ev(%struct.base* %b) #2, !dbg !39
43 ret void, !dbg !39
49 %b = getelementptr inbounds %struct.foo* %this1, i32 0, i32 0, !dbg !38
50 call void @_ZN4baseC2Ev(%struct.base* %b) #2, !dbg !38
51 ret void, !dbg !38
4452 }
4553
4654 ; Function Attrs: inlinehint uwtable
47 define linkonce_odr void @_ZN3fooD2Ev(%struct.foo* %this) unnamed_addr #1 align 2 {
55 define linkonce_odr void @_ZN3fooD2Ev(%struct.foo* %this) unnamed_addr #1 comdat align 2 {
4856 entry:
4957 %this.addr = alloca %struct.foo*, align 8
5058 store %struct.foo* %this, %struct.foo** %this.addr, align 8
51 call void @llvm.dbg.declare(metadata %struct.foo** %this.addr, metadata !40, metadata !{!"0x102"}), !dbg !41
59 call void @llvm.dbg.declare(metadata %struct.foo** %this.addr, metadata !39, metadata !36), !dbg !40
5260 %this1 = load %struct.foo** %this.addr
53 %b = getelementptr inbounds %struct.foo* %this1, i32 0, i32 0, !dbg !42
54 call void @_ZN4baseD1Ev(%struct.base* %b), !dbg !42
55 ret void, !dbg !44
61 %b = getelementptr inbounds %struct.foo* %this1, i32 0, i32 0, !dbg !41
62 call void @_ZN4baseD1Ev(%struct.base* %b), !dbg !41
63 ret void, !dbg !43
5664 }
5765
5866 ; Function Attrs: nounwind
6169 ; Function Attrs: nounwind readnone
6270 declare void @llvm.dbg.declare(metadata, metadata, metadata) #3
6371
64 declare void @_ZN4baseD1Ev(%struct.base*) #4
65
6672 ; Function Attrs: inlinehint nounwind uwtable
67 define linkonce_odr void @_ZN4baseC2Ev(%struct.base* %this) unnamed_addr #0 align 2 {
73 define linkonce_odr void @_ZN4baseC2Ev(%struct.base* %this) unnamed_addr #0 comdat align 2 {
6874 entry:
6975 %this.addr = alloca %struct.base*, align 8
7076 store %struct.base* %this, %struct.base** %this.addr, align 8
71 call void @llvm.dbg.declare(metadata %struct.base** %this.addr, metadata !45, metadata !{!"0x102"}), !dbg !47
77 call void @llvm.dbg.declare(metadata %struct.base** %this.addr, metadata !44, metadata !36), !dbg !46
7278 %this1 = load %struct.base** %this.addr
73 %0 = bitcast %struct.base* %this1 to i8***, !dbg !48
74 store i8** getelementptr inbounds ([4 x i8*]* @_ZTV4base, i64 0, i64 2), i8*** %0, !dbg !48
75 ret void, !dbg !48
79 %0 = bitcast %struct.base* %this1 to i32 (...)***, !dbg !47
80 store i32 (...)** bitcast (i8** getelementptr inbounds ([4 x i8*]* @_ZTV4base, i64 0, i64 2) to i32 (...)**), i32 (...)*** %0, !dbg !47
81 ret void, !dbg !47
7682 }
7783
78 define internal void @_GLOBAL__I_a() section ".text.startup" {
84 declare void @_ZN4baseD1Ev(%struct.base*) #4
85
86 define internal void @_GLOBAL__sub_I_decl_derived_member.cpp() section ".text.startup" {
7987 entry:
80 call void @__cxx_global_var_init(), !dbg !49
81 ret void, !dbg !49
88 call void @__cxx_global_var_init(), !dbg !48
89 ret void
8290 }
8391
8492 attributes #0 = { inlinehint nounwind uwtable "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" }
8896 attributes #4 = { "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" }
8997
9098 !llvm.dbg.cu = !{!0}
91 !llvm.module.flags = !{!32, !33}
92 !llvm.ident = !{!34}
99 !llvm.module.flags = !{!30, !31}
100 !llvm.ident = !{!32}
93101
94 !0 = !{!"0x11\004\00clang version 3.5.0 (trunk 203673) (llvm/trunk 203681)\000\00\000\00\001", !1, !2, !3, !8, !30, !2} ; [ DW_TAG_compile_unit ] [/usr/local/google/home/echristo/foo.cc] [DW_LANG_C_plus_plus]
95 !1 = !{!"foo.cc", !"/usr/local/google/home/echristo"}
102 !0 = !{!"0x11\004\00clang version 3.7.0 (trunk 227104) (llvm/trunk 227103)\000\00\000\00\001", !1, !2, !3, !9, !28, !2} ; [ DW_TAG_compile_unit ] [/tmp/dbginfo/decl-derived-member.cpp] [DW_LANG_C_plus_plus]
103 !1 = !{!"decl-derived-member.cpp", !"/tmp/dbginfo"}
96104 !2 = !{}
97 !3 = !{!4, !7}
105 !3 = !{!4, !8}
98106 !4 = !{!"0x13\00foo\005\0064\0064\000\000\000", !1, null, null, !5, null, null, !"_ZTS3foo"} ; [ DW_TAG_structure_type ] [foo] [line 5, size 64, align 64, offset 0] [def] [from ]
99107 !5 = !{!6}
100 !6 = !{!"0xd\00b\006\0064\0064\000\000", !1, !"_ZTS3foo", !"_ZTS4base"} ; [ DW_TAG_member ] [b] [line 6, size 64, align 64, offset 0] [from _ZTS4base]
101 !7 = !{!"0x13\00base\001\000\000\000\004\000", !1, null, null, null, null, null, !"_ZTS4base"} ; [ DW_TAG_structure_type ] [base] [line 1, size 0, align 0, offset 0] [decl] [from ]
102 !8 = !{!9, !13, !19, !22, !28}
103 !9 = !{!"0x2e\00__cxx_global_var_init\00__cxx_global_var_init\00\009\001\001\000\006\00256\000\009", !1, !10, !11, null, void ()* @__cxx_global_var_init, null, null, !2} ; [ DW_TAG_subprogram ] [line 9] [local] [def] [__cxx_global_var_init]
104 !10 = !{!"0x29", !1} ; [ DW_TAG_file_type ] [/usr/local/google/home/echristo/foo.cc]
105 !11 = !{!"0x15\00\000\000\000\000\000\000", i32 0, null, null, !12, null, null, null} ; [ DW_TAG_subroutine_type ] [line 0, size 0, align 0, offset 0] [from ]
106 !12 = !{null}
107 !13 = !{!"0x2e\00~foo\00~foo\00_ZN3fooD2Ev\005\000\001\000\006\00320\000\005", !1, !"_ZTS3foo", !14, null, void (%struct.foo*)* @_ZN3fooD2Ev, null, !17, !2} ; [ DW_TAG_subprogram ] [line 5] [def] [~foo]
108 !14 = !{!"0x15\00\000\000\000\000\000\000", i32 0, null, null, !15, null, null, null} ; [ DW_TAG_subroutine_type ] [line 0, size 0, align 0, offset 0] [from ]
109 !15 = !{null, !16}
110 !16 = !{!"0xf\00\000\0064\0064\000\001088", null, null, !"_ZTS3foo"} ; [ DW_TAG_pointer_type ] [line 0, size 64, align 64, offset 0] [artificial] [from _ZTS3foo]
111 !17 = !{!"0x2e\00~foo\00~foo\00\000\000\000\000\006\00320\000\000", null, !"_ZTS3foo", !14, null, null, null, i32 0, !18} ; [ DW_TAG_subprogram ] [line 0] [~foo]
112 !18 = !{i32 786468}
113 !19 = !{!"0x2e\00foo\00foo\00_ZN3fooC2Ev\005\000\001\000\006\00320\000\005", !1, !"_ZTS3foo", !14, null, void (%struct.foo*)* @_ZN3fooC2Ev, null, !20, !2} ; [ DW_TAG_subprogram ] [line 5] [def] [foo]
114 !20 = !{!"0x2e\00foo\00foo\00\000\000\000\000\006\00320\000\000", null, !"_ZTS3foo", !14, null, null, null, i32 0, !21} ; [ DW_TAG_subprogram ] [line 0] [foo]
115 !21 = !{i32 786468}
116 !22 = !{!"0x2e\00base\00base\00_ZN4baseC2Ev\001\000\001\000\006\00320\000\001", !1, !"_ZTS4base", !23, null, void (%struct.base*)* @_ZN4baseC2Ev, null, !26, !2} ; [ DW_TAG_subprogram ] [line 1] [def] [base]
117 !23 = !{!"0x15\00\000\000\000\000\000\000", i32 0, null, null, !24, null, null, null} ; [ DW_TAG_subroutine_type ] [line 0, size 0, align 0, offset 0] [from ]
118 !24 = !{null, !25}
119 !25 = !{!"0xf\00\000\0064\0064\000\001088", null, null, !"_ZTS4base"} ; [ DW_TAG_pointer_type ] [line 0, size 64, align 64, offset 0] [artificial] [from _ZTS4base]
120 !26 = !{!"0x2e\00base\00base\00\000\000\000\000\006\00320\000\000", null, !"_ZTS4base", !23, null, null, null, i32 0, !27} ; [ DW_TAG_subprogram ] [line 0] [base]
121 !27 = !{i32 786468}
122 !28 = !{!"0x2e\00\00\00_GLOBAL__I_a\001\001\001\000\006\0064\000\001", !1, !10, !29, null, void ()* @_GLOBAL__I_a, null, null, !2} ; [ DW_TAG_subprogram ] [line 1] [local] [def]
123 !29 = !{!"0x15\00\000\000\000\000\000\000", i32 0, null, null, !2, null, null, null} ; [ DW_TAG_subroutine_type ] [line 0, size 0, align 0, offset 0] [from ]
124 !30 = !{!31}
125 !31 = !{!"0x34\00f\00f\00\009\000\001", null, !10, !4, %struct.foo* @f, null} ; [ DW_TAG_variable ] [f] [line 9] [def]
126 !32 = !{i32 2, !"Dwarf Version", i32 4}
127 !33 = !{i32 1, !"Debug Info Version", i32 2}
128 !34 = !{!"clang version 3.5.0 (trunk 203673) (llvm/trunk 203681)"}
129 !35 = !MDLocation(line: 9, scope: !9)
130 !36 = !{!"0x101\00this\0016777216\001088", !19, null, !37} ; [ DW_TAG_arg_variable ] [this] [line 0]
131 !37 = !{!"0xf\00\000\0064\0064\000\000", null, null, !"_ZTS3foo"} ; [ DW_TAG_pointer_type ] [line 0, size 64, align 64, offset 0] [from _ZTS3foo]
132 !38 = !MDLocation(line: 0, scope: !19)
133 !39 = !MDLocation(line: 5, scope: !19)
134 !40 = !{!"0x101\00this\0016777216\001088", !13, null, !37} ; [ DW_TAG_arg_variable ] [this] [line 0]
135 !41 = !MDLocation(line: 0, scope: !13)
136 !42 = !MDLocation(line: 5, scope: !43)
137 !43 = !{!"0xb\005\000\000", !1, !13} ; [ DW_TAG_lexical_block ] [/usr/local/google/home/echristo/foo.cc]
138 !44 = !MDLocation(line: 5, scope: !13)
139 !45 = !{!"0x101\00this\0016777216\001088", !22, null, !46} ; [ DW_TAG_arg_variable ] [this] [line 0]
140 !46 = !{!"0xf\00\000\0064\0064\000\000", null, null, !"_ZTS4base"} ; [ DW_TAG_pointer_type ] [line 0, size 64, align 64, offset 0] [from _ZTS4base]
141 !47 = !MDLocation(line: 0, scope: !22)
142 !48 = !MDLocation(line: 1, scope: !22)
143 !49 = !MDLocation(line: 1, scope: !28)
108 !6 = !{!"0xd\00b\006\0064\0064\000\000", !1, !"_ZTS3foo", !7} ; [ DW_TAG_member ] [b] [line 6, size 64, align 64, offset 0] [from base_type]
109 !7 = !{!"0x16\00base_type\004\000\000\000\000", !1, null, !"_ZTS4base"} ; [ DW_TAG_typedef ] [base_type] [line 4, size 0, align 0, offset 0] [from _ZTS4base]
110 !8 = !{!"0x13\00base\001\000\000\000\004\000", !1, null, null, null, null, null, !"_ZTS4base"} ; [ DW_TAG_structure_type ] [base] [line 1, size 0, align 0, offset 0] [decl] [from ]
111 !9 = !{!10, !14, !19, !24, !26}
112 !10 = !{!"0x2e\00__cxx_global_var_init\00__cxx_global_var_init\00\008\001\001\000\000\00256\000\008", !1, !11, !12, null, void ()* @__cxx_global_var_init, null, null, !2} ; [ DW_TAG_subprogram ] [line 8] [local] [def] [__cxx_global_var_init]
113 !11 = !{!"0x29", !1} ; [ DW_TAG_file_type ] [/tmp/dbginfo/decl-derived-member.cpp]
114 !12 = !{!"0x15\00\000\000\000\000\000\000", null, null, null, !13, null, null, null} ; [ DW_TAG_subroutine_type ] [line 0, size 0, align 0, offset 0] [from ]
115 !13 = !{null}
116 !14 = !{!"0x2e\00foo\00foo\00_ZN3fooC2Ev\005\000\001\000\000\00320\000\005", !1, !"_ZTS3foo", !15, null, void (%struct.foo*)* @_ZN3fooC2Ev, null, !18, !2} ; [ DW_TAG_subprogram ] [line 5] [def] [foo]
117 !15 = !{!"0x15\00\000\000\000\000\000\000", null, null, null, !16, null, null, null} ; [ DW_TAG_subroutine_type ] [line 0, size 0, align 0, offset 0] [from ]
118 !16 = !{null, !17}
119 !17 = !{!"0xf\00\000\0064\0064\000\001088\00", null, null, !"_ZTS3foo"} ; [ DW_TAG_pointer_type ] [line 0, size 64, align 64, offset 0] [artificial] [from _ZTS3foo]
120 !18 = !{!"0x2e\00foo\00foo\00\000\000\000\000\000\00320\000\000", null, !"_ZTS3foo", !15, null, null, null, null, null} ; [ DW_TAG_subprogram ] [line 0] [foo]
121 !19 = !{!"0x2e\00base\00base\00_ZN4baseC2Ev\001\000\001\000\000\00320\000\001", !1, !"_ZTS4base", !20, null, void (%struct.base*)* @_ZN4baseC2Ev, null, !23, !2} ; [ DW_TAG_subprogram ] [line 1] [def] [base]
122 !20 = !{!"0x15\00\000\000\000\000\000\000", null, null, null, !21, null, null, null} ; [ DW_TAG_subroutine_type ] [line 0, size 0, align 0, offset 0] [from ]
123 !21 = !{null, !22}
124 !22 = !{!"0xf\00\000\0064\0064\000\001088\00", null, null, !"_ZTS4base"} ; [ DW_TAG_pointer_type ] [line 0, size 64, align 64, offset 0] [artificial] [from _ZTS4base]
125 !23 = !{!"0x2e\00base\00base\00\000\000\000\000\000\00320\000\000", null, !"_ZTS4base", !20, null, null, null, null, null} ; [ DW_TAG_subprogram ] [line 0] [base]
126 !24 = !{!"0x2e\00~foo\00~foo\00_ZN3fooD2Ev\005\000\001\000\000\00320\000\005", !1, !"_ZTS3foo", !15, null, void (%struct.foo*)* @_ZN3fooD2Ev, null, !25, !2} ; [ DW_TAG_subprogram ] [line 5] [def] [~foo]
127 !25 = !{!"0x2e\00~foo\00~foo\00\000\000\000\000\000\00320\000\000", null, !"_ZTS3foo", !15, null, null, null, null, null} ; [ DW_TAG_subprogram ] [line 0] [~foo]
128 !26 = !{!"0x2e\00\00\00_GLOBAL__sub_I_decl_derived_member.cpp\000\001\001\000\000\0064\000\000", !1, !11, !27, null, void ()* @_GLOBAL__sub_I_decl_derived_member.cpp, null, null, !2} ; [ DW_TAG_subprogram ] [line 0] [local] [def]
129 !27 = !{!"0x15\00\000\000\000\000\000\000", null, null, null, !2, null, null, null} ; [ DW_TAG_subroutine_type ] [line 0, size 0, align 0, offset 0] [from ]
130 !28 = !{!29}
131 !29 = !{!"0x34\00f\00f\00\008\000\001", null, !11, !"_ZTS3foo", %struct.foo* @f, null} ; [ DW_TAG_variable ] [f] [line 8] [def]
132 !30 = !{i32 2, !"Dwarf Version", i32 4}
133 !31 = !{i32 2, !"Debug Info Version", i32 2}
134 !32 = !{!"clang version 3.7.0 (trunk 227104) (llvm/trunk 227103)"}
135 !33 = !MDLocation(line: 8, column: 5, scope: !10)
136 !34 = !{!"0x101\00this\0016777216\001088", !14, null, !35} ; [ DW_TAG_arg_variable ] [this] [line 0]
137 !35 = !{!"0xf\00\000\0064\0064\000\000", null, null, !"_ZTS3foo"} ; [ DW_TAG_pointer_type ] [line 0, size 64, align 64, offset 0] [from _ZTS3foo]
138 !36 = !{!"0x102"} ; [ DW_TAG_expression ]
139 !37 = !MDLocation(line: 0, scope: !14)
140 !38 = !MDLocation(line: 5, column: 8, scope: !14)
141 !39 = !{!"0x101\00this\0016777216\001088", !24, null, !35} ; [ DW_TAG_arg_variable ] [this] [line 0]
142 !40 = !MDLocation(line: 0, scope: !24)
143 !41 = !MDLocation(line: 5, column: 8, scope: !42)
144 !42 = !{!"0xb\005\008\002", !1, !24} ; [ DW_TAG_lexical_block ] [/tmp/dbginfo/decl-derived-member.cpp]
145 !43 = !MDLocation(line: 5, column: 8, scope: !24)
146 !44 = !{!"0x101\00this\0016777216\001088", !19, null, !45} ; [ DW_TAG_arg_variable ] [this] [line 0]
147 !45 = !{!"0xf\00\000\0064\0064\000\000", null, null, !"_ZTS4base"} ; [ DW_TAG_pointer_type ] [line 0, size 64, align 64, offset 0] [from _ZTS4base]
148 !46 = !MDLocation(line: 0, scope: !19)
149 !47 = !MDLocation(line: 1, column: 8, scope: !19)
150 !48 = !MDLocation(line: 0, scope: !26)