2 ; RUN: llc -mtriple x86_64-pc-linux -O0 -filetype=obj %s -o %t
3 ; RUN: llvm-dwarfdump %t | FileCheck %s
9 ; typedef base base_type;
15 ; Where member b should be seen as a field at an offset and not a bitfield.
17 ; CHECK: DW_TAG_member
18 ; CHECK: DW_AT_name{{.*}}"b"
19 ; CHECK-NOT: DW_AT_bit_offset
21 source_filename = "test/DebugInfo/X86/decl-derived-member.ll"
23 %struct.foo = type { %struct.base }
24 %struct.base = type { ptr }
26 $_ZN3fooC2Ev = comdat any
28 $_ZN3fooD2Ev = comdat any
30 $_ZN4baseC2Ev = comdat any
32 @f = global %struct.foo zeroinitializer, align 8, !dbg !0
33 @__dso_handle = external global i8
34 @_ZTV4base = external unnamed_addr constant [4 x ptr]
35 @llvm.global_ctors = appending global [1 x { i32, ptr, ptr }] [{ i32, ptr, ptr } { i32 65535, ptr @_GLOBAL__sub_I_decl_derived_member.cpp, ptr null }]
37 define internal void @__cxx_global_var_init() section ".text.startup" !dbg !15 {
39 call void @_ZN3fooC2Ev(ptr @f) #2, !dbg !18
40 %0 = call i32 @__cxa_atexit(ptr @_ZN3fooD2Ev, ptr @f, ptr @__dso_handle) #2, !dbg !18
44 ; Function Attrs: inlinehint nounwind uwtable
45 define linkonce_odr void @_ZN3fooC2Ev(ptr %this) unnamed_addr #0 comdat align 2 !dbg !19 {
47 %this.addr = alloca ptr, align 8
48 store ptr %this, ptr %this.addr, align 8
49 call void @llvm.dbg.declare(metadata ptr %this.addr, metadata !24, metadata !26), !dbg !27
50 %this1 = load ptr, ptr %this.addr
51 call void @_ZN4baseC2Ev(ptr %this1) #2, !dbg !28
55 ; Function Attrs: inlinehint uwtable
56 define linkonce_odr void @_ZN3fooD2Ev(ptr %this) unnamed_addr #1 comdat align 2 !dbg !29 {
58 %this.addr = alloca ptr, align 8
59 store ptr %this, ptr %this.addr, align 8
60 call void @llvm.dbg.declare(metadata ptr %this.addr, metadata !31, metadata !26), !dbg !32
61 %this1 = load ptr, ptr %this.addr
62 call void @_ZN4baseD1Ev(ptr %this1), !dbg !33
66 ; Function Attrs: nounwind
67 declare i32 @__cxa_atexit(ptr, ptr, ptr) #2
69 ; Function Attrs: nounwind readnone
70 declare void @llvm.dbg.declare(metadata, metadata, metadata) #3
72 ; Function Attrs: inlinehint nounwind uwtable
73 define linkonce_odr void @_ZN4baseC2Ev(ptr %this) unnamed_addr #0 comdat align 2 !dbg !36 {
75 %this.addr = alloca ptr, align 8
76 store ptr %this, ptr %this.addr, align 8
77 call void @llvm.dbg.declare(metadata ptr %this.addr, metadata !41, metadata !26), !dbg !43
78 %this1 = load ptr, ptr %this.addr
79 store ptr getelementptr inbounds ([4 x ptr], ptr @_ZTV4base, i64 0, i64 2), ptr %this1, !dbg !44
83 declare void @_ZN4baseD1Ev(ptr) #4
85 define internal void @_GLOBAL__sub_I_decl_derived_member.cpp() section ".text.startup" {
87 call void @__cxx_global_var_init(), !dbg !45
91 attributes #0 = { inlinehint nounwind uwtable "less-precise-fpmad"="false" "frame-pointer"="all" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "stack-protector-buffer-size"="8" "unsafe-fp-math"="false" "use-soft-float"="false" }
92 attributes #1 = { inlinehint uwtable "less-precise-fpmad"="false" "frame-pointer"="all" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "stack-protector-buffer-size"="8" "unsafe-fp-math"="false" "use-soft-float"="false" }
93 attributes #2 = { nounwind }
94 attributes #3 = { nounwind readnone }
95 attributes #4 = { "less-precise-fpmad"="false" "frame-pointer"="all" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "stack-protector-buffer-size"="8" "unsafe-fp-math"="false" "use-soft-float"="false" }
98 !llvm.module.flags = !{!12, !13}
101 !0 = !DIGlobalVariableExpression(var: !1, expr: !DIExpression())
102 !1 = !DIGlobalVariable(name: "f", scope: null, file: !2, line: 8, type: !3, isLocal: false, isDefinition: true)
103 !2 = !DIFile(filename: "decl-derived-member.cpp", directory: "/tmp/dbginfo")
104 !3 = !DICompositeType(tag: DW_TAG_structure_type, name: "foo", file: !2, line: 5, size: 64, align: 64, elements: !4, identifier: "_ZTS3foo")
106 !5 = !DIDerivedType(tag: DW_TAG_member, name: "b", scope: !3, file: !2, line: 6, baseType: !6, size: 64, align: 64)
107 !6 = !DIDerivedType(tag: DW_TAG_typedef, name: "base_type", file: !2, line: 4, baseType: !7)
108 !7 = !DICompositeType(tag: DW_TAG_structure_type, name: "base", file: !2, line: 1, flags: DIFlagFwdDecl, identifier: "_ZTS4base")
109 !8 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, file: !2, producer: "clang version 3.7.0 (trunk 227104) (llvm/trunk 227103)", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, enums: !9, retainedTypes: !10, globals: !11, imports: !9)
113 !12 = !{i32 2, !"Dwarf Version", i32 4}
114 !13 = !{i32 2, !"Debug Info Version", i32 3}
115 !14 = !{!"clang version 3.7.0 (trunk 227104) (llvm/trunk 227103)"}
116 !15 = distinct !DISubprogram(name: "__cxx_global_var_init", scope: !2, file: !2, line: 8, type: !16, isLocal: true, isDefinition: true, scopeLine: 8, flags: DIFlagPrototyped, isOptimized: false, unit: !8, retainedNodes: !9)
117 !16 = !DISubroutineType(types: !17)
119 !18 = !DILocation(line: 8, column: 5, scope: !15)
120 !19 = distinct !DISubprogram(name: "foo", linkageName: "_ZN3fooC2Ev", scope: !3, file: !2, line: 5, type: !20, isLocal: false, isDefinition: true, scopeLine: 5, flags: DIFlagArtificial | DIFlagPrototyped, isOptimized: false, unit: !8, declaration: !23, retainedNodes: !9)
121 !20 = !DISubroutineType(types: !21)
123 !22 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !3, size: 64, align: 64, flags: DIFlagArtificial | DIFlagObjectPointer)
124 !23 = !DISubprogram(name: "foo", scope: !3, type: !20, isLocal: false, isDefinition: false, flags: DIFlagArtificial | DIFlagPrototyped, isOptimized: false)
125 !24 = !DILocalVariable(name: "this", arg: 1, scope: !19, type: !25, flags: DIFlagArtificial | DIFlagObjectPointer)
126 !25 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !3, size: 64, align: 64)
127 !26 = !DIExpression()
128 !27 = !DILocation(line: 0, scope: !19)
129 !28 = !DILocation(line: 5, column: 8, scope: !19)
130 !29 = distinct !DISubprogram(name: "~foo", linkageName: "_ZN3fooD2Ev", scope: !3, file: !2, line: 5, type: !20, isLocal: false, isDefinition: true, scopeLine: 5, flags: DIFlagArtificial | DIFlagPrototyped, isOptimized: false, unit: !8, declaration: !30, retainedNodes: !9)
131 !30 = !DISubprogram(name: "~foo", scope: !3, type: !20, isLocal: false, isDefinition: false, flags: DIFlagArtificial | DIFlagPrototyped, isOptimized: false)
132 !31 = !DILocalVariable(name: "this", arg: 1, scope: !29, type: !25, flags: DIFlagArtificial | DIFlagObjectPointer)
133 !32 = !DILocation(line: 0, scope: !29)
134 !33 = !DILocation(line: 5, column: 8, scope: !34)
135 !34 = distinct !DILexicalBlock(scope: !29, file: !2, line: 5, column: 8)
136 !35 = !DILocation(line: 5, column: 8, scope: !29)
137 !36 = distinct !DISubprogram(name: "base", linkageName: "_ZN4baseC2Ev", scope: !7, file: !2, line: 1, type: !37, isLocal: false, isDefinition: true, scopeLine: 1, flags: DIFlagArtificial | DIFlagPrototyped, isOptimized: false, unit: !8, declaration: !40, retainedNodes: !9)
138 !37 = !DISubroutineType(types: !38)
140 !39 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !7, size: 64, align: 64, flags: DIFlagArtificial | DIFlagObjectPointer)
141 !40 = !DISubprogram(name: "base", scope: !7, type: !37, isLocal: false, isDefinition: false, flags: DIFlagArtificial | DIFlagPrototyped, isOptimized: false)
142 !41 = !DILocalVariable(name: "this", arg: 1, scope: !36, type: !42, flags: DIFlagArtificial | DIFlagObjectPointer)
143 !42 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !7, size: 64, align: 64)
144 !43 = !DILocation(line: 0, scope: !36)
145 !44 = !DILocation(line: 1, column: 8, scope: !36)
146 !45 = !DILocation(line: 0, scope: !46)
147 !46 = distinct !DISubprogram(linkageName: "_GLOBAL__sub_I_decl_derived_member.cpp", scope: !2, file: !2, type: !47, isLocal: true, isDefinition: true, flags: DIFlagArtificial, isOptimized: false, unit: !8, retainedNodes: !9)
148 !47 = !DISubroutineType(types: !9)