blob: 376505f9832e9e6cf72afbf5d56dc9a294eee36c [file] [log] [blame]
Duncan P. N. Exon Smith7bb480d2015-04-16 22:27:54 +00001; RUN: llc -filetype=obj -o %t.o %s
Adrian Prantl16aa4cf2017-09-11 23:05:20 +00002; RUN: llvm-dwarfdump -v %t.o | FileCheck %s
Duncan P. N. Exon Smith7bb480d2015-04-16 22:27:54 +00003
Duncan P. N. Exon Smith05f53ae2015-04-17 00:18:46 +00004; Testcase generated using 'clang -g -O2 -S -emit-llvm' from the following:
Duncan P. N. Exon Smitha09bcd02015-04-17 00:37:53 +00005;; void sink(void);
Duncan P. N. Exon Smith05f53ae2015-04-17 00:18:46 +00006;; static __attribute__((always_inline)) void bar(int a) { sink(); }
Duncan P. N. Exon Smitha09bcd02015-04-17 00:37:53 +00007;; void foo(void) {
Duncan P. N. Exon Smith05f53ae2015-04-17 00:18:46 +00008;; bar(0);
9;; bar(0);
Duncan P. N. Exon Smith7bb480d2015-04-16 22:27:54 +000010;; }
11
Duncan P. N. Exon Smith05f53ae2015-04-17 00:18:46 +000012; Check that we have formal parameters for 'a' in both inlined subroutines.
Adrian Prantl274bcbc2017-06-16 22:40:04 +000013; CHECK: .debug_info
Duncan P. N. Exon Smith7bb480d2015-04-16 22:27:54 +000014; CHECK: DW_TAG_inlined_subroutine
Duncan P. N. Exon Smith05f53ae2015-04-17 00:18:46 +000015; CHECK-NEXT: DW_AT_abstract_origin {{.*}} "bar"
Duncan P. N. Exon Smith7bb480d2015-04-16 22:27:54 +000016; CHECK: DW_TAG_formal_parameter
17; CHECK-NEXT: DW_AT_const_value
18; CHECK-NEXT: DW_AT_abstract_origin {{.*}} "a"
Duncan P. N. Exon Smith05f53ae2015-04-17 00:18:46 +000019; CHECK: DW_TAG_inlined_subroutine
20; CHECK-NEXT: DW_AT_abstract_origin {{.*}} "bar"
21; CHECK: DW_TAG_formal_parameter
OCHyams57d8aca2020-08-27 09:40:53 +010022; CHECK-NEXT: DW_AT_const_value [DW_FORM_sdata] (0)
Duncan P. N. Exon Smith05f53ae2015-04-17 00:18:46 +000023; CHECK-NEXT: DW_AT_abstract_origin {{.*}} "a"
Reid Klecknera0587362017-08-29 21:41:21 +000024
Duncan P. N. Exon Smith7bb480d2015-04-16 22:27:54 +000025target datalayout = "e-m:o-i64:64-f80:128-n8:16:32:64-S128"
26target triple = "x86_64-apple-darwin"
27
Duncan P. N. Exon Smith7bb480d2015-04-16 22:27:54 +000028; Function Attrs: nounwind ssp uwtable
Peter Collingbourned4bff302015-11-05 22:03:56 +000029define void @foo() #0 !dbg !4 {
Duncan P. N. Exon Smith7bb480d2015-04-16 22:27:54 +000030entry:
Adrian Prantlabe04752017-07-28 20:21:02 +000031 tail call void @llvm.dbg.value(metadata i32 0, metadata !12, metadata !17) #3, !dbg !18
Duncan P. N. Exon Smitha09bcd02015-04-17 00:37:53 +000032 tail call void @sink() #3, !dbg !20
Adrian Prantlabe04752017-07-28 20:21:02 +000033 tail call void @llvm.dbg.value(metadata i32 0, metadata !12, metadata !17) #3, !dbg !21
Duncan P. N. Exon Smitha09bcd02015-04-17 00:37:53 +000034 tail call void @sink() #3, !dbg !23
Duncan P. N. Exon Smith05f53ae2015-04-17 00:18:46 +000035 ret void, !dbg !24
Duncan P. N. Exon Smith7bb480d2015-04-16 22:27:54 +000036}
37
Adrian Prantl274bcbc2017-06-16 22:40:04 +000038declare void @sink()
Duncan P. N. Exon Smith05f53ae2015-04-17 00:18:46 +000039
Duncan P. N. Exon Smith7bb480d2015-04-16 22:27:54 +000040; Function Attrs: nounwind readnone
Adrian Prantlabe04752017-07-28 20:21:02 +000041declare void @llvm.dbg.value(metadata, metadata, metadata) #2
Duncan P. N. Exon Smith7bb480d2015-04-16 22:27:54 +000042
Adrian Prantl274bcbc2017-06-16 22:40:04 +000043attributes #0 = { nounwind ssp uwtable }
Duncan P. N. Exon Smith05f53ae2015-04-17 00:18:46 +000044attributes #2 = { nounwind readnone }
45attributes #3 = { nounwind }
Duncan P. N. Exon Smith7bb480d2015-04-16 22:27:54 +000046
47!llvm.dbg.cu = !{!0}
Duncan P. N. Exon Smith05f53ae2015-04-17 00:18:46 +000048!llvm.module.flags = !{!13, !14, !15}
49!llvm.ident = !{!16}
Duncan P. N. Exon Smith7bb480d2015-04-16 22:27:54 +000050
Adrian Prantl75819aed2016-04-15 15:57:41 +000051!0 = distinct !DICompileUnit(language: DW_LANG_C99, file: !1, producer: "clang version 3.7.0 (trunk 235110) (llvm/trunk 235108)", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, enums: !2, retainedTypes: !2, globals: !2, imports: !2)
Duncan P. N. Exon Smitha9308c42015-04-29 16:38:44 +000052!1 = !DIFile(filename: "t.c", directory: "/path/to/dir")
Duncan P. N. Exon Smith7bb480d2015-04-16 22:27:54 +000053!2 = !{}
Shiva Chen2c864552018-05-09 02:40:45 +000054!4 = distinct !DISubprogram(name: "foo", scope: !1, file: !1, line: 3, type: !5, isLocal: false, isDefinition: true, scopeLine: 3, flags: DIFlagPrototyped, isOptimized: true, unit: !0, retainedNodes: !2)
Duncan P. N. Exon Smitha9308c42015-04-29 16:38:44 +000055!5 = !DISubroutineType(types: !6)
Duncan P. N. Exon Smith05f53ae2015-04-17 00:18:46 +000056!6 = !{null}
Shiva Chen2c864552018-05-09 02:40:45 +000057!7 = distinct !DISubprogram(name: "bar", scope: !1, file: !1, line: 2, type: !8, isLocal: true, isDefinition: true, scopeLine: 2, flags: DIFlagPrototyped, isOptimized: true, unit: !0, retainedNodes: !11)
Duncan P. N. Exon Smitha9308c42015-04-29 16:38:44 +000058!8 = !DISubroutineType(types: !9)
Duncan P. N. Exon Smith05f53ae2015-04-17 00:18:46 +000059!9 = !{null, !10}
Duncan P. N. Exon Smitha9308c42015-04-29 16:38:44 +000060!10 = !DIBasicType(name: "int", size: 32, align: 32, encoding: DW_ATE_signed)
Duncan P. N. Exon Smith05f53ae2015-04-17 00:18:46 +000061!11 = !{!12}
Duncan P. N. Exon Smithed013cd2015-07-31 18:58:39 +000062!12 = !DILocalVariable(name: "a", arg: 1, scope: !7, file: !1, line: 2, type: !10)
Duncan P. N. Exon Smith05f53ae2015-04-17 00:18:46 +000063!13 = !{i32 2, !"Dwarf Version", i32 2}
64!14 = !{i32 2, !"Debug Info Version", i32 3}
65!15 = !{i32 1, !"PIC Level", i32 2}
66!16 = !{!"clang version 3.7.0 (trunk 235110) (llvm/trunk 235108)"}
Duncan P. N. Exon Smitha9308c42015-04-29 16:38:44 +000067!17 = !DIExpression()
68!18 = !DILocation(line: 2, column: 52, scope: !7, inlinedAt: !19)
69!19 = distinct !DILocation(line: 4, column: 3, scope: !4)
70!20 = !DILocation(line: 2, column: 57, scope: !7, inlinedAt: !19)
71!21 = !DILocation(line: 2, column: 52, scope: !7, inlinedAt: !22)
72!22 = distinct !DILocation(line: 5, column: 3, scope: !4)
73!23 = !DILocation(line: 2, column: 57, scope: !7, inlinedAt: !22)
74!24 = !DILocation(line: 6, column: 1, scope: !4)