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