blob: 5b0cd6275336e16d3c448af7377d0dbcaa00bd10 [file] [log] [blame]
Bill Wendlingbfc0e572012-12-04 06:20:49 +00001; RUN: llc -mtriple=x86_64-apple-darwin -O0 -filetype=obj -o %t < %s
Adrian Prantl16aa4cf2017-09-11 23:05:20 +00002; RUN: llvm-dwarfdump -v -debug-info %t | FileCheck %s
Bill Wendlingbfc0e572012-12-04 06:20:49 +00003; <rdar://problem/12566646>
4
5%struct.foo = type { i32, [1 x i32] }
6%struct.bar = type { i32, [0 x i32] }
7
Peter Collingbourned4bff302015-11-05 22:03:56 +00008define i32 @func() nounwind uwtable ssp !dbg !5 {
Bill Wendlingbfc0e572012-12-04 06:20:49 +00009entry:
10 %my_foo = alloca %struct.foo, align 4
11 %my_bar = alloca %struct.bar, align 4
Duncan P. N. Exon Smitha9308c42015-04-29 16:38:44 +000012 call void @llvm.dbg.declare(metadata %struct.foo* %my_foo, metadata !10, metadata !DIExpression()), !dbg !19
13 call void @llvm.dbg.declare(metadata %struct.bar* %my_bar, metadata !20, metadata !DIExpression()), !dbg !28
David Blaikie79e6c742015-02-27 19:29:02 +000014 %a = getelementptr inbounds %struct.foo, %struct.foo* %my_foo, i32 0, i32 0, !dbg !29
Bill Wendlingbfc0e572012-12-04 06:20:49 +000015 store i32 3, i32* %a, align 4, !dbg !29
David Blaikie79e6c742015-02-27 19:29:02 +000016 %a1 = getelementptr inbounds %struct.bar, %struct.bar* %my_bar, i32 0, i32 0, !dbg !30
Bill Wendlingbfc0e572012-12-04 06:20:49 +000017 store i32 5, i32* %a1, align 4, !dbg !30
David Blaikie79e6c742015-02-27 19:29:02 +000018 %a2 = getelementptr inbounds %struct.foo, %struct.foo* %my_foo, i32 0, i32 0, !dbg !31
David Blaikiea79ac142015-02-27 21:17:42 +000019 %0 = load i32, i32* %a2, align 4, !dbg !31
David Blaikie79e6c742015-02-27 19:29:02 +000020 %a3 = getelementptr inbounds %struct.bar, %struct.bar* %my_bar, i32 0, i32 0, !dbg !31
David Blaikiea79ac142015-02-27 21:17:42 +000021 %1 = load i32, i32* %a3, align 4, !dbg !31
Bill Wendlingbfc0e572012-12-04 06:20:49 +000022 %add = add nsw i32 %0, %1, !dbg !31
23 ret i32 %add, !dbg !31
24}
25
Adrian Prantl87b7eb92014-10-01 18:55:02 +000026declare void @llvm.dbg.declare(metadata, metadata, metadata) nounwind readnone
Bill Wendlingbfc0e572012-12-04 06:20:49 +000027
David Blaikieeb1a2722014-06-13 22:18:23 +000028; CHECK: DW_TAG_base_type
29; CHECK-NEXT: DW_AT_name [DW_FORM_strp] ( .debug_str[{{.*}}] = "int")
Frederic Riss878065b2014-09-04 19:39:20 +000030; CHECK-NEXT: DW_AT_encoding [DW_FORM_data1] (DW_ATE_signed)
David Blaikieeb1a2722014-06-13 22:18:23 +000031; CHECK-NEXT: DW_AT_byte_size [DW_FORM_data1] (0x04)
32
Manman Renf4c339e2013-10-29 22:49:29 +000033; int foo::b[1]:
34; CHECK: DW_TAG_structure_type
35; CHECK: DW_AT_name{{.*}}"foo"
36; CHECK: DW_TAG_member
37; CHECK: DW_TAG_member
38; CHECK-NEXT: DW_AT_name [DW_FORM_strp] ( .debug_str[{{.*}}] = "b")
Eric Christophere31e0722013-09-04 22:21:24 +000039; CHECK-NEXT: DW_AT_type [DW_FORM_ref4]
Manman Renf4c339e2013-10-29 22:49:29 +000040
41; int[1]:
42; CHECK: DW_TAG_array_type [{{.*}}] *
43; CHECK-NEXT: DW_AT_type [DW_FORM_ref4]
44; CHECK: DW_TAG_subrange_type [{{.*}}]
Eric Christophere31e0722013-09-04 22:21:24 +000045; CHECK-NEXT: DW_AT_type [DW_FORM_ref4]
David Blaikie32b0f362014-10-01 00:56:55 +000046; CHECK-NEXT: DW_AT_count [DW_FORM_data1] (0x01)
Bill Wendlingbfc0e572012-12-04 06:20:49 +000047
Manman Renf4c339e2013-10-29 22:49:29 +000048; int bar::b[0]:
49; CHECK: DW_TAG_structure_type
50; CHECK: DW_AT_name{{.*}}"bar"
51; CHECK: DW_TAG_member
52; CHECK: DW_TAG_member
Eric Christophere31e0722013-09-04 22:21:24 +000053; CHECK-NEXT: DW_AT_name [DW_FORM_strp] ( .debug_str[{{.*}}] = "b")
54; CHECK-NEXT: DW_AT_type [DW_FORM_ref4]
Bill Wendlingbfc0e572012-12-04 06:20:49 +000055
56; int[0]:
Manman Renf4c339e2013-10-29 22:49:29 +000057; CHECK: DW_TAG_array_type [{{.*}}] *
Eric Christophere31e0722013-09-04 22:21:24 +000058; CHECK-NEXT: DW_AT_type [DW_FORM_ref4]
David Blaikie32b0f362014-10-01 00:56:55 +000059; CHECK: DW_TAG_subrange_type
Eric Christophere31e0722013-09-04 22:21:24 +000060; CHECK-NEXT: DW_AT_type [DW_FORM_ref4]
David Blaikie32b0f362014-10-01 00:56:55 +000061; CHECK: DW_AT_count [DW_FORM_data1] (0x00)
Bill Wendlingbfc0e572012-12-04 06:20:49 +000062
Bill Wendlingbfc0e572012-12-04 06:20:49 +000063!llvm.dbg.cu = !{!0}
Manman Ren409558f2013-11-22 21:49:45 +000064!llvm.module.flags = !{!33}
Bill Wendlingbfc0e572012-12-04 06:20:49 +000065
Adrian Prantl75819ae2016-04-15 15:57:41 +000066!0 = distinct !DICompileUnit(language: DW_LANG_C99, producer: "clang version 3.3 (trunk 169136)", isOptimized: false, emissionKind: FullDebug, file: !32, enums: !1, retainedTypes: !1, globals: !1, imports: !1)
Duncan P. N. Exon Smithbe7ea192014-12-15 19:07:53 +000067!1 = !{}
Adrian Prantl75819ae2016-04-15 15:57:41 +000068!5 = distinct !DISubprogram(name: "func", line: 11, isLocal: false, isDefinition: true, virtualIndex: 6, isOptimized: false, unit: !0, scopeLine: 11, file: !6, scope: !6, type: !7, variables: !1)
Duncan P. N. Exon Smitha9308c42015-04-29 16:38:44 +000069!6 = !DIFile(filename: "test.c", directory: "/Volumes/Sandbox/llvm")
70!7 = !DISubroutineType(types: !8)
Duncan P. N. Exon Smithbe7ea192014-12-15 19:07:53 +000071!8 = !{!9}
Duncan P. N. Exon Smitha9308c42015-04-29 16:38:44 +000072!9 = !DIBasicType(tag: DW_TAG_base_type, name: "int", size: 32, align: 32, encoding: DW_ATE_signed)
Duncan P. N. Exon Smithed013cd2015-07-31 18:58:39 +000073!10 = !DILocalVariable(name: "my_foo", line: 12, scope: !11, file: !6, type: !12)
Duncan P. N. Exon Smitha9308c42015-04-29 16:38:44 +000074!11 = distinct !DILexicalBlock(line: 11, column: 0, file: !6, scope: !5)
75!12 = !DICompositeType(tag: DW_TAG_structure_type, name: "foo", line: 1, size: 64, align: 32, file: !32, elements: !13)
Duncan P. N. Exon Smithbe7ea192014-12-15 19:07:53 +000076!13 = !{!14, !15}
Duncan P. N. Exon Smitha9308c42015-04-29 16:38:44 +000077!14 = !DIDerivedType(tag: DW_TAG_member, name: "a", line: 2, size: 32, align: 32, file: !32, scope: !12, baseType: !9)
78!15 = !DIDerivedType(tag: DW_TAG_member, name: "b", line: 3, size: 32, align: 32, offset: 32, file: !32, scope: !12, baseType: !16)
79!16 = !DICompositeType(tag: DW_TAG_array_type, size: 32, align: 32, baseType: !9, elements: !17)
Duncan P. N. Exon Smithbe7ea192014-12-15 19:07:53 +000080!17 = !{!18}
Duncan P. N. Exon Smitha9308c42015-04-29 16:38:44 +000081!18 = !DISubrange(count: 1)
82!19 = !DILocation(line: 12, scope: !11)
Duncan P. N. Exon Smithed013cd2015-07-31 18:58:39 +000083!20 = !DILocalVariable(name: "my_bar", line: 13, scope: !11, file: !6, type: !21)
Duncan P. N. Exon Smitha9308c42015-04-29 16:38:44 +000084!21 = !DICompositeType(tag: DW_TAG_structure_type, name: "bar", line: 6, size: 32, align: 32, file: !32, elements: !22)
Duncan P. N. Exon Smithbe7ea192014-12-15 19:07:53 +000085!22 = !{!23, !24}
Duncan P. N. Exon Smitha9308c42015-04-29 16:38:44 +000086!23 = !DIDerivedType(tag: DW_TAG_member, name: "a", line: 7, size: 32, align: 32, file: !32, scope: !21, baseType: !9)
87!24 = !DIDerivedType(tag: DW_TAG_member, name: "b", line: 8, align: 32, offset: 32, file: !32, scope: !21, baseType: !25)
88!25 = !DICompositeType(tag: DW_TAG_array_type, align: 32, baseType: !9, elements: !26)
Duncan P. N. Exon Smithbe7ea192014-12-15 19:07:53 +000089!26 = !{!27}
Duncan P. N. Exon Smitha9308c42015-04-29 16:38:44 +000090!27 = !DISubrange(count: 0)
91!28 = !DILocation(line: 13, scope: !11)
92!29 = !DILocation(line: 15, scope: !11)
93!30 = !DILocation(line: 16, scope: !11)
94!31 = !DILocation(line: 17, scope: !11)
95!32 = !DIFile(filename: "test.c", directory: "/Volumes/Sandbox/llvm")
Duncan P. N. Exon Smithe2741802015-03-03 17:24:31 +000096!33 = !{i32 1, !"Debug Info Version", i32 3}