Home | History | Annotate | Download | only in Linker
      1 ; REQUIRES: default_triple, object-emission
      2 ;
      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 -debug-dump=info - \
      6 ; RUN:   | FileCheck %s
      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 -debug-dump=info - \
     10 ; RUN:   | FileCheck %s
     11 ;
     12 ; Test ODR-based type uniquing for C++ class members.
     13 ; rdar://problem/15851313.
     14 ;
     15 ; $ cat -n type-unique-odr-a.cpp
     16 ;     1	class A {
     17 ;     2	  int data;
     18 ;     3	protected:
     19 ;     4	  void getFoo();
     20 ;     5	};
     21 ;     6
     22 ;     7	static void bar() {
     23 ;     8	  A a;
     24 ;     9	}
     25 ;    10
     26 ;    11	void baz() { bar(); }
     27 ;; #include "ab.h"
     28 ; foo_t bar() {
     29 ;     return A().getFoo();
     30 ; }
     31 ;
     32 ; CHECK:      DW_TAG_class_type
     33 ; CHECK-NEXT:   DW_AT_name {{.*}} "A"
     34 ; CHECK-NOT:    DW_TAG
     35 ; CHECK:        DW_TAG_member
     36 ; CHECK-NEXT:     DW_AT_name {{.*}} "data"
     37 ; CHECK-NOT:    DW_TAG
     38 ; CHECK:        DW_TAG_subprogram
     39 ; CHECK-NOT:    DW_TAG
     40 ; CHECK:          DW_AT_linkage_name {{.*}} "_ZN1A6getFooEv"
     41 ; CHECK-NOT:    DW_TAG
     42 ; CHECK:          DW_AT_name {{.*}} "getFoo"
     43 
     44 ; Ensure that there aren't any other subprograms in class A.
     45 ; CHECK-NOT:      DW_TAG
     46 ; CHECK:          DW_TAG_formal_parameter
     47 ; CHECK-NOT:      DW_TAG
     48 ; CHECK:          NULL
     49 ; CHECK-NOT:    DW_TAG
     50 ; CHECK:        NULL
     51 ; CHECK-NOT:  DW_TAG
     52 ; CHECK:      DW_TAG_base_type
     53 
     54 ; Ensure that getFoo and A are only emitted once.
     55 ; CHECK-NOT:  AT_name{{.*(getFoo)|("A")}}
     56 
     57 ; ModuleID = 'type-unique-odr-a.cpp'
     58 
     59 %class.A = type { i32 }
     60 
     61 ; Function Attrs: nounwind
     62 define void @_Z3bazv() #0 !dbg !15 {
     63 entry:
     64   call void @_ZL3barv(), !dbg !23
     65   ret void, !dbg !23
     66 }
     67 
     68 ; Function Attrs: nounwind
     69 define internal void @_ZL3barv() #0 !dbg !19 {
     70 entry:
     71   %a = alloca %class.A, align 4
     72   call void @llvm.dbg.declare(metadata %class.A* %a, metadata !24, metadata !DIExpression()), !dbg !25
     73   ret void, !dbg !26
     74 }
     75 
     76 ; Function Attrs: nounwind readnone
     77 declare void @llvm.dbg.declare(metadata, metadata, metadata) #1
     78 
     79 attributes #0 = { nounwind }
     80 attributes #1 = { nounwind readnone }
     81 
     82 !llvm.dbg.cu = !{!0}
     83 !llvm.module.flags = !{!20, !21}
     84 !llvm.ident = !{!22}
     85 
     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: "")
     88 !2 = !{}
     89 !3 = !{!4}
     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: "")
     92 !6 = !{!7, !9}
     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)
     97 !11 = !{null, !12}
     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, variables: !2)
    100 !16 = !DIFile(filename: "type-unique-odr-a.cpp", directory: "")
    101 !17 = !DISubroutineType(types: !18)
    102 !18 = !{null}
    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, variables: !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)
    111