blob: 712a20c3a4a82e3a319834d1bd8df44fe5f5e543 [file] [log] [blame]
David Blaikied8f0ac72014-04-28 20:27:02 +00001; REQUIRES: object-emission
2
3; RUN: llc -mtriple=x86_64-linux -O0 -filetype=obj < %s | llvm-dwarfdump -debug-dump=info - | FileCheck %s
4
5; From source:
6; struct foo {
7; int __attribute__((always_inline)) func(int x) { return x + 2; }
8; };
9
10; int i;
11
12; int main() {
13; return foo().func(i);
14; }
15
David Blaikie3c2fff32014-05-27 18:37:48 +000016; CHECK: DW_TAG_structure_type
17; CHECK: DW_TAG_subprogram
18
19; But make sure we emit DW_AT_object_pointer on the abstract definition.
20; CHECK: [[ABSTRACT_ORIGIN:.*]]: DW_TAG_subprogram
Frederic Rissd1cfc3c2014-10-06 03:36:31 +000021; CHECK-NOT: {{NULL|TAG}}
22; CHECK: DW_AT_specification {{.*}} "_ZN3foo4funcEi"
23; CHECK-NOT: {{NULL|TAG}}
David Blaikie3c2fff32014-05-27 18:37:48 +000024; CHECK: DW_AT_object_pointer
25
David Blaikied8f0ac72014-04-28 20:27:02 +000026; Ensure we omit DW_AT_object_pointer on inlined subroutines.
27; CHECK: DW_TAG_inlined_subroutine
Frederic Rissd1cfc3c2014-10-06 03:36:31 +000028; CHECK-NEXT: DW_AT_abstract_origin {{.*}} {[[ABSTRACT_ORIGIN]]} "_ZN3foo4funcEi"
David Blaikied8f0ac72014-04-28 20:27:02 +000029; CHECK-NOT: NULL
30; CHECK-NOT: DW_AT_object_pointer
David Blaikie44078b32014-04-30 22:41:33 +000031; CHECK: DW_TAG_formal_parameter
32; CHECK-NOT: DW_AT_artificial
David Blaikied8f0ac72014-04-28 20:27:02 +000033; CHECK: DW_TAG
34
David Blaikied8f0ac72014-04-28 20:27:02 +000035%struct.foo = type { i8 }
36
37@i = global i32 0, align 4
38
39; Function Attrs: uwtable
Peter Collingbourned4bff302015-11-05 22:03:56 +000040define i32 @main() #0 !dbg !13 {
David Blaikied8f0ac72014-04-28 20:27:02 +000041entry:
42 %this.addr.i = alloca %struct.foo*, align 8
43 %x.addr.i = alloca i32, align 4
44 %retval = alloca i32, align 4
45 %tmp = alloca %struct.foo, align 1
46 store i32 0, i32* %retval
David Blaikiea79ac142015-02-27 21:17:42 +000047 %0 = load i32, i32* @i, align 4, !dbg !23
David Blaikied8f0ac72014-04-28 20:27:02 +000048 store %struct.foo* %tmp, %struct.foo** %this.addr.i, align 8
Duncan P. N. Exon Smitha9308c42015-04-29 16:38:44 +000049 call void @llvm.dbg.declare(metadata %struct.foo** %this.addr.i, metadata !24, metadata !DIExpression()), !dbg !26
David Blaikied8f0ac72014-04-28 20:27:02 +000050 store i32 %0, i32* %x.addr.i, align 4
Duncan P. N. Exon Smitha9308c42015-04-29 16:38:44 +000051 call void @llvm.dbg.declare(metadata i32* %x.addr.i, metadata !27, metadata !DIExpression()), !dbg !28
David Blaikiea79ac142015-02-27 21:17:42 +000052 %this1.i = load %struct.foo*, %struct.foo** %this.addr.i
53 %1 = load i32, i32* %x.addr.i, align 4, !dbg !28
David Blaikied8f0ac72014-04-28 20:27:02 +000054 %add.i = add nsw i32 %1, 2, !dbg !28
55 ret i32 %add.i, !dbg !23
56}
57
58; Function Attrs: nounwind readnone
Adrian Prantl87b7eb92014-10-01 18:55:02 +000059declare void @llvm.dbg.declare(metadata, metadata, metadata) #1
David Blaikied8f0ac72014-04-28 20:27:02 +000060
61attributes #0 = { 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" }
62attributes #1 = { nounwind readnone }
63
64!llvm.dbg.cu = !{!0}
65!llvm.module.flags = !{!20, !21}
66!llvm.ident = !{!22}
67
Duncan P. N. Exon Smith55ca9642015-08-03 17:26:41 +000068!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: !12, globals: !18, imports: !2)
Duncan P. N. Exon Smitha9308c42015-04-29 16:38:44 +000069!1 = !DIFile(filename: "inline.cpp", directory: "/tmp/dbginfo")
Duncan P. N. Exon Smithbe7ea192014-12-15 19:07:53 +000070!2 = !{}
71!3 = !{!4}
Duncan P. N. Exon Smitha9308c42015-04-29 16:38:44 +000072!4 = !DICompositeType(tag: DW_TAG_structure_type, name: "foo", line: 1, size: 8, align: 8, file: !1, elements: !5, identifier: "_ZTS3foo")
Duncan P. N. Exon Smithbe7ea192014-12-15 19:07:53 +000073!5 = !{!6}
Duncan P. N. Exon Smitha9308c42015-04-29 16:38:44 +000074!6 = !DISubprogram(name: "func", linkageName: "_ZN3foo4funcEi", line: 2, isLocal: false, isDefinition: false, virtualIndex: 6, flags: DIFlagPrototyped, isOptimized: false, scopeLine: 2, file: !1, scope: !"_ZTS3foo", type: !7)
75!7 = !DISubroutineType(types: !8)
Duncan P. N. Exon Smithbe7ea192014-12-15 19:07:53 +000076!8 = !{!9, !10, !9}
Duncan P. N. Exon Smitha9308c42015-04-29 16:38:44 +000077!9 = !DIBasicType(tag: DW_TAG_base_type, name: "int", size: 32, align: 32, encoding: DW_ATE_signed)
78!10 = !DIDerivedType(tag: DW_TAG_pointer_type, size: 64, align: 64, flags: DIFlagArtificial | DIFlagObjectPointer, baseType: !"_ZTS3foo")
Duncan P. N. Exon Smithbe7ea192014-12-15 19:07:53 +000079!12 = !{!13, !17}
Peter Collingbourned4bff302015-11-05 22:03:56 +000080!13 = distinct !DISubprogram(name: "main", line: 7, isLocal: false, isDefinition: true, virtualIndex: 6, flags: DIFlagPrototyped, isOptimized: false, scopeLine: 7, file: !1, scope: !14, type: !15, variables: !2)
Duncan P. N. Exon Smitha9308c42015-04-29 16:38:44 +000081!14 = !DIFile(filename: "inline.cpp", directory: "/tmp/dbginfo")
82!15 = !DISubroutineType(types: !16)
Duncan P. N. Exon Smithbe7ea192014-12-15 19:07:53 +000083!16 = !{!9}
Duncan P. N. Exon Smith814b8e92015-08-28 20:26:49 +000084!17 = distinct !DISubprogram(name: "func", linkageName: "_ZN3foo4funcEi", line: 2, isLocal: false, isDefinition: true, virtualIndex: 6, flags: DIFlagPrototyped, isOptimized: false, scopeLine: 2, file: !1, scope: !"_ZTS3foo", type: !7, declaration: !6, variables: !2)
Duncan P. N. Exon Smithbe7ea192014-12-15 19:07:53 +000085!18 = !{!19}
Duncan P. N. Exon Smitha9308c42015-04-29 16:38:44 +000086!19 = !DIGlobalVariable(name: "i", line: 5, isLocal: false, isDefinition: true, scope: null, file: !14, type: !9, variable: i32* @i)
Duncan P. N. Exon Smithbe7ea192014-12-15 19:07:53 +000087!20 = !{i32 2, !"Dwarf Version", i32 4}
Duncan P. N. Exon Smithe2741802015-03-03 17:24:31 +000088!21 = !{i32 1, !"Debug Info Version", i32 3}
Duncan P. N. Exon Smithbe7ea192014-12-15 19:07:53 +000089!22 = !{!"clang version 3.5.0 "}
Duncan P. N. Exon Smitha9308c42015-04-29 16:38:44 +000090!23 = !DILocation(line: 8, scope: !13)
Duncan P. N. Exon Smithed013cd2015-07-31 18:58:39 +000091!24 = !DILocalVariable(name: "this", arg: 1, flags: DIFlagArtificial | DIFlagObjectPointer, scope: !17, type: !25)
Duncan P. N. Exon Smitha9308c42015-04-29 16:38:44 +000092!25 = !DIDerivedType(tag: DW_TAG_pointer_type, size: 64, align: 64, baseType: !"_ZTS3foo")
93!26 = !DILocation(line: 0, scope: !17, inlinedAt: !23)
Duncan P. N. Exon Smithed013cd2015-07-31 18:58:39 +000094!27 = !DILocalVariable(name: "x", line: 2, arg: 2, scope: !17, file: !14, type: !9)
Duncan P. N. Exon Smitha9308c42015-04-29 16:38:44 +000095!28 = !DILocation(line: 2, scope: !17, inlinedAt: !23)