Home | History | Annotate | Download | only in Linker
      1 ; REQUIRES: object-emission
      2 ;
      3 ; RUN: llvm-link %s %p/type-unique-odr-b.ll -S -o - | %llc_dwarf -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_MIPS_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_MIPS_linkage_name {{.*}} "_Z3bazv"
     39 ; CHECK:      DW_TAG_subprogram
     40 ; CHECK-NOT: DW_TAG
     41 ; CHECK:   DW_AT_MIPS_linkage_name {{.*}} "_ZL3barv"
     42 
     43 ; getFoo and A may only appear once.
     44 ; CHECK-NOT:  {{(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 {
     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 {
     60 entry:
     61   %a = alloca %class.A, align 4
     62   call void @llvm.dbg.declare(metadata !{%class.A* %a}, metadata !24), !dbg !25
     63   ret void, !dbg !26
     64 }
     65 
     66 ; Function Attrs: nounwind readnone
     67 declare void @llvm.dbg.declare(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 = metadata !{i32 786449, metadata !1, i32 4, metadata !"clang version 3.5.0 ", i1 false, metadata !"", i32 0, metadata !2, metadata !3, metadata !14, metadata !2, metadata !2, metadata !"", i32 1} ; [ DW_TAG_compile_unit ] [<unknown>] [DW_LANG_C_plus_plus]
     77 !1 = metadata !{metadata !"<unknown>", metadata !""}
     78 !2 = metadata !{}
     79 !3 = metadata !{metadata !4}
     80 !4 = metadata !{i32 786434, metadata !5, null, metadata !"A", i32 1, i64 32, i64 32, i32 0, i32 0, null, metadata !6, i32 0, null, null, metadata !"_ZTS1A"} ; [ DW_TAG_class_type ] [A] [line 1, size 32, align 32, offset 0] [def] [from ]
     81 !5 = metadata !{metadata !"type-unique-odr-a.cpp", metadata !""}
     82 !6 = metadata !{metadata !7, metadata !9}
     83 !7 = metadata !{i32 786445, metadata !5, metadata !"_ZTS1A", metadata !"data", i32 2, i64 32, i64 32, i64 0, i32 1, metadata !8} ; [ DW_TAG_member ] [data] [line 2, size 32, align 32, offset 0] [private] [from int]
     84 !8 = metadata !{i32 786468, null, null, metadata !"int", i32 0, i64 32, i64 32, i64 0, i32 0, i32 5} ; [ DW_TAG_base_type ] [int] [line 0, size 32, align 32, offset 0, enc DW_ATE_signed]
     85 !9 = metadata !{i32 786478, metadata !5, metadata !"_ZTS1A", metadata !"getFoo", metadata !"getFoo", metadata !"_ZN1A6getFooEv", i32 4, metadata !10, i1 false, i1 false, i32 0, i32 0, null, i32 258, i1 false, null, null, i32 0, metadata !13, i32 4} ; [ DW_TAG_subprogram ] [line 4] [protected] [getFoo]
     86 !10 = metadata !{i32 786453, i32 0, null, metadata !"", i32 0, i64 0, i64 0, i64 0, i32 0, null, metadata !11, i32 0, null, null, null} ; [ DW_TAG_subroutine_type ] [line 0, size 0, align 0, offset 0] [from ]
     87 !11 = metadata !{null, metadata !12}
     88 !12 = metadata !{i32 786447, null, null, metadata !"", i32 0, i64 64, i64 64, i64 0, i32 1088, metadata !"_ZTS1A"} ; [ DW_TAG_pointer_type ] [line 0, size 64, align 64, offset 0] [artificial] [from _ZTS1A]
     89 !13 = metadata !{i32 786468}
     90 !14 = metadata !{metadata !15, metadata !19}
     91 !15 = metadata !{i32 786478, metadata !5, metadata !16, metadata !"baz", metadata !"baz", metadata !"_Z3bazv", i32 11, metadata !17, i1 false, i1 true, i32 0, i32 0, null, i32 256, i1 false, void ()* @_Z3bazv, null, null, metadata !2, i32 11} ; [ DW_TAG_subprogram ] [line 11] [def] [baz]
     92 !16 = metadata !{i32 786473, metadata !5}         ; [ DW_TAG_file_type ] [type-unique-odr-a.cpp]
     93 !17 = metadata !{i32 786453, i32 0, null, metadata !"", i32 0, i64 0, i64 0, i64 0, i32 0, null, metadata !18, i32 0, null, null, null} ; [ DW_TAG_subroutine_type ] [line 0, size 0, align 0, offset 0] [from ]
     94 !18 = metadata !{null}
     95 !19 = metadata !{i32 786478, metadata !5, metadata !16, metadata !"bar", metadata !"bar", metadata !"_ZL3barv", i32 7, metadata !17, i1 true, i1 true, i32 0, i32 0, null, i32 256, i1 false, void ()* @_ZL3barv, null, null, metadata !2, i32 7} ; [ DW_TAG_subprogram ] [line 7] [local] [def] [bar]
     96 !20 = metadata !{i32 2, metadata !"Dwarf Version", i32 4}
     97 !21 = metadata !{i32 1, metadata !"Debug Info Version", i32 1}
     98 !22 = metadata !{metadata !"clang version 3.5.0 "}
     99 !23 = metadata !{i32 11, i32 0, metadata !15, null}
    100 !24 = metadata !{i32 786688, metadata !19, metadata !"a", metadata !16, i32 8, metadata !"_ZTS1A", i32 0, i32 0} ; [ DW_TAG_auto_variable ] [a] [line 8]
    101 !25 = metadata !{i32 8, i32 0, metadata !19, null} ; [ DW_TAG_imported_declaration ]
    102 !26 = metadata !{i32 9, i32 0, metadata !19, null}
    103