xref: /aosp_15_r20/external/llvm/test/DebugInfo/X86/cu-ranges.ll (revision 9880d6810fe72a1726cb53787c6711e909410d58)
1*9880d681SAndroid Build Coastguard Worker; RUN: llc -split-dwarf=Enable -O0 %s -function-sections -mtriple=x86_64-unknown-linux-gnu -filetype=obj -o %t
2*9880d681SAndroid Build Coastguard Worker; RUN: llvm-dwarfdump -debug-dump=abbrev %t | FileCheck --check-prefix=FUNCTION-SECTIONS %s
3*9880d681SAndroid Build Coastguard Worker; RUN: llvm-readobj --relocations %t | FileCheck --check-prefix=FUNCTION-SECTIONS-RELOCS %s
4*9880d681SAndroid Build Coastguard Worker
5*9880d681SAndroid Build Coastguard Worker; RUN: llc -split-dwarf=Enable -O0 %s -mtriple=x86_64-unknown-linux-gnu -filetype=obj -o %t
6*9880d681SAndroid Build Coastguard Worker; RUN: llvm-dwarfdump -debug-dump=abbrev %t | FileCheck --check-prefix=NO-FUNCTION-SECTIONS %s
7*9880d681SAndroid Build Coastguard Worker
8*9880d681SAndroid Build Coastguard Worker; From:
9*9880d681SAndroid Build Coastguard Worker; int foo (int a) {
10*9880d681SAndroid Build Coastguard Worker;   return a+1;
11*9880d681SAndroid Build Coastguard Worker; }
12*9880d681SAndroid Build Coastguard Worker; int bar (int b) {
13*9880d681SAndroid Build Coastguard Worker;   return b+2;
14*9880d681SAndroid Build Coastguard Worker; }
15*9880d681SAndroid Build Coastguard Worker
16*9880d681SAndroid Build Coastguard Worker; With function sections enabled make sure that we have a DW_AT_ranges attribute.
17*9880d681SAndroid Build Coastguard Worker; FUNCTION-SECTIONS: DW_AT_ranges
18*9880d681SAndroid Build Coastguard Worker
19*9880d681SAndroid Build Coastguard Worker; Check that we have a relocation against the .debug_ranges section.
20*9880d681SAndroid Build Coastguard Worker; FUNCTION-SECTIONS-RELOCS: R_X86_64_32 .debug_ranges 0x0
21*9880d681SAndroid Build Coastguard Worker
22*9880d681SAndroid Build Coastguard Worker; Without function sections enabled make sure that we have no DW_AT_ranges attribute.
23*9880d681SAndroid Build Coastguard Worker; NO-FUNCTION-SECTIONS-NOT: DW_AT_ranges
24*9880d681SAndroid Build Coastguard Worker; NO-FUNCTION-SECTIONS: DW_AT_low_pc DW_FORM_addr
25*9880d681SAndroid Build Coastguard Worker; NO-FUNCTION-SECTIONS-NOT: DW_AT_ranges
26*9880d681SAndroid Build Coastguard Worker
27*9880d681SAndroid Build Coastguard Worker; Function Attrs: nounwind uwtable
28*9880d681SAndroid Build Coastguard Workerdefine i32 @foo(i32 %a) #0 !dbg !4 {
29*9880d681SAndroid Build Coastguard Workerentry:
30*9880d681SAndroid Build Coastguard Worker  %a.addr = alloca i32, align 4
31*9880d681SAndroid Build Coastguard Worker  store i32 %a, i32* %a.addr, align 4
32*9880d681SAndroid Build Coastguard Worker  call void @llvm.dbg.declare(metadata i32* %a.addr, metadata !13, metadata !DIExpression()), !dbg !14
33*9880d681SAndroid Build Coastguard Worker  %0 = load i32, i32* %a.addr, align 4, !dbg !14
34*9880d681SAndroid Build Coastguard Worker  %add = add nsw i32 %0, 1, !dbg !14
35*9880d681SAndroid Build Coastguard Worker  ret i32 %add, !dbg !14
36*9880d681SAndroid Build Coastguard Worker}
37*9880d681SAndroid Build Coastguard Worker
38*9880d681SAndroid Build Coastguard Worker; Function Attrs: nounwind readnone
39*9880d681SAndroid Build Coastguard Workerdeclare void @llvm.dbg.declare(metadata, metadata, metadata) #1
40*9880d681SAndroid Build Coastguard Worker
41*9880d681SAndroid Build Coastguard Worker; Function Attrs: nounwind uwtable
42*9880d681SAndroid Build Coastguard Workerdefine i32 @bar(i32 %b) #0 !dbg !9 {
43*9880d681SAndroid Build Coastguard Workerentry:
44*9880d681SAndroid Build Coastguard Worker  %b.addr = alloca i32, align 4
45*9880d681SAndroid Build Coastguard Worker  store i32 %b, i32* %b.addr, align 4
46*9880d681SAndroid Build Coastguard Worker  call void @llvm.dbg.declare(metadata i32* %b.addr, metadata !15, metadata !DIExpression()), !dbg !16
47*9880d681SAndroid Build Coastguard Worker  %0 = load i32, i32* %b.addr, align 4, !dbg !16
48*9880d681SAndroid Build Coastguard Worker  %add = add nsw i32 %0, 2, !dbg !16
49*9880d681SAndroid Build Coastguard Worker  ret i32 %add, !dbg !16
50*9880d681SAndroid Build Coastguard Worker}
51*9880d681SAndroid Build Coastguard Worker
52*9880d681SAndroid Build Coastguard Workerattributes #0 = { nounwind uwtable "less-precise-fpmad"="false" "no-frame-pointer-elim"="true" "no-frame-pointer-elim-non-leaf" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "stack-protector-buffer-size"="8" "unsafe-fp-math"="false" "use-soft-float"="false" }
53*9880d681SAndroid Build Coastguard Workerattributes #1 = { nounwind readnone }
54*9880d681SAndroid Build Coastguard Worker
55*9880d681SAndroid Build Coastguard Worker!llvm.dbg.cu = !{!0}
56*9880d681SAndroid Build Coastguard Worker!llvm.module.flags = !{!10, !11}
57*9880d681SAndroid Build Coastguard Worker!llvm.ident = !{!12}
58*9880d681SAndroid Build Coastguard Worker
59*9880d681SAndroid Build Coastguard Worker!0 = distinct !DICompileUnit(language: DW_LANG_C99, producer: "clang version 3.5.0 (trunk 204164) (llvm/trunk 204183)", isOptimized: false, emissionKind: FullDebug, file: !1, enums: !2, retainedTypes: !2, globals: !2, imports: !2)
60*9880d681SAndroid Build Coastguard Worker!1 = !DIFile(filename: "z.c", directory: "/usr/local/google/home/echristo")
61*9880d681SAndroid Build Coastguard Worker!2 = !{}
62*9880d681SAndroid Build Coastguard Worker!4 = distinct !DISubprogram(name: "foo", line: 1, isLocal: false, isDefinition: true, virtualIndex: 6, flags: DIFlagPrototyped, isOptimized: false, unit: !0, scopeLine: 1, file: !1, scope: !5, type: !6, variables: !2)
63*9880d681SAndroid Build Coastguard Worker!5 = !DIFile(filename: "z.c", directory: "/usr/local/google/home/echristo")
64*9880d681SAndroid Build Coastguard Worker!6 = !DISubroutineType(types: !7)
65*9880d681SAndroid Build Coastguard Worker!7 = !{!8, !8}
66*9880d681SAndroid Build Coastguard Worker!8 = !DIBasicType(tag: DW_TAG_base_type, name: "int", size: 32, align: 32, encoding: DW_ATE_signed)
67*9880d681SAndroid Build Coastguard Worker!9 = distinct !DISubprogram(name: "bar", line: 2, isLocal: false, isDefinition: true, virtualIndex: 6, flags: DIFlagPrototyped, isOptimized: false, unit: !0, scopeLine: 2, file: !1, scope: !5, type: !6, variables: !2)
68*9880d681SAndroid Build Coastguard Worker!10 = !{i32 2, !"Dwarf Version", i32 4}
69*9880d681SAndroid Build Coastguard Worker!11 = !{i32 1, !"Debug Info Version", i32 3}
70*9880d681SAndroid Build Coastguard Worker!12 = !{!"clang version 3.5.0 (trunk 204164) (llvm/trunk 204183)"}
71*9880d681SAndroid Build Coastguard Worker!13 = !DILocalVariable(name: "a", line: 1, arg: 1, scope: !4, file: !5, type: !8)
72*9880d681SAndroid Build Coastguard Worker!14 = !DILocation(line: 1, scope: !4)
73*9880d681SAndroid Build Coastguard Worker!15 = !DILocalVariable(name: "b", line: 2, arg: 1, scope: !9, file: !5, type: !8)
74*9880d681SAndroid Build Coastguard Worker!16 = !DILocation(line: 2, scope: !9)
75