1 ; RUN: llc -generate-arange-section -minimize-addr-in-v5=Ranges --filetype=obj -o %t < %s
2 ; RUN: llvm-dwarfdump --debug-info -debug-aranges -debug-addr %t | FileCheck %s
3 ; RUN: llvm-dwarfdump --verify %t
5 ; This file was based on output of
7 ; clang -target msp430-elf -S -emit-llvm -gdwarf-5 -Os dwarf-basics-v5.c
9 ; for the following dwarf-basics-v5.c
15 ; int f(long y, struct X *p)
21 ; CHECK: file format elf32-msp430
23 ; CHECK: .debug_info contents:
24 ; CHECK: Compile Unit: length = 0x{{.*}}, format = DWARF32, version = 0x0005, unit_type = DW_UT_compile, abbr_offset = 0x0000, addr_size = 0x04 (next unit at 0x{{.*}})
26 ; CHECK: DW_TAG_compile_unit
27 ; CHECK: DW_AT_producer ("clang version 17.0.0 (git@...)")
28 ; CHECK: DW_AT_language (DW_LANG_C11)
29 ; CHECK: DW_AT_name ("dwarf-basics-v5.c")
30 ; CHECK: DW_AT_str_offsets_base (0x00000008)
31 ; CHECK: DW_AT_stmt_list (0x{{.*}})
32 ; CHECK: DW_AT_comp_dir ("/tmp")
33 ; CHECK: DW_AT_low_pc (0x{{.*}})
34 ; CHECK: DW_AT_high_pc (0x{{.*}})
35 ; CHECK: DW_AT_addr_base (0x00000008)
36 ; CHECK: DW_AT_loclists_base (0x0000000c)
38 ; CHECK: DW_TAG_subprogram
39 ; CHECK: DW_AT_low_pc (0x{{.*}})
40 ; CHECK: DW_AT_high_pc (0x{{.*}})
41 ; CHECK: DW_AT_frame_base (DW_OP_reg1 SP)
42 ; CHECK: DW_AT_call_all_calls (true)
43 ; CHECK: DW_AT_name ("f")
44 ; CHECK: DW_AT_decl_file ("/tmp{{[/\\]}}dwarf-basics-v5.c")
45 ; CHECK: DW_AT_decl_line (5)
46 ; CHECK: DW_AT_prototyped (true)
47 ; CHECK: DW_AT_type (0x{{.*}} "int")
48 ; CHECK: DW_AT_external (true)
50 ; CHECK: DW_TAG_formal_parameter
51 ; CHECK: DW_AT_location (indexed (0x0) loclist = 0x{{.*}}:
52 ; CHECK: [0x00000000, 0x00000004): DW_OP_reg12 R12)
53 ; CHECK: DW_AT_name ("y")
54 ; CHECK: DW_AT_decl_file ("/tmp{{[/\\]}}dwarf-basics-v5.c")
55 ; CHECK: DW_AT_decl_line (5)
56 ; CHECK: DW_AT_type (0x{{.*}} "long")
58 ; CHECK: DW_TAG_formal_parameter
59 ; CHECK: DW_AT_location (DW_OP_reg14 R14)
60 ; CHECK: DW_AT_name ("p")
61 ; CHECK: DW_AT_decl_file ("/tmp{{[/\\]}}dwarf-basics-v5.c")
62 ; CHECK: DW_AT_decl_line (5)
63 ; CHECK: DW_AT_type (0x{{.*}} "X *")
67 ; CHECK: DW_TAG_base_type
68 ; CHECK: DW_AT_name ("int")
69 ; CHECK: DW_AT_encoding (DW_ATE_signed)
70 ; CHECK: DW_AT_byte_size (0x02)
72 ; CHECK: DW_TAG_base_type
73 ; CHECK: DW_AT_name ("long")
74 ; CHECK: DW_AT_encoding (DW_ATE_signed)
75 ; CHECK: DW_AT_byte_size (0x04)
77 ; CHECK: DW_TAG_pointer_type
78 ; CHECK: DW_AT_type (0x{{.*}} "X")
80 ; CHECK: DW_TAG_structure_type
81 ; CHECK: DW_AT_name ("X")
82 ; CHECK: DW_AT_byte_size (0x02)
83 ; CHECK: DW_AT_decl_file ("/tmp{{[/\\]}}dwarf-basics-v5.c")
84 ; CHECK: DW_AT_decl_line (1)
86 ; CHECK: DW_TAG_member
87 ; CHECK: DW_AT_name ("a")
88 ; CHECK: DW_AT_type (0x{{.*}} "void *")
89 ; CHECK: DW_AT_decl_file ("/tmp{{[/\\]}}dwarf-basics-v5.c")
90 ; CHECK: DW_AT_decl_line (2)
91 ; CHECK: DW_AT_data_member_location (0x00)
95 ; CHECK: DW_TAG_pointer_type
99 ; CHECK: .debug_aranges contents:
100 ; CHECK-NEXT: Address Range Header: length = 0x{{.*}}, format = DWARF32, version = 0x0002, cu_offset = 0x00000000, addr_size = 0x04, seg_size = 0x00
101 ; CHECK-NEXT: [0x00000000, 0x00000006)
103 ; CHECK: .debug_addr contents:
104 ; CHECK-NEXT: Address table header: length = 0x{{.*}}, format = DWARF32, version = 0x0005, addr_size = 0x04, seg_size = 0x00
105 ; CHECK-NEXT: Addrs: [
106 ; CHECK-NEXT: 0x00000000
109 ; ModuleID = 'dwarf-basics-v5.c'
110 source_filename = "dwarf-basics-v5.c"
111 target datalayout = "e-m:e-p:16:16-i32:16-i64:16-f32:16-f64:16-a:8-n8:16-S16"
112 target triple = "msp430-unknown-unknown-elf"
114 ; Function Attrs: mustprogress nofree norecurse nosync nounwind optsize willreturn memory(none)
115 define dso_local i16 @f(i32 noundef %0, ptr nocapture noundef readnone %1) local_unnamed_addr #0 !dbg !6 {
116 call void @llvm.dbg.value(metadata i32 %0, metadata !17, metadata !DIExpression()), !dbg !19
117 call void @llvm.dbg.value(metadata ptr %1, metadata !18, metadata !DIExpression()), !dbg !19
121 ; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
122 declare void @llvm.dbg.value(metadata, metadata, metadata) #1
124 attributes #0 = { mustprogress nofree norecurse nosync nounwind optsize willreturn memory(none) "no-trapping-math"="true" "stack-protector-buffer-size"="8" }
125 attributes #1 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
128 !llvm.module.flags = !{!2, !3, !4}
131 !0 = distinct !DICompileUnit(language: DW_LANG_C11, file: !1, producer: "clang version 17.0.0 (git@...)", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, splitDebugInlining: false, nameTableKind: None)
132 !1 = !DIFile(filename: "dwarf-basics-v5.c", directory: "/tmp", checksumkind: CSK_MD5, checksum: "ead340d457001e2ce340630cfa3a9cb8")
133 !2 = !{i32 7, !"Dwarf Version", i32 5}
134 !3 = !{i32 2, !"Debug Info Version", i32 3}
135 !4 = !{i32 1, !"wchar_size", i32 2}
136 !5 = !{!"clang version 17.0.0 (git@...)"}
137 !6 = distinct !DISubprogram(name: "f", scope: !1, file: !1, line: 5, type: !7, scopeLine: 6, flags: DIFlagPrototyped | DIFlagAllCallsDescribed, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !0, retainedNodes: !16)
138 !7 = !DISubroutineType(types: !8)
140 !9 = !DIBasicType(name: "int", size: 16, encoding: DW_ATE_signed)
141 !10 = !DIBasicType(name: "long", size: 32, encoding: DW_ATE_signed)
142 !11 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !12, size: 16)
143 !12 = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "X", file: !1, line: 1, size: 16, elements: !13)
145 !14 = !DIDerivedType(tag: DW_TAG_member, name: "a", scope: !12, file: !1, line: 2, baseType: !15, size: 16)
146 !15 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: null, size: 16)
148 !17 = !DILocalVariable(name: "y", arg: 1, scope: !6, file: !1, line: 5, type: !10)
149 !18 = !DILocalVariable(name: "p", arg: 2, scope: !6, file: !1, line: 5, type: !11)
150 !19 = !DILocation(line: 0, scope: !6)
151 !20 = !DILocation(line: 7, column: 3, scope: !6)