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
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_reg3
9; CHECK-NEXT: DW_AT_name	("i")
10
11; Source to generate the IR below:
12; void f1();
13; int f2();
14; extern int x;
15; void test() {
16;   int tmp = f2();
17;   // non-constant value with a single location description
18;   // Shouldn't change with BB-sections
19;   int i = tmp;
20;   f1();
21;   x = i;
22; }
23; $ clang++ -S -emit-llvm -g -O2 loclist_2.cc
24
25
26@x = external dso_local local_unnamed_addr global i32, align 4
27
28define dso_local void @_Z4testv() local_unnamed_addr !dbg !7 {
29entry:
30  %call = tail call i32 @_Z2f2v(), !dbg !14
31  call void @llvm.dbg.value(metadata i32 %call, metadata !11, metadata !DIExpression()), !dbg !15
32  call void @llvm.dbg.value(metadata i32 %call, metadata !13, metadata !DIExpression()), !dbg !15
33  tail call void @_Z2f1v(), !dbg !16
34  store i32 %call, i32* @x, align 4, !dbg !17, !tbaa !18
35  ret void, !dbg !22
36}
37
38declare !dbg !23 dso_local i32 @_Z2f2v() local_unnamed_addr
39
40declare !dbg !26 dso_local void @_Z2f1v() local_unnamed_addr
41
42declare void @llvm.dbg.value(metadata, metadata, metadata)
43
44!llvm.dbg.cu = !{!0}
45!llvm.module.flags = !{!3, !4, !5}
46!llvm.ident = !{!6}
47
48!0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus_14, file: !1, producer: "clang version 13.0.0 ([email protected]:llvm/llvm-project.git 593cb4655097552ac6d81ce18a2851ae0feb8d3c)", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, enums: !2, splitDebugInlining: false, nameTableKind: None)
49!1 = !DIFile(filename: "loclist_3.cc", directory: "/code")
50!2 = !{}
51!3 = !{i32 7, !"Dwarf Version", i32 4}
52!4 = !{i32 2, !"Debug Info Version", i32 3}
53!5 = !{i32 1, !"wchar_size", i32 4}
54!6 = !{!"clang version 13.0.0 ([email protected]:llvm/llvm-project.git 593cb4655097552ac6d81ce18a2851ae0feb8d3c)"}
55!7 = distinct !DISubprogram(name: "test", linkageName: "_Z4testv", scope: !1, file: !1, line: 4, type: !8, scopeLine: 4, flags: DIFlagPrototyped | DIFlagAllCallsDescribed, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !0, retainedNodes: !10)
56!8 = !DISubroutineType(types: !9)
57!9 = !{null}
58!10 = !{!11, !13}
59!11 = !DILocalVariable(name: "tmp", scope: !7, file: !1, line: 5, type: !12)
60!12 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)
61!13 = !DILocalVariable(name: "i", scope: !7, file: !1, line: 8, type: !12)
62!14 = !DILocation(line: 5, column: 13, scope: !7)
63!15 = !DILocation(line: 0, scope: !7)
64!16 = !DILocation(line: 9, column: 3, scope: !7)
65!17 = !DILocation(line: 10, column: 5, scope: !7)
66!18 = !{!19, !19, i64 0}
67!19 = !{!"int", !20, i64 0}
68!20 = !{!"omnipotent char", !21, i64 0}
69!21 = !{!"Simple C++ TBAA"}
70!22 = !DILocation(line: 11, column: 1, scope: !7)
71!23 = !DISubprogram(name: "f2", linkageName: "_Z2f2v", scope: !1, file: !1, line: 2, type: !24, flags: DIFlagPrototyped, spFlags: DISPFlagOptimized, retainedNodes: !2)
72!24 = !DISubroutineType(types: !25)
73!25 = !{!12}
74!26 = !DISubprogram(name: "f1", linkageName: "_Z2f1v", scope: !1, file: !1, line: 1, type: !8, flags: DIFlagPrototyped, spFlags: DISPFlagOptimized, retainedNodes: !2)
75