1; REQUIRES: default_triple, object-emission
2;
3; RUN: llvm-link %s %p/type-unique-simple2-b.ll -S -o - | %llc_dwarf -filetype=obj -O0 | llvm-dwarfdump -debug-dump=info - | FileCheck %s
4;
5; Tests for a merge error where attributes are inserted twice into the same DIE.
6;
7; $ cat ab.h
8; typedef int foo_t;
9; class A {
10; public:
11;   virtual void setFoo();
12;   virtual const foo_t getFoo();
13; };
14;
15; $ cat a.cpp
16; #include "ab.h"
17; foo_t bar() {
18;     return A().getFoo();
19; }
20;
21; CHECK: DW_AT_name {{.*}} "setFoo"
22; CHECK-NOT: DW_TAG
23; CHECK: DW_AT_accessibility [DW_FORM_data1]   (DW_ACCESS_public)
24; CHECK-NOT: DW_AT_accessibility
25; CHECK: DW_TAG
26
27; ModuleID = 'a.cpp'
28
29%class.A = type { i32 (...)** }
30
31@_ZTV1A = external unnamed_addr constant [4 x i8*]
32
33; Function Attrs: nounwind
34define i32 @_Z3barv() #0 !dbg !27 {
35entry:
36  %tmp = alloca %class.A, align 8
37  %0 = bitcast %class.A* %tmp to i8*, !dbg !38
38  call void @llvm.memset.p0i8.i64(i8* %0, i8 0, i64 8, i32 8, i1 false), !dbg !38
39  call void @_ZN1AC1Ev(%class.A* %tmp) #1, !dbg !38
40  %call = call i32 @_ZN1A6getFooEv(%class.A* %tmp), !dbg !38
41  ret i32 %call, !dbg !38
42}
43
44; Function Attrs: nounwind
45declare void @llvm.memset.p0i8.i64(i8* nocapture, i8, i64, i32, i1) #1
46
47; Function Attrs: inlinehint nounwind
48define linkonce_odr void @_ZN1AC1Ev(%class.A* %this) unnamed_addr #2 align 2 !dbg !31 {
49entry:
50  %this.addr = alloca %class.A*, align 8
51  store %class.A* %this, %class.A** %this.addr, align 8
52  call void @llvm.dbg.declare(metadata %class.A** %this.addr, metadata !39, metadata !DIExpression()), !dbg !41
53  %this1 = load %class.A*, %class.A** %this.addr
54  call void @_ZN1AC2Ev(%class.A* %this1) #1, !dbg !42
55  ret void, !dbg !42
56}
57
58declare i32 @_ZN1A6getFooEv(%class.A*)
59
60; Function Attrs: nounwind readnone
61declare void @llvm.dbg.declare(metadata, metadata, metadata) #4
62
63; Function Attrs: inlinehint nounwind
64define linkonce_odr void @_ZN1AC2Ev(%class.A* %this) unnamed_addr #2 align 2 !dbg !34 {
65entry:
66  %this.addr = alloca %class.A*, align 8
67  store %class.A* %this, %class.A** %this.addr, align 8
68  call void @llvm.dbg.declare(metadata %class.A** %this.addr, metadata !44, metadata !DIExpression()), !dbg !45
69  %this1 = load %class.A*, %class.A** %this.addr
70  %0 = bitcast %class.A* %this1 to i8***, !dbg !46
71  store i8** getelementptr inbounds ([4 x i8*], [4 x i8*]* @_ZTV1A, i64 0, i64 2), i8*** %0, !dbg !46
72  ret void, !dbg !46
73}
74
75attributes #0 = { nounwind }
76attributes #1 = { nounwind }
77attributes #2 = { inlinehint nounwind }
78attributes #4 = { nounwind readnone }
79
80!llvm.dbg.cu = !{!0}
81!llvm.module.flags = !{!35, !36}
82!llvm.ident = !{!37}
83
84!0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, producer: "clang version 3.5 ", isOptimized: false, emissionKind: 0, file: !1, enums: !2, retainedTypes: !3, subprograms: !26, globals: !2, imports: !2)
85!1 = !DIFile(filename: "<unknown>", directory: "")
86!2 = !{}
87!3 = !{!4}
88!4 = !DICompositeType(tag: DW_TAG_class_type, name: "A", line: 2, size: 64, align: 64, file: !5, elements: !6, vtableHolder: !"_ZTS1A", identifier: "_ZTS1A")
89!5 = !DIFile(filename: "./ab.h", directory: "")
90!6 = !{!7, !14, !19}
91!7 = !DIDerivedType(tag: DW_TAG_member, name: "_vptr$A", size: 64, flags: DIFlagArtificial, file: !5, scope: !8, baseType: !9)
92!8 = !DIFile(filename: "./ab.h", directory: "")
93!9 = !DIDerivedType(tag: DW_TAG_pointer_type, size: 64, baseType: !10)
94!10 = !DIDerivedType(tag: DW_TAG_pointer_type, name: "__vtbl_ptr_type", size: 64, baseType: !11)
95!11 = !DISubroutineType(types: !12)
96!12 = !{!13}
97!13 = !DIBasicType(tag: DW_TAG_base_type, name: "int", size: 32, align: 32, encoding: DW_ATE_signed)
98!14 = !DISubprogram(name: "setFoo", linkageName: "_ZN1A6setFooEv", line: 4, isLocal: false, isDefinition: false, virtuality: DW_VIRTUALITY_virtual, virtualIndex: 6, flags: DIFlagPublic | DIFlagPrototyped, isOptimized: false, scopeLine: 4, file: !5, scope: !"_ZTS1A", type: !15, containingType: !"_ZTS1A")
99!15 = !DISubroutineType(types: !16)
100!16 = !{null, !17}
101!17 = !DIDerivedType(tag: DW_TAG_pointer_type, size: 64, align: 64, flags: DIFlagArtificial | DIFlagObjectPointer, baseType: !"_ZTS1A")
102!19 = !DISubprogram(name: "getFoo", linkageName: "_ZN1A6getFooEv", line: 5, isLocal: false, isDefinition: false, virtuality: DW_VIRTUALITY_virtual, virtualIndex: 6, flags: DIFlagPublic | DIFlagPrototyped, isOptimized: false, scopeLine: 5, file: !5, scope: !"_ZTS1A", type: !20, containingType: !"_ZTS1A")
103!20 = !DISubroutineType(types: !21)
104!21 = !{!22, !17}
105!22 = !DIDerivedType(tag: DW_TAG_const_type, baseType: !23)
106!23 = !DIDerivedType(tag: DW_TAG_typedef, name: "foo_t", line: 1, file: !24, baseType: !13)
107!24 = !DIFile(filename: "a.cpp", directory: "")
108!26 = !{!27, !31, !34}
109!27 = distinct !DISubprogram(name: "bar", linkageName: "_Z3barv", line: 2, isLocal: false, isDefinition: true, virtualIndex: 6, flags: DIFlagPrototyped, isOptimized: false, scopeLine: 2, file: !24, scope: !28, type: !29, variables: !2)
110!28 = !DIFile(filename: "a.cpp", directory: "")
111!29 = !DISubroutineType(types: !30)
112!30 = !{!23}
113!31 = distinct !DISubprogram(name: "A", linkageName: "_ZN1AC1Ev", line: 2, isLocal: false, isDefinition: true, virtualIndex: 6, flags: DIFlagArtificial | DIFlagPrototyped, isOptimized: false, scopeLine: 2, file: !5, scope: !"_ZTS1A", type: !15, declaration: !32, variables: !2)
114!32 = !DISubprogram(name: "A", isLocal: false, isDefinition: false, virtualIndex: 6, flags: DIFlagArtificial | DIFlagPrototyped, isOptimized: false, scope: !"_ZTS1A", type: !15)
115!34 = distinct !DISubprogram(name: "A", linkageName: "_ZN1AC2Ev", line: 2, isLocal: false, isDefinition: true, virtualIndex: 6, flags: DIFlagArtificial | DIFlagPrototyped, isOptimized: false, scopeLine: 2, file: !5, scope: !"_ZTS1A", type: !15, declaration: !32, variables: !2)
116!35 = !{i32 2, !"Dwarf Version", i32 2}
117!36 = !{i32 1, !"Debug Info Version", i32 3}
118!37 = !{!"clang version 3.5 "}
119!38 = !DILocation(line: 3, scope: !27)
120!39 = !DILocalVariable(name: "this", arg: 1, flags: DIFlagArtificial | DIFlagObjectPointer, scope: !31, type: !40)
121!40 = !DIDerivedType(tag: DW_TAG_pointer_type, size: 64, align: 64, baseType: !"_ZTS1A")
122!41 = !DILocation(line: 0, scope: !31)
123!42 = !DILocation(line: 2, scope: !43)
124!43 = !DILexicalBlockFile(discriminator: 0, file: !5, scope: !31)
125!44 = !DILocalVariable(name: "this", arg: 1, flags: DIFlagArtificial | DIFlagObjectPointer, scope: !34, type: !40)
126!45 = !DILocation(line: 0, scope: !34)
127!46 = !DILocation(line: 2, scope: !34)
128