xref: /llvm-project/llvm/test/DebugInfo/MSP430/ranges_always.ll (revision c395a846001aa953e54916c6f88da22173efb25e)
1; RUN: llc -O0 %s -mtriple=msp430 -filetype=obj -o - -minimize-addr-in-v5=Ranges \
2; RUN:   | llvm-dwarfdump -debug-info -debug-addr -debug-rnglists -v - \
3; RUN:   | FileCheck --check-prefix=CHECK --check-prefix=RNG \
4; RUN:     --implicit-check-not=DW_TAG --implicit-check-not=NULL --implicit-check-not=_pc %s
5
6; RUN: llc -O0 %s -mtriple=msp430 -filetype=obj -o - -minimize-addr-in-v5=Expressions \
7; RUN:   | llvm-dwarfdump -debug-info -debug-addr -debug-rnglists -v - \
8; RUN:   | FileCheck --check-prefix=CHECK --check-prefix=EXPRORFORM --check-prefix=EXPR\
9; RUN:     --implicit-check-not=DW_TAG --implicit-check-not=NULL --implicit-check-not=_pc %s
10
11; RUN: llc -O0 %s -mtriple=msp430 -filetype=obj -o - -minimize-addr-in-v5=Form \
12; RUN:   | llvm-dwarfdump -debug-info -debug-addr -debug-rnglists -v - \
13; RUN:   | FileCheck --check-prefix=CHECK --check-prefix=EXPRORFORM --check-prefix=FORM \
14; RUN:     --implicit-check-not=DW_TAG --implicit-check-not=NULL --implicit-check-not=_pc %s
15
16; Ported from X86 test to cover 2-byte address size case
17; Check that 16-bit addresses of MSP430 are properly stored
18; in 32-bit DWARF fields
19
20; Generated from the following source. f4 is used to put a hole in the CU
21; ranges while keeping f2 and f4 in the same section (as opposed to
22; -ffunction-sections, which would produce CU ranges, but each function would
23; be in a different section, so unable to share addresses). The call to f1 at
24; the start of f3 ensures the range for the inlined subroutine doesn't share
25; the starting address with f3 (so it can be improved by using a rnglist to
26; allow it to share an address it wouldn't already be sharing).
27
28; Without f6 being in another section, technically we could use a non-zero CU
29; low_pc that could act as a base address for all the addresses in the CU & avoid
30; the need for these forced rnglists - we don't do that currently, but f6 ensures
31; that this test will remain meaningful even if that improvement is made in the
32; future. (implementing that would require detecting that all the addresses in
33; the CU ranges are in the same section, then picking the lowest such address as
34; the base address to make all other addresses relative to)
35
36; IR from the following, compiled with:
37; $ clang -g -c -gdwarf-5 -O1
38; __attribute__((optnone)) void f1() { }
39; __attribute__((always_inline)) inline void f2() {
40;   f1();
41; }
42; void f3() {
43;   f1();
44;   f2();
45; }
46; __attribute__((nodebug)) void f4() {
47; }
48; void f5() {
49; }
50; __attribute__((section(".other"))) void f6() {
51; }
52
53; CHECK-LABEL: .debug_info contents:
54; CHECK: DW_TAG_compile_unit
55; CHECK:   DW_AT_low_pc
56; CHECK-SAME: (0x00000000)
57; RNG:     DW_AT_ranges
58; RNG-SAME:  (indexed (0x3) rangelist = [[CU_RANGE:.*]]
59; EXPRORFORM: DW_AT_ranges
60; EXPRORFORM-SAME: (indexed (0x0) rangelist = [[CU_RANGE:.*]]
61; CHECK:   DW_TAG_subprogram
62; CHECK:     DW_AT_low_pc
63; CHECK-SAME:  (indexed (00000000) address = 0x00000000 ".text")
64; CHECK:     DW_AT_high_pc
65; CHECK-SAME:  (0x00000002)
66; CHECK:     DW_AT_name
67; CHECK-SAME:  "f1"
68; CHECK:   DW_TAG_subprogram
69; CHECK:     DW_AT_name
70; CHECK-SAME:  "f2"
71; CHECK:   DW_TAG_subprogram
72; EXPR:      DW_AT_low_pc
73; EXPR-SAME:   (DW_OP_addrx 0x0, DW_OP_const4u 0x2, DW_OP_plus)
74; FORM:      DW_AT_low_pc
75; FORM-SAME:   [DW_FORM_LLVM_addrx_offset] (indexed (00000000) + 0x2 address = 0x00000002 ".text")
76; EXPRORFORM: DW_AT_high_pc
77; EXPRORFORM-SAME: (0x0000000a)
78; RNG:       DW_AT_ranges
79; RNG-SAME:    (indexed (0x0) rangelist = [[F3_RANGE:.*]]
80; CHECK:     DW_AT_name
81; CHECK-SAME: "f3"
82; CHECK:     DW_TAG_inlined_subroutine
83; EXPR:        DW_AT_low_pc
84; EXPR-SAME:     [DW_FORM_exprloc] (DW_OP_addrx 0x0, DW_OP_const4u 0x6, DW_OP_plus)
85; FORM:        DW_AT_low_pc
86; FORM-SAME:     [DW_FORM_LLVM_addrx_offset] (indexed (00000000) + 0x6 address = 0x00000006 ".text")
87; EXPRORFORM:  DW_AT_high_pc
88; EXPRORFORM-SAME: (0x00000004)
89; RNG:         DW_AT_ranges
90; RNG-SAME:      (indexed (0x1) rangelist = [[INL_RANGE:.*]]
91; CHECK:     DW_TAG_call_site
92; RNG:         DW_AT_call_return_pc
93; RNG-SAME:      (indexed (00000001) address = 0x00000006 ".text")
94; EXPR:        DW_AT_call_return_pc
95; EXPR-SAME:     [DW_FORM_exprloc] (DW_OP_addrx 0x0, DW_OP_const4u 0x6, DW_OP_plus)
96; FORM:        DW_AT_call_return_pc
97; FORM-SAME:     [DW_FORM_LLVM_addrx_offset] (indexed (00000000) + 0x6 address = 0x00000006 ".text")
98; CHECK:     DW_TAG_call_site
99; RNG:         DW_AT_call_return_pc
100; RNG-SAME:      (indexed (00000002) address = 0x0000000a ".text")
101; EXPR:        DW_AT_call_return_pc
102; EXPR-SAME:     [DW_FORM_exprloc] (DW_OP_addrx 0x0, DW_OP_const4u 0xa, DW_OP_plus)
103; FORM:        DW_AT_call_return_pc
104; FORM-SAME:     [DW_FORM_LLVM_addrx_offset] (indexed (00000000) + 0xa address = 0x0000000a ".text")
105; CHECK:     NULL
106; CHECK:   DW_TAG_subprogram
107; EXPR:      DW_AT_low_pc
108; EXPR-SAME:   [DW_FORM_exprloc] (DW_OP_addrx 0x0, DW_OP_const4u 0xe, DW_OP_plus)
109; FORM:      DW_AT_low_pc
110; FORM-SAME:   [DW_FORM_LLVM_addrx_offset] (indexed (00000000) + 0xe address = 0x0000000e ".text")
111; EXPRORFORM: DW_AT_high_pc
112; EXPRORFORM-SAME: (0x00000002)
113; RNG:       DW_AT_ranges
114; RNG-SAME:    (indexed (0x2) rangelist = [[F5_RANGE:.*]]
115; CHECK:     DW_AT_name
116; CHECK-SAME:  "f5"
117; CHECK:   DW_TAG_subprogram
118; CHECK:     DW_AT_low_pc [DW_FORM_addrx]    (indexed (
119; RNG-SAME: 00000003
120; EXPRORFORM-SAME: 00000001
121; CHECK: ) address = 0x00000000 ".other")
122; CHECK:     DW_AT_high_pc
123; CHECK-SAME:  (0x00000006)
124; CHECK:     DW_AT_name
125; CHECK-SAME: "f6"
126; CHECK:       DW_TAG_inlined_subroutine
127; RNG:           DW_AT_low_pc
128; RNG-SAME:        (indexed (00000003) address = 0x00000000 ".other")
129; EXPRORFORM:    DW_AT_low_pc
130; EXPRORFORM-SAME: (indexed (00000001) address = 0x00000000 ".other")
131; CHECK:         DW_AT_high_pc
132; CHECK-SAME:      (0x00000004)
133; CHECK:       DW_TAG_call_site
134; CHECK:         DW_AT_call_return_pc
135; CHECK:       NULL
136; CHECK:   NULL
137
138; CHECK-LABEL: .debug_addr contents:
139; CHECK: 0x00000000: Address table
140; CHECK-NEXT: Addrs: [
141; CHECK-NEXT: 0x00000000
142; RNG-NEXT:   0x00000006
143; RNG-NEXT:   0x0000000a
144; CHECK-NEXT: 0x00000000
145; RNG-NEXT:   0x00000004
146; CHECK-NEXT: ]
147
148; CHECK-LABEL: .debug_rnglists contents:
149; RNG: 0x00000000: range list header: {{.*}}, offset_entry_count = 0x00000004
150; EXPRORFORM: 0x00000000: range list header: {{.*}}, offset_entry_count = 0x00000001
151; CHECK: ranges:
152; RNG-NEXT:   [[F3_RANGE]]: [DW_RLE_base_addressx]:
153; RNG-SAME:                   0x00000000
154; RNG-NEXT:                 [DW_RLE_offset_pair  ]
155; RNG-NEXT:                 [DW_RLE_end_of_list  ]
156
157; RNG-NEXT:   [[INL_RANGE]]: [DW_RLE_base_addressx]:
158; RNG-SAME:                    0x00000000
159; RNG-NEXT:                  [DW_RLE_offset_pair  ]
160; RNG-NEXT:                  [DW_RLE_end_of_list  ]
161
162; RNG-NEXT:   [[F5_RANGE]]: [DW_RLE_base_addressx]:
163; RNG-SAME:                   0x00000000
164; RNG-NEXT:                 [DW_RLE_offset_pair  ]
165; RNG-NEXT:                 [DW_RLE_end_of_list  ]
166
167; CHECK-NEXT: [[CU_RANGE]]: [DW_RLE_base_addressx]:
168; CHECK-SAME:                 0x00000000
169; CHECK-NEXT:               [DW_RLE_offset_pair  ]
170; CHECK-NEXT:               [DW_RLE_offset_pair  ]
171; RNG-NEXT:                 [DW_RLE_startx_length]:
172; RNG-SAME:                   0x00000003
173; EXPRORFORM-NEXT:          [DW_RLE_startx_length]:
174; EXPRORFORM-SAME:            0x00000001
175; CHECK-NEXT:               [DW_RLE_end_of_list  ]
176
177; Function Attrs: mustprogress noinline nounwind optnone uwtable
178define dso_local void @_Z2f1v() local_unnamed_addr #0 !dbg !7 {
179entry:
180  ret void, !dbg !12
181}
182
183; Function Attrs: mustprogress nounwind uwtable
184define dso_local void @_Z2f3v() local_unnamed_addr #1 !dbg !13 {
185entry:
186  call void @_Z2f1v(), !dbg !14
187  call void @_Z2f1v() #3, !dbg !15
188  ret void, !dbg !18
189}
190
191; Function Attrs: mustprogress nofree norecurse nosync nounwind readnone uwtable willreturn
192define dso_local void @_Z2f4v() local_unnamed_addr #2 {
193entry:
194  ret void
195}
196
197; Function Attrs: mustprogress nofree norecurse nosync nounwind readnone uwtable willreturn
198define dso_local void @_Z2f5v() local_unnamed_addr #2 !dbg !19 {
199entry:
200  ret void, !dbg !20
201}
202
203; Function Attrs: mustprogress nounwind uwtable
204define dso_local void @_Z2f6v() local_unnamed_addr #1 section ".other" !dbg !21 {
205entry:
206  call void @_Z2f1v() #3, !dbg !22
207  ret void, !dbg !24
208}
209
210attributes #0 = { mustprogress noinline nounwind optnone uwtable "frame-pointer"="none" "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
211attributes #1 = { mustprogress nounwind uwtable "frame-pointer"="none" "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
212attributes #2 = { mustprogress nofree norecurse nosync nounwind readnone uwtable willreturn "frame-pointer"="none" "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
213attributes #3 = { nounwind }
214
215!llvm.dbg.cu = !{!0}
216!llvm.module.flags = !{!2, !3, !4, !5}
217!llvm.ident = !{!6}
218
219!0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus_14, file: !1, producer: "clang version 14.0.0 (git@github.com:llvm/llvm-project.git e2c3dc6fc76e767f08249f6d2c36e41660a4e331)", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, splitDebugInlining: false, nameTableKind: None)
220!1 = !DIFile(filename: "/usr/local/google/home/blaikie/dev/scratch/test.cpp", directory: "/usr/local/google/home/blaikie/dev/llvm/src", checksumkind: CSK_MD5, checksum: "e70db21a276125757057e729999c09c7")
221!2 = !{i32 7, !"Dwarf Version", i32 5}
222!3 = !{i32 2, !"Debug Info Version", i32 3}
223!4 = !{i32 1, !"wchar_size", i32 4}
224!5 = !{i32 7, !"uwtable", i32 1}
225!6 = !{!"clang version 14.0.0 (git@github.com:llvm/llvm-project.git e2c3dc6fc76e767f08249f6d2c36e41660a4e331)"}
226!7 = distinct !DISubprogram(name: "f1", linkageName: "_Z2f1v", scope: !8, file: !8, line: 1, type: !9, scopeLine: 1, flags: DIFlagPrototyped | DIFlagAllCallsDescribed, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !0, retainedNodes: !11)
227!8 = !DIFile(filename: "scratch/test.cpp", directory: "/usr/local/google/home/blaikie/dev", checksumkind: CSK_MD5, checksum: "e70db21a276125757057e729999c09c7")
228!9 = !DISubroutineType(types: !10)
229!10 = !{null}
230!11 = !{}
231!12 = !DILocation(line: 1, column: 38, scope: !7)
232!13 = distinct !DISubprogram(name: "f3", linkageName: "_Z2f3v", scope: !8, file: !8, line: 5, type: !9, scopeLine: 5, flags: DIFlagPrototyped | DIFlagAllCallsDescribed, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !0, retainedNodes: !11)
233!14 = !DILocation(line: 6, column: 3, scope: !13)
234!15 = !DILocation(line: 3, column: 3, scope: !16, inlinedAt: !17)
235!16 = distinct !DISubprogram(name: "f2", linkageName: "_Z2f2v", scope: !8, file: !8, line: 2, type: !9, scopeLine: 2, flags: DIFlagPrototyped | DIFlagAllCallsDescribed, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !0, retainedNodes: !11)
236!17 = distinct !DILocation(line: 7, column: 3, scope: !13)
237!18 = !DILocation(line: 8, column: 1, scope: !13)
238!19 = distinct !DISubprogram(name: "f5", linkageName: "_Z2f5v", scope: !8, file: !8, line: 11, type: !9, scopeLine: 11, flags: DIFlagPrototyped | DIFlagAllCallsDescribed, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !0, retainedNodes: !11)
239!20 = !DILocation(line: 12, column: 1, scope: !19)
240!21 = distinct !DISubprogram(name: "f6", linkageName: "_Z2f6v", scope: !8, file: !8, line: 13, type: !9, scopeLine: 13, flags: DIFlagPrototyped | DIFlagAllCallsDescribed, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !0, retainedNodes: !11)
241!22 = !DILocation(line: 3, column: 3, scope: !16, inlinedAt: !23)
242!23 = distinct !DILocation(line: 14, column: 3, scope: !21)
243!24 = !DILocation(line: 15, column: 1, scope: !21)
244