xref: /llvm-project/llvm/test/DebugInfo/X86/basic-block-sections-debug-loc-split-range.ll (revision 391f323690b9ef84d13a09ff07fb805008401fee)
1; RUN: llc %s -mtriple=x86_64-unknown-linux-gnu --dwarf-version=4 --basic-block-sections=none -filetype=obj -o - | llvm-dwarfdump - | FileCheck %s
2; RUN: llc %s -mtriple=x86_64-unknown-linux-gnu --dwarf-version=4 --basic-block-sections=all -filetype=obj -o -  | llvm-dwarfdump - | FileCheck %s --check-prefix=CHECK --check-prefix=SECTIONS
3; RUN: llc %s -mtriple=x86_64-unknown-linux-gnu --dwarf-version=5 --basic-block-sections=none -filetype=obj -o - | llvm-dwarfdump - | FileCheck %s
4; RUN: llc %s -mtriple=x86_64-unknown-linux-gnu --dwarf-version=5 --basic-block-sections=all -filetype=obj -o -  | llvm-dwarfdump - | FileCheck %s --check-prefix=CHECK --check-prefix=SECTIONS
5
6; CHECK:         DW_AT_location
7; CHECK-NEXT:    [0x{{[0-9a-f]+}}, 0x{{[0-9a-f]+}}): DW_OP_constu 0x9d, DW_OP_stack_value
8; SECTIONS:      [0x{{[0-9a-f]+}}, 0x{{[0-9a-f]+}}): DW_OP_constu 0x9d, DW_OP_stack_value
9; SECTIONS-NEXT: [0x{{[0-9a-f]+}}, 0x{{[0-9a-f]+}}): DW_OP_constu 0x9d, DW_OP_stack_value
10; CHECK-NEXT:    [0x{{[0-9a-f]+}}, 0x{{[0-9a-f]+}}): DW_OP_constu 0x9f, DW_OP_stack_value
11; CHECK-NEXT:    DW_AT_name	("buflen")
12
13; This IR is generated by copying basic-block-sections-debug-loc.ll and
14; manually adding one more dbg value in block 2 and modifying the value.
15; With just one dbg value a DW_AT_const_val would be emitted, so we add
16; one more dbg value with a different value to split the ranges.
17; The extra dbg value is added to split the range and to check if the
18; ranges are split correctly with sections.  With basic block sections,
19; the dbg value 157 (0x9d) gets split into one more range.
20
21define dso_local void @_ZL4ncatPcjz(ptr %0, i32 %1, ...) unnamed_addr  align 32 !dbg !22 {
22.critedge3:
23  call void @llvm.dbg.value(metadata i32 157, metadata !27, metadata !DIExpression()), !dbg !46
24  call void @llvm.va_start(ptr nonnull undef), !dbg !47
25  br label %2
26
272:                                                ; preds = %2, %.critedge3
28  call void @llvm.dbg.value(metadata i32 159, metadata !27, metadata !DIExpression()), !dbg !46
29  br label %2
30}
31
32declare void @llvm.va_start(ptr)
33
34declare void @llvm.dbg.value(metadata, metadata, metadata)
35
36!llvm.dbg.cu = !{!0}
37!llvm.module.flags = !{!20, !21}
38
39!0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus_14, file: !1, producer: "clang", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, retainedTypes: !2)
40!1 = !DIFile(filename: "bug.cpp", directory: "/proc/self/cwd")
41!2 = !{!3, !6, !9, !10, !11, !13, !16, !17, !15}
42!3 = !DIDerivedType(tag: DW_TAG_typedef, name: "int32_t", file: !4, line: 38, baseType: !5)
43!4 = !DIFile(filename: "stdint.h", directory: "/proc/self/cwd")
44!5 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)
45!6 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !7, size: 64)
46!7 = !DIDerivedType(tag: DW_TAG_const_type, baseType: !8)
47!8 = !DIBasicType(name: "char", size: 8, encoding: DW_ATE_unsigned_char)
48!9 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !8, size: 64)
49!10 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: null, size: 64)
50!11 = !DIDerivedType(tag: DW_TAG_typedef, name: "uint32_t", file: !4, line: 51, baseType: !12)
51!12 = !DIBasicType(name: "unsigned int", size: 32, encoding: DW_ATE_unsigned)
52!13 = !DIDerivedType(tag: DW_TAG_typedef, name: "UChar", file: !14, line: 372, baseType: !15)
53!14 = !DIFile(filename: "umachine.h", directory: "/proc/self/cwd")
54!15 = !DIBasicType(name: "char16_t", size: 16, encoding: DW_ATE_UTF)
55!16 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !3, size: 64)
56!17 = !DIDerivedType(tag: DW_TAG_typedef, name: "UBool", file: !14, line: 261, baseType: !18)
57!18 = !DIDerivedType(tag: DW_TAG_typedef, name: "int8_t", file: !4, line: 36, baseType: !19)
58!19 = !DIBasicType(name: "signed char", size: 8, encoding: DW_ATE_signed_char)
59!20 = !{i32 2, !"Debug Info Version", i32 3}
60!21 = !{i32 7, !"PIC Level", i32 2}
61!22 = distinct !DISubprogram(name: "ncat", linkageName: "_ZL4ncatPcjz", scope: !1, file: !1, line: 37, type: !23, scopeLine: 37, flags: DIFlagPrototyped | DIFlagAllCallsDescribed, spFlags: DISPFlagLocalToUnit | DISPFlagDefinition | DISPFlagOptimized, unit: !0, retainedNodes: !25)
62!23 = !DISubroutineType(types: !24)
63!24 = !{!3, !9, !11, null}
64!25 = !{!26, !27, !28, !41, !42, !43, !44}
65!26 = !DILocalVariable(name: "buffer", arg: 1, scope: !22, file: !1, line: 37, type: !9)
66!27 = !DILocalVariable(name: "buflen", arg: 2, scope: !22, file: !1, line: 37, type: !11)
67!28 = !DILocalVariable(name: "args", scope: !22, file: !1, line: 38, type: !29)
68!29 = !DIDerivedType(tag: DW_TAG_typedef, name: "va_list", file: !30, line: 14, baseType: !31)
69!30 = !DIFile(filename: "stdarg.h", directory: "/proc/self/cwd")
70!31 = !DIDerivedType(tag: DW_TAG_typedef, name: "__builtin_va_list", file: !1, line: 38, baseType: !32)
71!32 = !DICompositeType(tag: DW_TAG_array_type, baseType: !33, size: 192, elements: !39)
72!33 = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "__va_list_tag", file: !1, line: 38, size: 192, flags: DIFlagTypePassByValue, elements: !34, identifier: "_ZTS13__va_list_tag")
73!34 = !{!35, !36, !37, !38}
74!35 = !DIDerivedType(tag: DW_TAG_member, name: "gp_offset", scope: !33, file: !1, line: 38, baseType: !12, size: 32)
75!36 = !DIDerivedType(tag: DW_TAG_member, name: "fp_offset", scope: !33, file: !1, line: 38, baseType: !12, size: 32, offset: 32)
76!37 = !DIDerivedType(tag: DW_TAG_member, name: "overflow_arg_area", scope: !33, file: !1, line: 38, baseType: !10, size: 64, offset: 64)
77!38 = !DIDerivedType(tag: DW_TAG_member, name: "reg_save_area", scope: !33, file: !1, line: 38, baseType: !10, size: 64, offset: 128)
78!39 = !{!40}
79!40 = !DISubrange(count: 1)
80!41 = !DILocalVariable(name: "str", scope: !22, file: !1, line: 39, type: !9)
81!42 = !DILocalVariable(name: "p", scope: !22, file: !1, line: 40, type: !9)
82!43 = !DILocalVariable(name: "e", scope: !22, file: !1, line: 41, type: !6)
83!44 = !DILocalVariable(name: "c", scope: !45, file: !1, line: 49, type: !8)
84!45 = distinct !DILexicalBlock(scope: !22, file: !1, line: 48, column: 45)
85!46 = !DILocation(line: 0, scope: !22)
86!47 = !DILocation(line: 47, column: 3, scope: !22)
87