1; RUN: llc -O0 %s -mtriple=x86_64 -filetype=obj -o %t && llvm-dwarfdump -debug-info -v %t | FileCheck --check-prefix=NO-SECTIONS %s
2; RUN: llc -O0 %s --basic-block-sections=all --unique-basic-block-section-names -mtriple=x86_64 -filetype=obj -o %t && llvm-dwarfdump -debug-info -v %t | FileCheck --check-prefix=BB-SECTIONS %s
3; RUN: llc -O0 %s --basic-block-sections=all --unique-basic-block-section-names -mtriple=x86_64 -filetype=obj -split-dwarf-file=%t.dwo -o %t && llvm-dwarfdump -debug-info -v %t | FileCheck --check-prefix=BB-SECTIONS %s
4; RUN: llc -O0 %s --basic-block-sections=all -mtriple=x86_64 -o - | FileCheck --check-prefix=BB-SECTIONS-ASM %s
5
6; From:
7; int foo(int a) {
8;   if (a > 20)
9;     return 2;
10;   else
11;     return 0;
12; }
13
14; NO-SECTIONS: DW_AT_low_pc [DW_FORM_addr] (0x0000000000000000 ".text")
15; NO-SECTIONS: DW_AT_high_pc [DW_FORM_data4] ({{.*}})
16; BB-SECTIONS: DW_AT_low_pc [DW_FORM_addr] (0x0000000000000000)
17; BB-SECTIONS-NEXT: DW_AT_ranges [DW_FORM_sec_offset]
18; BB-SECTIONS-NEXT: [{{.*}}) ".text._Z3fooi.1"
19; BB-SECTIONS-NEXT: [{{.*}}) ".text._Z3fooi.2"
20; BB-SECTIONS-NEXT: [{{.*}}) ".text._Z3fooi.3"
21; BB-SECTIONS-NEXT: [{{.*}}) ".text"
22; BB-SECTIONS-ASM: _Z3fooi:
23; BB-SECTIONS-ASM: .Ltmp{{[0-9]+}}:
24; BB-SECTIONS-ASM-NEXT: .loc 1 2 9 prologue_end
25; BB-SECTIONS-ASM: .Ltmp{{[0-9]+}}:
26; BB-SECTIONS-ASM-NEXT: .loc 1 2 7 is_stmt
27; BB-SECTIONS-ASM: _Z3fooi.1:
28; BB-SECTIONS-ASM: .LBB_END0_{{[0-9]+}}:
29; BB-SECTIONS-ASM: .size	_Z3fooi.1, .LBB_END0_{{[0-9]+}}-_Z3fooi.1
30; BB-SECTIONS-ASM: _Z3fooi.2:
31; BB-SECTIONS-ASM: .Ltmp{{[0-9]+}}:
32; BB-SECTIONS-ASM-NEXT: .LBB_END0_{{[0-9]+}}:
33; BB-SECTIONS-ASM: .size	_Z3fooi.2, .LBB_END0_{{[0-9]+}}-_Z3fooi.2
34; BB-SECTIONS-ASM: _Z3fooi.3:
35; BB-SECTIONS-ASM: .Ltmp{{[0-9]+}}:
36; BB-SECTIONS-ASM-NEXT: .LBB_END0_{{[0-9]+}}:
37; BB-SECTIONS-ASM: .size	_Z3fooi.3, .LBB_END0_{{[0-9]+}}-_Z3fooi.3
38; BB-SECTIONS-ASM: .Lfunc_end0:
39; BB-SECTIONS-ASM: .Ldebug_ranges0:
40; BB-SECTIONS-ASM-NEXT:	.quad	_Z3fooi.1
41; BB-SECTIONS-ASM-NEXT:	.quad	.LBB_END0_{{[0-9]+}}
42; BB-SECTIONS-ASM-NEXT:	.quad	_Z3fooi.2
43; BB-SECTIONS-ASM-NEXT:	.quad	.LBB_END0_{{[0-9]+}}
44; BB-SECTIONS-ASM-NEXT:	.quad	_Z3fooi.3
45; BB-SECTIONS-ASM-NEXT:	.quad	.LBB_END0_{{[0-9]+}}
46; BB-SECTIONS-ASM-NEXT:	.quad	.Lfunc_begin0
47; BB-SECTIONS-ASM-NEXT:	.quad	.Lfunc_end0
48; BB-SECTIONS-ASM-NEXT:	.quad	0
49; BB-SECTIONS-ASM-NEXT:	.quad	0
50
51; Function Attrs: noinline nounwind optnone uwtable
52define dso_local i32 @_Z3fooi(i32 %0) !dbg !7 {
53  %2 = alloca i32, align 4
54  %3 = alloca i32, align 4
55  store i32 %0, i32* %3, align 4
56  call void @llvm.dbg.declare(metadata i32* %3, metadata !11, metadata !DIExpression()), !dbg !12
57  %4 = load i32, i32* %3, align 4, !dbg !13
58  %5 = icmp sgt i32 %4, 20, !dbg !15
59  br i1 %5, label %6, label %7, !dbg !16
60
616:                                                ; preds = %1
62  store i32 2, i32* %2, align 4, !dbg !17
63  br label %8, !dbg !17
64
657:                                                ; preds = %1
66  store i32 0, i32* %2, align 4, !dbg !18
67  br label %8, !dbg !18
68
698:                                                ; preds = %7, %6
70  %9 = load i32, i32* %2, align 4, !dbg !19
71  ret i32 %9, !dbg !19
72}
73
74; Function Attrs: nounwind readnone speculatable willreturn
75declare void @llvm.dbg.declare(metadata, metadata, metadata)
76
77!llvm.dbg.cu = !{!0}
78!llvm.module.flags = !{!3, !4}
79
80!0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, file: !1, producer: "clang version 10.0.0 ([email protected]:google/llvm-propeller.git f9421ebf4b3d8b64678bf6c49d1607fdce3f50c5)", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, enums: !2, nameTableKind: None)
81!1 = !DIFile(filename: "debuginfo.cc", directory: "/")
82!2 = !{}
83!3 = !{i32 2, !"Dwarf Version", i32 4}
84!4 = !{i32 2, !"Debug Info Version", i32 3}
85!7 = distinct !DISubprogram(name: "foo", linkageName: "_Z3fooi", scope: !1, file: !1, line: 1, type: !8, scopeLine: 1, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition, unit: !0, retainedNodes: !2)
86!8 = !DISubroutineType(types: !9)
87!9 = !{!10, !10}
88!10 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)
89!11 = !DILocalVariable(name: "a", arg: 1, scope: !7, file: !1, line: 1, type: !10)
90!12 = !DILocation(line: 1, column: 13, scope: !7)
91!13 = !DILocation(line: 2, column: 7, scope: !14)
92!14 = distinct !DILexicalBlock(scope: !7, file: !1, line: 2, column: 7)
93!15 = !DILocation(line: 2, column: 9, scope: !14)
94!16 = !DILocation(line: 2, column: 7, scope: !7)
95!17 = !DILocation(line: 3, column: 5, scope: !14)
96!18 = !DILocation(line: 5, column: 5, scope: !14)
97!19 = !DILocation(line: 6, column: 1, scope: !7)
98