Restore "Move metadata linking after lazy global materialization/linking."
[oota-llvm.git] / test / Linker / type-unique-odr-a.ll
1 ; REQUIRES: default_triple, object-emission
2 ;
3 ; RUN: llvm-link %s %p/type-unique-odr-b.ll -S -o - | %llc_dwarf -dwarf-linkage-names=Enable -filetype=obj -O0 | llvm-dwarfdump -debug-dump=info - | FileCheck %s
4 ;
5 ; Test ODR-based type uniquing for C++ class members.
6 ; rdar://problem/15851313.
7 ;
8 ; $ cat -n type-unique-odr-a.cpp
9 ;     1 class A {
10 ;     2   int data;
11 ;     3 protected:
12 ;     4   void getFoo();
13 ;     5 };
14 ;     6
15 ;     7 static void bar() {
16 ;     8   A a;
17 ;     9 }
18 ;    10
19 ;    11 void baz() { bar(); }
20 ;; #include "ab.h"
21 ; foo_t bar() {
22 ;     return A().getFoo();
23 ; }
24 ;
25 ; CHECK:      DW_TAG_class_type
26 ; CHECK-NEXT:   DW_AT_name {{.*}} "A"
27 ; CHECK-NOT:  DW_TAG
28 ; CHECK:      DW_TAG_member
29 ; CHECK-NEXT:   DW_AT_name {{.*}} "data"
30 ; CHECK-NOT:  DW_TAG
31 ; CHECK:      DW_TAG_subprogram
32 ; CHECK-NOT: DW_TAG
33 ; CHECK:   DW_AT_linkage_name {{.*}} "_ZN1A6getFooEv"
34 ; CHECK-NOT: DW_TAG
35 ; CHECK:   DW_AT_name {{.*}} "getFoo"
36 ; CHECK:      DW_TAG_subprogram
37 ; CHECK-NOT: DW_TAG
38 ; CHECK:   DW_AT_linkage_name {{.*}} "_Z3bazv"
39 ; CHECK:      DW_TAG_subprogram
40 ; CHECK-NOT: DW_TAG
41 ; CHECK:   DW_AT_linkage_name {{.*}} "_ZL3barv"
42
43 ; getFoo and A may only appear once.
44 ; CHECK-NOT:  AT_name{{.*(getFoo)|("A")}}
45
46
47 ; ModuleID = 'type-unique-odr-a.cpp'
48
49 %class.A = type { i32 }
50
51 ; Function Attrs: nounwind
52 define void @_Z3bazv() #0 !dbg !15 {
53 entry:
54   call void @_ZL3barv(), !dbg !23
55   ret void, !dbg !23
56 }
57
58 ; Function Attrs: nounwind
59 define internal void @_ZL3barv() #0 !dbg !19 {
60 entry:
61   %a = alloca %class.A, align 4
62   call void @llvm.dbg.declare(metadata %class.A* %a, metadata !24, metadata !DIExpression()), !dbg !25
63   ret void, !dbg !26
64 }
65
66 ; Function Attrs: nounwind readnone
67 declare void @llvm.dbg.declare(metadata, metadata, metadata) #1
68
69 attributes #0 = { nounwind }
70 attributes #1 = { nounwind readnone }
71
72 !llvm.dbg.cu = !{!0}
73 !llvm.module.flags = !{!20, !21}
74 !llvm.ident = !{!22}
75
76 !0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, producer: "clang version 3.5.0 ", isOptimized: false, emissionKind: 1, file: !1, enums: !2, retainedTypes: !3, subprograms: !14, globals: !2, imports: !2)
77 !1 = !DIFile(filename: "<unknown>", directory: "")
78 !2 = !{}
79 !3 = !{!4}
80 !4 = !DICompositeType(tag: DW_TAG_class_type, name: "A", line: 1, size: 32, align: 32, file: !5, elements: !6, identifier: "_ZTS1A")
81 !5 = !DIFile(filename: "type-unique-odr-a.cpp", directory: "")
82 !6 = !{!7, !9}
83 !7 = !DIDerivedType(tag: DW_TAG_member, name: "data", line: 2, size: 32, align: 32, flags: DIFlagPrivate, file: !5, scope: !"_ZTS1A", baseType: !8)
84 !8 = !DIBasicType(tag: DW_TAG_base_type, name: "int", size: 32, align: 32, encoding: DW_ATE_signed)
85 !9 = !DISubprogram(name: "getFoo", linkageName: "_ZN1A6getFooEv", line: 4, isLocal: false, isDefinition: false, virtualIndex: 6, flags: DIFlagProtected | DIFlagPrototyped, isOptimized: false, scopeLine: 4, file: !5, scope: !"_ZTS1A", type: !10)
86 !10 = !DISubroutineType(types: !11)
87 !11 = !{null, !12}
88 !12 = !DIDerivedType(tag: DW_TAG_pointer_type, size: 64, align: 64, flags: DIFlagArtificial | DIFlagObjectPointer, baseType: !"_ZTS1A")
89 !14 = !{!15, !19}
90 !15 = distinct !DISubprogram(name: "baz", linkageName: "_Z3bazv", line: 11, isLocal: false, isDefinition: true, virtualIndex: 6, flags: DIFlagPrototyped, isOptimized: false, scopeLine: 11, file: !5, scope: !16, type: !17, variables: !2)
91 !16 = !DIFile(filename: "type-unique-odr-a.cpp", directory: "")
92 !17 = !DISubroutineType(types: !18)
93 !18 = !{null}
94 !19 = distinct !DISubprogram(name: "bar", linkageName: "_ZL3barv", line: 7, isLocal: true, isDefinition: true, virtualIndex: 6, flags: DIFlagPrototyped, isOptimized: false, scopeLine: 7, file: !5, scope: !16, type: !17, variables: !2)
95 !20 = !{i32 2, !"Dwarf Version", i32 4}
96 !21 = !{i32 1, !"Debug Info Version", i32 3}
97 !22 = !{!"clang version 3.5.0 "}
98 !23 = !DILocation(line: 11, scope: !15)
99 !24 = !DILocalVariable(name: "a", line: 8, scope: !19, file: !16, type: !"_ZTS1A")
100 !25 = !DILocation(line: 8, scope: !19)
101 !26 = !DILocation(line: 9, scope: !19)