xref: /llvm-project/llvm/test/DebugInfo/X86/basic-block-sections-debug-loclist-6.ll (revision c7ef002bc6a6b99371865a416da781d0374c69fd)
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 --check-prefix=SECTIONS %s
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 --check-prefix=SECTIONS %s
5
6; CHECK:      DW_TAG_variable
7; CHECK-NEXT: DW_AT_location
8; CHECK-NEXT: [0x{{[0-9a-f]+}}, 0x{{[0-9a-f]+}}): DW_OP_consts +7, DW_OP_stack_value
9; CHECK-NEXT: [0x{{[0-9a-f]+}}, 0x{{[0-9a-f]+}}): DW_OP_consts +8, DW_OP_stack_value
10; CHECK-NEXT: DW_AT_name	("i")
11
12; SECTIONS:      DW_TAG_variable
13; SECTIONS-NEXT: DW_AT_location
14; SECTIONS-NEXT: [0x{{[0-9a-f]+}}, 0x{{[0-9a-f]+}}): DW_OP_consts +7, DW_OP_stack_value
15; SECTIONS-NEXT: [0x{{[0-9a-f]+}}, 0x{{[0-9a-f]+}}): DW_OP_consts +8, DW_OP_stack_value
16; SECTIONS-NEXT: [0x{{[0-9a-f]+}}, 0x{{[0-9a-f]+}}): DW_OP_consts +8, DW_OP_stack_value
17; SECTIONS-NEXT: [0x{{[0-9a-f]+}}, 0x{{[0-9a-f]+}}): DW_OP_consts +8, DW_OP_stack_value
18; SECTIONS-NEXT: DW_AT_name	("i")
19
20; Source to generate the IR below:
21; void f1();
22; extern bool b;
23; void test() {
24;     // i is not a const throughout the whole scope and should
25;     // not use DW_AT_const_value
26;     int i = 7;
27;     f1();
28;     i = 8;
29;     if (b)
30;       f1();
31; }
32; $ clang++ -S loclist_section.cc -O2 -g  -emit-llvm
33
34@b = external local_unnamed_addr global i8, align 1
35
36; Function Attrs: mustprogress uwtable
37define dso_local void @_Z4testv() local_unnamed_addr #0 !dbg !10 {
38entry:
39    #dbg_value(i32 7, !14, !DIExpression(), !16)
40  tail call void @_Z2f1v(), !dbg !17
41    #dbg_value(i32 8, !14, !DIExpression(), !16)
42  %0 = load i8, ptr @b, align 1, !dbg !18, !tbaa !20, !range !24, !noundef !25
43  %loadedv = trunc nuw i8 %0 to i1, !dbg !18
44  br i1 %loadedv, label %if.then, label %if.end, !dbg !26
45
46if.then:                                          ; preds = %entry
47  tail call void @_Z2f1v(), !dbg !27
48  br label %if.end, !dbg !27
49
50if.end:                                           ; preds = %if.then, %entry
51  ret void, !dbg !28
52}
53
54declare !dbg !29 void @_Z2f1v() local_unnamed_addr #1
55
56attributes #0 = { mustprogress uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
57attributes #1 = { "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
58
59!llvm.dbg.cu = !{!0}
60!llvm.module.flags = !{!2, !3, !4, !5, !6, !7, !8}
61!llvm.ident = !{!9}
62
63!0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus_14, file: !1, producer: "clang version 20.0.0git (git@github.com:)", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, splitDebugInlining: false, nameTableKind: None)
64!1 = !DIFile(filename: "loclist_section.cc", directory: "Examples/debug_loc", checksumkind: CSK_MD5, checksum: "67769a94389681c8a6da481e2f358abb")
65!2 = !{i32 7, !"Dwarf Version", i32 5}
66!3 = !{i32 2, !"Debug Info Version", i32 3}
67!4 = !{i32 1, !"wchar_size", i32 4}
68!5 = !{i32 8, !"PIC Level", i32 2}
69!6 = !{i32 7, !"PIE Level", i32 2}
70!7 = !{i32 7, !"uwtable", i32 2}
71!8 = !{i32 7, !"debug-info-assignment-tracking", i1 true}
72!9 = !{!"clang version 20.0.0git (git@github.com:.../llvm-project.git 7c3256280a78b0505ae4d43985c4d3239451a151)"}
73!10 = distinct !DISubprogram(name: "test", linkageName: "_Z4testv", scope: !1, file: !1, line: 3, type: !11, scopeLine: 3, flags: DIFlagPrototyped | DIFlagAllCallsDescribed, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !0, retainedNodes: !13)
74!11 = !DISubroutineType(types: !12)
75!12 = !{null}
76!13 = !{!14}
77!14 = !DILocalVariable(name: "i", scope: !10, file: !1, line: 6, type: !15)
78!15 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)
79!16 = !DILocation(line: 0, scope: !10)
80!17 = !DILocation(line: 7, column: 5, scope: !10)
81!18 = !DILocation(line: 9, column: 9, scope: !19)
82!19 = distinct !DILexicalBlock(scope: !10, file: !1, line: 9, column: 9)
83!20 = !{!21, !21, i64 0}
84!21 = !{!"bool", !22, i64 0}
85!22 = !{!"omnipotent char", !23, i64 0}
86!23 = !{!"Simple C++ TBAA"}
87!24 = !{i8 0, i8 2}
88!25 = !{}
89!26 = !DILocation(line: 9, column: 9, scope: !10)
90!27 = !DILocation(line: 10, column: 7, scope: !19)
91!28 = !DILocation(line: 11, column: 1, scope: !10)
92!29 = !DISubprogram(name: "f1", linkageName: "_Z2f1v", scope: !1, file: !1, line: 1, type: !11, flags: DIFlagPrototyped, spFlags: DISPFlagOptimized)
93