1 ; REQUIRES: default_triple, object-emission
3 ; RUN: llvm-link %s %p/type-unique-odr-b.ll -S -o - \
4 ; RUN: | %llc_dwarf -dwarf-linkage-names=All -filetype=obj -O0 \
5 ; RUN: | llvm-dwarfdump -v -debug-info - \
7 ; RUN: llvm-link %p/type-unique-odr-b.ll %s -S -o - \
8 ; RUN: | %llc_dwarf -dwarf-linkage-names=All -filetype=obj -O0 \
9 ; RUN: | llvm-dwarfdump -v -debug-info - \
12 ; Test ODR-based type uniquing for C++ class members.
13 ; rdar://problem/15851313.
15 ; $ cat -n type-unique-odr-a.cpp
22 ; 7 static void bar() {
26 ; 11 void baz() { bar(); }
29 ; return A().getFoo();
32 ; CHECK: DW_TAG_class_type
33 ; CHECK-NEXT: DW_AT_name {{.*}} "A"
35 ; CHECK: DW_TAG_member
36 ; CHECK-NEXT: DW_AT_name {{.*}} "data"
38 ; CHECK: DW_TAG_subprogram
40 ; CHECK: DW_AT_linkage_name {{.*}} "_ZN1A6getFooEv"
42 ; CHECK: DW_AT_name {{.*}} "getFoo"
44 ; Ensure that there aren't any other subprograms in class A.
46 ; CHECK: DW_TAG_formal_parameter
52 ; CHECK: DW_TAG_base_type
54 ; Ensure that getFoo and A are only emitted once.
55 ; CHECK-NOT: AT_name{{.*(getFoo)|("A")}}
57 ; ModuleID = 'type-unique-odr-a.cpp'
59 %class.A = type { i32 }
61 ; Function Attrs: nounwind
62 define void @_Z3bazv() #0 !dbg !15 {
64 call void @_ZL3barv(), !dbg !23
68 ; Function Attrs: nounwind
69 define internal void @_ZL3barv() #0 !dbg !19 {
71 %a = alloca %class.A, align 4
72 call void @llvm.dbg.declare(metadata %class.A* %a, metadata !24, metadata !DIExpression()), !dbg !25
76 ; Function Attrs: nounwind readnone
77 declare void @llvm.dbg.declare(metadata, metadata, metadata) #1
79 attributes #0 = { nounwind }
80 attributes #1 = { nounwind readnone }
83 !llvm.module.flags = !{!20, !21}
86 !0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, producer: "clang version 3.5.0 ", isOptimized: false, emissionKind: FullDebug, file: !1, enums: !2, retainedTypes: !3, globals: !2, imports: !2)
87 !1 = !DIFile(filename: "<unknown>", directory: "")
90 !4 = !DICompositeType(tag: DW_TAG_class_type, name: "A", line: 1, size: 32, align: 32, file: !5, elements: !6, identifier: "_ZTS1A")
91 !5 = !DIFile(filename: "type-unique-odr-a.cpp", directory: "")
93 !7 = !DIDerivedType(tag: DW_TAG_member, name: "data", line: 2, size: 32, align: 32, flags: DIFlagPrivate, file: !5, scope: !4, baseType: !8)
94 !8 = !DIBasicType(tag: DW_TAG_base_type, name: "int", size: 32, align: 32, encoding: DW_ATE_signed)
95 !9 = !DISubprogram(name: "getFoo", linkageName: "_ZN1A6getFooEv", line: 4, isLocal: false, isDefinition: false, virtualIndex: 6, flags: DIFlagProtected | DIFlagPrototyped, isOptimized: false, scopeLine: 4, file: !5, scope: !4, type: !10)
96 !10 = !DISubroutineType(types: !11)
98 !12 = !DIDerivedType(tag: DW_TAG_pointer_type, size: 64, align: 64, flags: DIFlagArtificial | DIFlagObjectPointer, baseType: !4)
99 !15 = distinct !DISubprogram(name: "baz", linkageName: "_Z3bazv", line: 11, isLocal: false, isDefinition: true, virtualIndex: 6, flags: DIFlagPrototyped, isOptimized: false, unit: !0, scopeLine: 11, file: !5, scope: !16, type: !17, retainedNodes: !2)
100 !16 = !DIFile(filename: "type-unique-odr-a.cpp", directory: "")
101 !17 = !DISubroutineType(types: !18)
103 !19 = distinct !DISubprogram(name: "bar", linkageName: "_ZL3barv", line: 7, isLocal: true, isDefinition: true, virtualIndex: 6, flags: DIFlagPrototyped, isOptimized: false, unit: !0, scopeLine: 7, file: !5, scope: !16, type: !17, retainedNodes: !2)
104 !20 = !{i32 2, !"Dwarf Version", i32 4}
105 !21 = !{i32 1, !"Debug Info Version", i32 3}
106 !22 = !{!"clang version 3.5.0 "}
107 !23 = !DILocation(line: 11, scope: !15)
108 !24 = !DILocalVariable(name: "a", line: 8, scope: !19, file: !16, type: !4)
109 !25 = !DILocation(line: 8, scope: !19)
110 !26 = !DILocation(line: 9, scope: !19)