blob: 2f4937c7171a825e4e7fdcc9f9eec1a924bef4f2 [file] [log] [blame]
David Blaikied8f0ac72014-04-28 20:27:02 +00001; REQUIRES: object-emission
2
Adrian Prantl16aa4cf2017-09-11 23:05:20 +00003; RUN: llc -mtriple=x86_64-linux -O0 -filetype=obj < %s | llvm-dwarfdump -v -debug-info - | FileCheck %s
David Blaikied8f0ac72014-04-28 20:27:02 +00004
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
Adrian Prantl1eadba12016-12-22 00:45:21 +000035source_filename = "test/DebugInfo/X86/inline-member-function.ll"
36
David Blaikied8f0ac72014-04-28 20:27:02 +000037%struct.foo = type { i8 }
38
Adrian Prantl1eadba12016-12-22 00:45:21 +000039@i = global i32 0, align 4, !dbg !0
David Blaikied8f0ac72014-04-28 20:27:02 +000040
41; Function Attrs: uwtable
Adrian Prantl1eadba12016-12-22 00:45:21 +000042define i32 @main() #0 !dbg !17 {
David Blaikied8f0ac72014-04-28 20:27:02 +000043entry:
44 %this.addr.i = alloca %struct.foo*, align 8
45 %x.addr.i = alloca i32, align 4
46 %retval = alloca i32, align 4
47 %tmp = alloca %struct.foo, align 1
48 store i32 0, i32* %retval
Adrian Prantl1eadba12016-12-22 00:45:21 +000049 %0 = load i32, i32* @i, align 4, !dbg !20
David Blaikied8f0ac72014-04-28 20:27:02 +000050 store %struct.foo* %tmp, %struct.foo** %this.addr.i, align 8
Adrian Prantl1eadba12016-12-22 00:45:21 +000051 call void @llvm.dbg.declare(metadata %struct.foo** %this.addr.i, metadata !21, metadata !24), !dbg !25
David Blaikied8f0ac72014-04-28 20:27:02 +000052 store i32 %0, i32* %x.addr.i, align 4
Adrian Prantl1eadba12016-12-22 00:45:21 +000053 call void @llvm.dbg.declare(metadata i32* %x.addr.i, metadata !26, metadata !24), !dbg !27
David Blaikiea79ac142015-02-27 21:17:42 +000054 %this1.i = load %struct.foo*, %struct.foo** %this.addr.i
Adrian Prantl1eadba12016-12-22 00:45:21 +000055 %1 = load i32, i32* %x.addr.i, align 4, !dbg !27
56 %add.i = add nsw i32 %1, 2, !dbg !27
57 ret i32 %add.i, !dbg !20
David Blaikied8f0ac72014-04-28 20:27:02 +000058}
59
60; Function Attrs: nounwind readnone
Adrian Prantl1eadba12016-12-22 00:45:21 +000061
Adrian Prantl87b7eb92014-10-01 18:55:02 +000062declare void @llvm.dbg.declare(metadata, metadata, metadata) #1
David Blaikied8f0ac72014-04-28 20:27:02 +000063
Fangrui Song502a77f2019-12-24 15:52:21 -080064attributes #0 = { uwtable "less-precise-fpmad"="false" "frame-pointer"="all" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "stack-protector-buffer-size"="8" "unsafe-fp-math"="false" "use-soft-float"="false" }
David Blaikied8f0ac72014-04-28 20:27:02 +000065attributes #1 = { nounwind readnone }
66
Adrian Prantl1eadba12016-12-22 00:45:21 +000067!llvm.dbg.cu = !{!4}
68!llvm.module.flags = !{!14, !15}
69!llvm.ident = !{!16}
David Blaikied8f0ac72014-04-28 20:27:02 +000070
Adrian Prantl05782212017-08-30 18:06:51 +000071!0 = !DIGlobalVariableExpression(var: !1, expr: !DIExpression())
Adrian Prantl1eadba12016-12-22 00:45:21 +000072!1 = !DIGlobalVariable(name: "i", scope: null, file: !2, line: 5, type: !3, isLocal: false, isDefinition: true)
73!2 = !DIFile(filename: "inline.cpp", directory: "/tmp/dbginfo")
74!3 = !DIBasicType(name: "int", size: 32, align: 32, encoding: DW_ATE_signed)
75!4 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, file: !2, producer: "clang version 3.5.0 ", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, enums: !5, retainedTypes: !6, globals: !13, imports: !5)
76!5 = !{}
77!6 = !{!7}
78!7 = !DICompositeType(tag: DW_TAG_structure_type, name: "foo", file: !2, line: 1, size: 8, align: 8, elements: !8, identifier: "_ZTS3foo")
79!8 = !{!9}
80!9 = !DISubprogram(name: "func", linkageName: "_ZN3foo4funcEi", scope: !7, file: !2, line: 2, type: !10, isLocal: false, isDefinition: false, scopeLine: 2, virtualIndex: 6, flags: DIFlagPrototyped, isOptimized: false)
81!10 = !DISubroutineType(types: !11)
82!11 = !{!3, !12, !3}
83!12 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !7, size: 64, align: 64, flags: DIFlagArtificial | DIFlagObjectPointer)
84!13 = !{!0}
85!14 = !{i32 2, !"Dwarf Version", i32 4}
86!15 = !{i32 1, !"Debug Info Version", i32 3}
87!16 = !{!"clang version 3.5.0 "}
Shiva Chen2c864552018-05-09 02:40:45 +000088!17 = distinct !DISubprogram(name: "main", scope: !2, file: !2, line: 7, type: !18, isLocal: false, isDefinition: true, scopeLine: 7, virtualIndex: 6, flags: DIFlagPrototyped, isOptimized: false, unit: !4, retainedNodes: !5)
Adrian Prantl1eadba12016-12-22 00:45:21 +000089!18 = !DISubroutineType(types: !19)
90!19 = !{!3}
91!20 = !DILocation(line: 8, scope: !17)
92!21 = !DILocalVariable(name: "this", arg: 1, scope: !22, type: !23, flags: DIFlagArtificial | DIFlagObjectPointer)
Shiva Chen2c864552018-05-09 02:40:45 +000093!22 = distinct !DISubprogram(name: "func", linkageName: "_ZN3foo4funcEi", scope: !7, file: !2, line: 2, type: !10, isLocal: false, isDefinition: true, scopeLine: 2, virtualIndex: 6, flags: DIFlagPrototyped, isOptimized: false, unit: !4, declaration: !9, retainedNodes: !5)
Adrian Prantl1eadba12016-12-22 00:45:21 +000094!23 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !7, size: 64, align: 64)
95!24 = !DIExpression()
96!25 = !DILocation(line: 0, scope: !22, inlinedAt: !20)
97!26 = !DILocalVariable(name: "x", arg: 2, scope: !22, file: !2, line: 2, type: !3)
98!27 = !DILocation(line: 2, scope: !22, inlinedAt: !20)
99