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
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
6 ; CHECK: DW_TAG_variable
7 ; CHECK-NEXT: DW_AT_const_value (7)
8 ; CHECK-NEXT: DW_AT_name ("i")
10 ; Source to generate the IR below:
15 ; // i is a const throughout the whole scope and should
16 ; // use DW_AT_const_value
23 ; $ clang++ -S -emit-llvm -g -O2 simple.cc
26 @b = external dso_local local_unnamed_addr global i8, align 1
28 define dso_local void @_Z4testv() local_unnamed_addr !dbg !7 {
30 call void @llvm.dbg.value(metadata i32 7, metadata !11, metadata !DIExpression()), !dbg !13
31 tail call void @_Z2f1v(), !dbg !14
32 %0 = load i8, i8* @b, align 1, !dbg !15, !tbaa !17, !range !21
33 %tobool.not = icmp eq i8 %0, 0, !dbg !15
34 br i1 %tobool.not, label %if.end, label %if.then, !dbg !22
36 if.then: ; preds = %entry
37 tail call void @_Z2f1v(), !dbg !23
38 br label %if.end, !dbg !23
40 if.end: ; preds = %if.then, %entry
44 declare !dbg !25 dso_local void @_Z2f1v() local_unnamed_addr
46 declare void @llvm.dbg.value(metadata, metadata, metadata)
49 !llvm.module.flags = !{!3, !4, !5}
52 !0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus_14, file: !1, producer: "clang version 13.0.0 (git@github.com:llvm/llvm-project.git 593cb4655097552ac6d81ce18a2851ae0feb8d3c)", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, enums: !2, splitDebugInlining: false, nameTableKind: None)
53 !1 = !DIFile(filename: "simple.cc", directory: "/code")
55 !3 = !{i32 7, !"Dwarf Version", i32 4}
56 !4 = !{i32 2, !"Debug Info Version", i32 3}
57 !5 = !{i32 1, !"wchar_size", i32 4}
58 !6 = !{!"clang version 13.0.0 (git@github.com:llvm/llvm-project.git 593cb4655097552ac6d81ce18a2851ae0feb8d3c)"}
59 !7 = distinct !DISubprogram(name: "test", linkageName: "_Z4testv", scope: !1, file: !1, line: 5, type: !8, scopeLine: 5, flags: DIFlagPrototyped | DIFlagAllCallsDescribed, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !0, retainedNodes: !10)
60 !8 = !DISubroutineType(types: !9)
63 !11 = !DILocalVariable(name: "i", scope: !7, file: !1, line: 14, type: !12)
64 !12 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)
65 !13 = !DILocation(line: 0, scope: !7)
66 !14 = !DILocation(line: 15, column: 5, scope: !7)
67 !15 = !DILocation(line: 16, column: 9, scope: !16)
68 !16 = distinct !DILexicalBlock(scope: !7, file: !1, line: 16, column: 9)
69 !17 = !{!18, !18, i64 0}
70 !18 = !{!"bool", !19, i64 0}
71 !19 = !{!"omnipotent char", !20, i64 0}
72 !20 = !{!"Simple C++ TBAA"}
74 !22 = !DILocation(line: 16, column: 9, scope: !7)
75 !23 = !DILocation(line: 17, column: 7, scope: !16)
76 !24 = !DILocation(line: 18, column: 1, scope: !7)
77 !25 = !DISubprogram(name: "f1", linkageName: "_Z2f1v", scope: !1, file: !1, line: 1, type: !8, flags: DIFlagPrototyped, spFlags: DISPFlagOptimized, retainedNodes: !2)