xref: /llvm-project/llvm/test/DebugInfo/Generic/debug-ranges-duplication.ll (revision fe7bc872aad83fc0d5cf998230df752e73bb696d)
1; AIX doesn't currently support DWARF 5 section .debug_rnglists
2; XFAIL: target={{.*}}-zos{{.*}}, target={{.*}}-aix{{.*}}
3
4; RUN: %llc_dwarf -O0 -filetype=obj < %s | llvm-dwarfdump -debug-info - | FileCheck %s
5;
6; Generated from the following C++ source with:
7; clang -S -emit-llvm -g -O2 test.c
8;
9; /* BEGIN SOURCE */
10; void f1();
11; inline void f2() {
12;   f1();
13;   f1();
14; }
15; inline void f3() {
16;   f2();
17; }
18; void f4() {
19;   f3();
20;   f1();
21; }
22; /* END SOURCE */
23;
24; Minor complication: after generating the LLVM IR, it was manually edited so
25; that the 'f1()' call from f3 was reordered to appear between the two inlined
26; f1 calls from f2. This causes f2's inlined_subroutine to use DW_AT_ranges.
27
28; Check that identical debug ranges in succession reuse the same entry in
29; .debug_ranges rather than emitting duplicate entries.
30
31; CHECK:      DW_TAG_inlined_subroutine
32; CHECK:      DW_AT_ranges
33; CHECK-SAME: rangelist = 0x[[#%.8X,RANGE:]]
34; CHECK:      DW_TAG_inlined_subroutine
35; CHECK:      DW_AT_ranges
36; CHECK-SAME: rangelist = 0x[[#RANGE]]
37
38; Function Attrs: nounwind uwtable
39define dso_local void @f4() local_unnamed_addr !dbg !9 {
40entry:
41  tail call void (...) @f1(), !dbg !12
42  tail call void (...) @f1(), !dbg !18
43  tail call void (...) @f1(), !dbg !17
44  ret void, !dbg !19
45}
46
47declare !dbg !20 void @f1(...) local_unnamed_addr
48
49!llvm.dbg.cu = !{!0}
50!llvm.module.flags = !{!2, !3, !4, !5, !6, !7}
51!llvm.ident = !{!8}
52
53!0 = distinct !DICompileUnit(language: DW_LANG_C11, file: !1, producer: "clang version 20.0.0git (https://github.com/llvm/llvm-project.git 9edd998e10fabfff067b9e6e5b044f85a24d0dd5)", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, splitDebugInlining: false, nameTableKind: None)
54!1 = !DIFile(filename: "test.c", directory: "/home/khuey/dev/llvm-project", checksumkind: CSK_MD5, checksum: "4510feb241cf078af753e3dc13205127")
55!2 = !{i32 7, !"Dwarf Version", i32 5}
56!3 = !{i32 2, !"Debug Info Version", i32 3}
57!4 = !{i32 1, !"wchar_size", i32 4}
58!5 = !{i32 8, !"PIC Level", i32 2}
59!6 = !{i32 7, !"PIE Level", i32 2}
60!7 = !{i32 7, !"uwtable", i32 2}
61!8 = !{!"clang version 20.0.0git (https://github.com/llvm/llvm-project.git 9edd998e10fabfff067b9e6e5b044f85a24d0dd5)"}
62!9 = distinct !DISubprogram(name: "f4", scope: !1, file: !1, line: 9, type: !10, scopeLine: 9, flags: DIFlagAllCallsDescribed, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !0)
63!10 = !DISubroutineType(types: !11)
64!11 = !{null}
65!12 = !DILocation(line: 3, column: 3, scope: !13, inlinedAt: !14)
66!13 = distinct !DISubprogram(name: "f2", scope: !1, file: !1, line: 2, type: !10, scopeLine: 2, flags: DIFlagAllCallsDescribed, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !0)
67!14 = distinct !DILocation(line: 7, column: 3, scope: !15, inlinedAt: !16)
68!15 = distinct !DISubprogram(name: "f3", scope: !1, file: !1, line: 6, type: !10, scopeLine: 6, flags: DIFlagAllCallsDescribed, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !0)
69!16 = distinct !DILocation(line: 10, column: 3, scope: !9)
70!17 = !DILocation(line: 4, column: 3, scope: !13, inlinedAt: !14)
71!18 = !DILocation(line: 11, column: 3, scope: !9)
72!19 = !DILocation(line: 12, column: 1, scope: !9)
73!20 = !DISubprogram(name: "f1", scope: !1, file: !1, line: 1, type: !10, spFlags: DISPFlagOptimized)
74