Home | History | Annotate | Download | only in X86
      1 ; REQUIRES: object-emission
      2 
      3 ; RUN: llc -mtriple x86_64-pc-linux -O0 -filetype=obj %s -o %t
      4 ; RUN: llvm-dwarfdump %t | FileCheck %s
      5 
      6 ; Testcase from:
      7 ; struct base {
      8 ;  virtual ~base();
      9 ; };
     10 ; typedef base base_type;
     11 ; struct foo {
     12 ;  base_type b;
     13 ; };
     14 ; foo f;
     15 
     16 ; Where member b should be seen as a field at an offset and not a bitfield.
     17 
     18 ; CHECK: DW_TAG_member
     19 ; CHECK: DW_AT_name{{.*}}"b"
     20 ; CHECK-NOT: DW_AT_bit_offset
     21 
     22 source_filename = "test/DebugInfo/X86/decl-derived-member.ll"
     23 
     24 %struct.foo = type { %struct.base }
     25 %struct.base = type { i32 (...)** }
     26 
     27 $_ZN3fooC2Ev = comdat any
     28 
     29 $_ZN3fooD2Ev = comdat any
     30 
     31 $_ZN4baseC2Ev = comdat any
     32 
     33 @f = global %struct.foo zeroinitializer, align 8, !dbg !0
     34 @__dso_handle = external global i8
     35 @_ZTV4base = external unnamed_addr constant [4 x i8*]
     36 @llvm.global_ctors = appending global [1 x { i32, void ()*, i8* }] [{ i32, void ()*, i8* } { i32 65535, void ()* @_GLOBAL__sub_I_decl_derived_member.cpp, i8* null }]
     37 
     38 define internal void @__cxx_global_var_init() section ".text.startup" !dbg !15 {
     39 entry:
     40   call void @_ZN3fooC2Ev(%struct.foo* @f) #2, !dbg !18
     41   %0 = call i32 @__cxa_atexit(void (i8*)* bitcast (void (%struct.foo*)* @_ZN3fooD2Ev to void (i8*)*), i8* bitcast (%struct.foo* @f to i8*), i8* @__dso_handle) #2, !dbg !18
     42   ret void, !dbg !18
     43 }
     44 
     45 ; Function Attrs: inlinehint nounwind uwtable
     46 define linkonce_odr void @_ZN3fooC2Ev(%struct.foo* %this) unnamed_addr #0 comdat align 2 !dbg !19 {
     47 entry:
     48   %this.addr = alloca %struct.foo*, align 8
     49   store %struct.foo* %this, %struct.foo** %this.addr, align 8
     50   call void @llvm.dbg.declare(metadata %struct.foo** %this.addr, metadata !24, metadata !26), !dbg !27
     51   %this1 = load %struct.foo*, %struct.foo** %this.addr
     52   %b = getelementptr inbounds %struct.foo, %struct.foo* %this1, i32 0, i32 0, !dbg !28
     53   call void @_ZN4baseC2Ev(%struct.base* %b) #2, !dbg !28
     54   ret void, !dbg !28
     55 }
     56 
     57 ; Function Attrs: inlinehint uwtable
     58 define linkonce_odr void @_ZN3fooD2Ev(%struct.foo* %this) unnamed_addr #1 comdat align 2 !dbg !29 {
     59 entry:
     60   %this.addr = alloca %struct.foo*, align 8
     61   store %struct.foo* %this, %struct.foo** %this.addr, align 8
     62   call void @llvm.dbg.declare(metadata %struct.foo** %this.addr, metadata !31, metadata !26), !dbg !32
     63   %this1 = load %struct.foo*, %struct.foo** %this.addr
     64   %b = getelementptr inbounds %struct.foo, %struct.foo* %this1, i32 0, i32 0, !dbg !33
     65   call void @_ZN4baseD1Ev(%struct.base* %b), !dbg !33
     66   ret void, !dbg !35
     67 }
     68 
     69 ; Function Attrs: nounwind
     70 declare i32 @__cxa_atexit(void (i8*)*, i8*, i8*) #2
     71 
     72 ; Function Attrs: nounwind readnone
     73 declare void @llvm.dbg.declare(metadata, metadata, metadata) #3
     74 
     75 ; Function Attrs: inlinehint nounwind uwtable
     76 define linkonce_odr void @_ZN4baseC2Ev(%struct.base* %this) unnamed_addr #0 comdat align 2 !dbg !36 {
     77 entry:
     78   %this.addr = alloca %struct.base*, align 8
     79   store %struct.base* %this, %struct.base** %this.addr, align 8
     80   call void @llvm.dbg.declare(metadata %struct.base** %this.addr, metadata !41, metadata !26), !dbg !43
     81   %this1 = load %struct.base*, %struct.base** %this.addr
     82   %0 = bitcast %struct.base* %this1 to i32 (...)***, !dbg !44
     83   store i32 (...)** bitcast (i8** getelementptr inbounds ([4 x i8*], [4 x i8*]* @_ZTV4base, i64 0, i64 2) to i32 (...)**), i32 (...)*** %0, !dbg !44
     84   ret void, !dbg !44
     85 }
     86 
     87 declare void @_ZN4baseD1Ev(%struct.base*) #4
     88 
     89 define internal void @_GLOBAL__sub_I_decl_derived_member.cpp() section ".text.startup" {
     90 entry:
     91   call void @__cxx_global_var_init(), !dbg !45
     92   ret void
     93 }
     94 
     95 attributes #0 = { inlinehint nounwind uwtable "less-precise-fpmad"="false" "no-frame-pointer-elim"="true" "no-frame-pointer-elim-non-leaf" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "stack-protector-buffer-size"="8" "unsafe-fp-math"="false" "use-soft-float"="false" }
     96 attributes #1 = { inlinehint uwtable "less-precise-fpmad"="false" "no-frame-pointer-elim"="true" "no-frame-pointer-elim-non-leaf" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "stack-protector-buffer-size"="8" "unsafe-fp-math"="false" "use-soft-float"="false" }
     97 attributes #2 = { nounwind }
     98 attributes #3 = { nounwind readnone }
     99 attributes #4 = { "less-precise-fpmad"="false" "no-frame-pointer-elim"="true" "no-frame-pointer-elim-non-leaf" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "stack-protector-buffer-size"="8" "unsafe-fp-math"="false" "use-soft-float"="false" }
    100 
    101 !llvm.dbg.cu = !{!8}
    102 !llvm.module.flags = !{!12, !13}
    103 !llvm.ident = !{!14}
    104 
    105 !0 = !DIGlobalVariableExpression(var: !1, expr: !DIExpression())
    106 !1 = !DIGlobalVariable(name: "f", scope: null, file: !2, line: 8, type: !3, isLocal: false, isDefinition: true)
    107 !2 = !DIFile(filename: "decl-derived-member.cpp", directory: "/tmp/dbginfo")
    108 !3 = !DICompositeType(tag: DW_TAG_structure_type, name: "foo", file: !2, line: 5, size: 64, align: 64, elements: !4, identifier: "_ZTS3foo")
    109 !4 = !{!5}
    110 !5 = !DIDerivedType(tag: DW_TAG_member, name: "b", scope: !3, file: !2, line: 6, baseType: !6, size: 64, align: 64)
    111 !6 = !DIDerivedType(tag: DW_TAG_typedef, name: "base_type", file: !2, line: 4, baseType: !7)
    112 !7 = !DICompositeType(tag: DW_TAG_structure_type, name: "base", file: !2, line: 1, flags: DIFlagFwdDecl, identifier: "_ZTS4base")
    113 !8 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, file: !2, producer: "clang version 3.7.0 (trunk 227104) (llvm/trunk 227103)", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, enums: !9, retainedTypes: !10, globals: !11, imports: !9)
    114 !9 = !{}
    115 !10 = !{!3, !7}
    116 !11 = !{!0}
    117 !12 = !{i32 2, !"Dwarf Version", i32 4}
    118 !13 = !{i32 2, !"Debug Info Version", i32 3}
    119 !14 = !{!"clang version 3.7.0 (trunk 227104) (llvm/trunk 227103)"}
    120 !15 = distinct !DISubprogram(name: "__cxx_global_var_init", scope: !2, file: !2, line: 8, type: !16, isLocal: true, isDefinition: true, scopeLine: 8, flags: DIFlagPrototyped, isOptimized: false, unit: !8, retainedNodes: !9)
    121 !16 = !DISubroutineType(types: !17)
    122 !17 = !{null}
    123 !18 = !DILocation(line: 8, column: 5, scope: !15)
    124 !19 = distinct !DISubprogram(name: "foo", linkageName: "_ZN3fooC2Ev", scope: !3, file: !2, line: 5, type: !20, isLocal: false, isDefinition: true, scopeLine: 5, flags: DIFlagArtificial | DIFlagPrototyped, isOptimized: false, unit: !8, declaration: !23, retainedNodes: !9)
    125 !20 = !DISubroutineType(types: !21)
    126 !21 = !{null, !22}
    127 !22 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !3, size: 64, align: 64, flags: DIFlagArtificial | DIFlagObjectPointer)
    128 !23 = !DISubprogram(name: "foo", scope: !3, type: !20, isLocal: false, isDefinition: false, flags: DIFlagArtificial | DIFlagPrototyped, isOptimized: false)
    129 !24 = !DILocalVariable(name: "this", arg: 1, scope: !19, type: !25, flags: DIFlagArtificial | DIFlagObjectPointer)
    130 !25 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !3, size: 64, align: 64)
    131 !26 = !DIExpression()
    132 !27 = !DILocation(line: 0, scope: !19)
    133 !28 = !DILocation(line: 5, column: 8, scope: !19)
    134 !29 = distinct !DISubprogram(name: "~foo", linkageName: "_ZN3fooD2Ev", scope: !3, file: !2, line: 5, type: !20, isLocal: false, isDefinition: true, scopeLine: 5, flags: DIFlagArtificial | DIFlagPrototyped, isOptimized: false, unit: !8, declaration: !30, retainedNodes: !9)
    135 !30 = !DISubprogram(name: "~foo", scope: !3, type: !20, isLocal: false, isDefinition: false, flags: DIFlagArtificial | DIFlagPrototyped, isOptimized: false)
    136 !31 = !DILocalVariable(name: "this", arg: 1, scope: !29, type: !25, flags: DIFlagArtificial | DIFlagObjectPointer)
    137 !32 = !DILocation(line: 0, scope: !29)
    138 !33 = !DILocation(line: 5, column: 8, scope: !34)
    139 !34 = distinct !DILexicalBlock(scope: !29, file: !2, line: 5, column: 8)
    140 !35 = !DILocation(line: 5, column: 8, scope: !29)
    141 !36 = distinct !DISubprogram(name: "base", linkageName: "_ZN4baseC2Ev", scope: !7, file: !2, line: 1, type: !37, isLocal: false, isDefinition: true, scopeLine: 1, flags: DIFlagArtificial | DIFlagPrototyped, isOptimized: false, unit: !8, declaration: !40, retainedNodes: !9)
    142 !37 = !DISubroutineType(types: !38)
    143 !38 = !{null, !39}
    144 !39 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !7, size: 64, align: 64, flags: DIFlagArtificial | DIFlagObjectPointer)
    145 !40 = !DISubprogram(name: "base", scope: !7, type: !37, isLocal: false, isDefinition: false, flags: DIFlagArtificial | DIFlagPrototyped, isOptimized: false)
    146 !41 = !DILocalVariable(name: "this", arg: 1, scope: !36, type: !42, flags: DIFlagArtificial | DIFlagObjectPointer)
    147 !42 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !7, size: 64, align: 64)
    148 !43 = !DILocation(line: 0, scope: !36)
    149 !44 = !DILocation(line: 1, column: 8, scope: !36)
    150 !45 = !DILocation(line: 0, scope: !46)
    151 !46 = distinct !DISubprogram(linkageName: "_GLOBAL__sub_I_decl_derived_member.cpp", scope: !2, file: !2, type: !47, isLocal: true, isDefinition: true, flags: DIFlagArtificial, isOptimized: false, unit: !8, retainedNodes: !9)
    152 !47 = !DISubroutineType(types: !9)
    153 
    154