xref: /llvm-project/llvm/test/DebugInfo/X86/stmt-list-multiple-compile-units.ll (revision 23b3f6da1480abd6ce6aefcc3b72d0438e73375d)
1; RUN: llc -O0 %s -mtriple=x86_64-apple-darwin -filetype=obj -o %t
2; RUN: llvm-dwarfdump -v %t | FileCheck %s
3; RUN: llc -O0 %s -mtriple=x86_64-apple-darwin -filetype=obj -o %t -dwarf-version=3
4; RUN: llvm-dwarfdump -v %t | FileCheck %s -check-prefix=DWARF3
5; RUN: llc < %s -O0 -mtriple=x86_64-apple-macosx10.7 | FileCheck %s -check-prefix=ASM
6
7; rdar://13067005
8; CHECK: .debug_info contents:
9; CHECK: DW_TAG_compile_unit
10; CHECK: DW_AT_stmt_list [DW_FORM_sec_offset]   (0x00000000)
11; CHECK: DW_AT_low_pc [DW_FORM_addr]            (0x0000000000000000)
12; CHECK: DW_AT_high_pc [DW_FORM_data4]          (0x00000010)
13; CHECK: DW_TAG_subprogram
14; CHECK: DW_AT_low_pc [DW_FORM_addr]            (0x0000000000000000)
15; CHECK: DW_AT_high_pc [DW_FORM_data4]          (0x00000010)
16
17; CHECK: DW_TAG_compile_unit
18; CHECK: DW_AT_stmt_list [DW_FORM_sec_offset]   (0x0000003c)
19; CHECK: DW_AT_low_pc [DW_FORM_addr]            (0x0000000000000010)
20; CHECK: DW_AT_high_pc [DW_FORM_data4]          (0x00000009)
21; CHECK: DW_TAG_subprogram
22; CHECK: DW_AT_low_pc [DW_FORM_addr]            (0x0000000000000010)
23; CHECK: DW_AT_high_pc [DW_FORM_data4]          (0x00000009)
24
25
26; CHECK: .debug_line contents:
27; CHECK-NEXT: debug_line[{{.*}}]
28; CHECK-NEXT: Line table prologue:
29; CHECK-NEXT: total_length: 0x00000038
30; CHECK: file_names[  1]    0 0x00000000 0x00000000 simple.c
31; CHECK: debug_line[{{.*}}]
32; CHECK-NEXT: Line table prologue:
33; CHECK-NEXT: total_length: 0x00000039
34; CHECK: file_names[  1]    0 0x00000000 0x00000000 simple2.c
35; CHECK-NOT: file_names
36
37; DWARF3: .debug_info contents:
38; DWARF3: DW_TAG_compile_unit
39; DWARF3: DW_AT_stmt_list [DW_FORM_data4]    (0x00000000)
40
41; DWARF3: DW_TAG_compile_unit
42; DWARF3: DW_AT_stmt_list [DW_FORM_data4]   (0x0000003c)
43
44
45; DWARF3: .debug_line contents:
46; DWARF3-NEXT: debug_line[{{.*}}]
47; DWARF3-NEXT: Line table prologue:
48; DWARF3-NEXT: total_length: 0x00000038
49; DWARF3: file_names[  1]    0 0x00000000 0x00000000 simple.c
50; DWARF3: debug_line[{{.*}}]
51; DWARF3-NEXT: Line table prologue:
52; DWARF3-NEXT: total_length: 0x00000039
53; DWARF3: file_names[  1]    0 0x00000000 0x00000000 simple2.c
54; DWARF3-NOT: file_names
55
56; PR15408
57; ASM: Lcu_begin0:
58; ASM-NOT: Lcu_begin
59; ASM: Lset[[LT:[0-9]+]] = Lline_table_start0-Lsection_line ## DW_AT_stmt_list
60; ASM-NEXT: .long   Lset[[LT]]
61; ASM: Lcu_begin1:
62; ASM-NOT: Lcu_begin
63; ASM: Lset[[LT:[0-9]+]] = Lline_table_start0-Lsection_line ## DW_AT_stmt_list
64; ASM-NEXT: .long   Lset[[LT]]
65define i32 @test(i32 %a) nounwind uwtable ssp !dbg !5 {
66entry:
67  %a.addr = alloca i32, align 4
68  store i32 %a, i32* %a.addr, align 4
69  call void @llvm.dbg.declare(metadata i32* %a.addr, metadata !15, metadata !DIExpression()), !dbg !16
70  %0 = load i32, i32* %a.addr, align 4, !dbg !17
71  %call = call i32 @fn(i32 %0), !dbg !17
72  ret i32 %call, !dbg !17
73}
74
75declare void @llvm.dbg.declare(metadata, metadata, metadata) nounwind readnone
76
77define i32 @fn(i32 %a) nounwind uwtable ssp !dbg !13 {
78entry:
79  %a.addr = alloca i32, align 4
80  store i32 %a, i32* %a.addr, align 4
81  call void @llvm.dbg.declare(metadata i32* %a.addr, metadata !19, metadata !DIExpression()), !dbg !20
82  %0 = load i32, i32* %a.addr, align 4, !dbg !21
83  ret i32 %0, !dbg !21
84}
85
86!llvm.dbg.cu = !{!0, !10}
87!llvm.module.flags = !{!25}
88!0 = distinct !DICompileUnit(language: DW_LANG_C99, producer: "clang version 3.3", isOptimized: false, emissionKind: FullDebug, file: !23, enums: !1, retainedTypes: !1, globals: !1, imports:  !1)
89!1 = !{}
90!5 = distinct !DISubprogram(name: "test", line: 2, isLocal: false, isDefinition: true, virtualIndex: 6, flags: DIFlagPrototyped, isOptimized: false, unit: !0, scopeLine: 3, file: !23, scope: !6, type: !7, variables: !1)
91!6 = !DIFile(filename: "simple.c", directory: "/private/tmp")
92!7 = !DISubroutineType(types: !8)
93!8 = !{!9, !9}
94!9 = !DIBasicType(tag: DW_TAG_base_type, name: "int", size: 32, align: 32, encoding: DW_ATE_signed)
95!10 = distinct !DICompileUnit(language: DW_LANG_C99, producer: "clang version 3.3 (trunk 172862)", isOptimized: false, emissionKind: FullDebug, file: !24, enums: !1, retainedTypes: !1, globals: !1, imports:  !1)
96!13 = distinct !DISubprogram(name: "fn", line: 1, isLocal: false, isDefinition: true, virtualIndex: 6, flags: DIFlagPrototyped, isOptimized: false, unit: !10, scopeLine: 1, file: !24, scope: !14, type: !7, variables: !1)
97!14 = !DIFile(filename: "simple2.c", directory: "/private/tmp")
98!15 = !DILocalVariable(name: "a", line: 2, arg: 1, scope: !5, file: !6, type: !9)
99!16 = !DILocation(line: 2, scope: !5)
100!17 = !DILocation(line: 4, scope: !18)
101!18 = distinct !DILexicalBlock(line: 3, column: 0, file: !23, scope: !5)
102!19 = !DILocalVariable(name: "a", line: 1, arg: 1, scope: !13, file: !14, type: !9)
103!20 = !DILocation(line: 1, scope: !13)
104!21 = !DILocation(line: 2, scope: !22)
105!22 = distinct !DILexicalBlock(line: 1, column: 0, file: !24, scope: !13)
106!23 = !DIFile(filename: "simple.c", directory: "/private/tmp")
107!24 = !DIFile(filename: "simple2.c", directory: "/private/tmp")
108!25 = !{i32 1, !"Debug Info Version", i32 3}
109