blob: 90911d8ef71b0b7bef6f8059da5aa625c2c3d5ad [file] [log] [blame]
David Blaikie96b1ed52017-04-21 23:35:26 +00001; RUN: llc -split-dwarf-file=foo.dwo -O0 %s -function-sections -mtriple=x86_64-unknown-linux-gnu -filetype=obj -o %t
Adrian Prantl7bc1b282017-09-11 22:59:45 +00002; RUN: llvm-dwarfdump -debug-abbrev %t | FileCheck --check-prefix=FUNCTION-SECTIONS %s
Eric Christopher1ad84572014-01-15 00:04:29 +00003; RUN: llvm-readobj --relocations %t | FileCheck --check-prefix=FUNCTION-SECTIONS-RELOCS %s
Eric Christopherfb4a99c2014-01-14 22:57:52 +00004
David Blaikie96b1ed52017-04-21 23:35:26 +00005; RUN: llc -split-dwarf-file=foo.dwo -O0 %s -mtriple=x86_64-unknown-linux-gnu -filetype=obj -o %t
Adrian Prantl7bc1b282017-09-11 22:59:45 +00006; RUN: llvm-dwarfdump -debug-abbrev %t | FileCheck --check-prefix=NO-FUNCTION-SECTIONS %s
Eric Christopherfb4a99c2014-01-14 22:57:52 +00007
Wolfgang Pieb9ea65082018-07-26 22:48:52 +00008; RUN: llc -dwarf-version=5 -O0 %s -mtriple=x86_64-unknown-linux-gnu -filetype=obj -o %t
9; RUN: llvm-dwarfdump -v %t | FileCheck --check-prefix=DWARF5 %s
10
Eric Christopherfb4a99c2014-01-14 22:57:52 +000011; From:
12; int foo (int a) {
13; return a+1;
14; }
Eric Christopher384f3fe2014-03-20 19:16:16 +000015; int bar (int b) {
16; return b+2;
17; }
Eric Christopherfb4a99c2014-01-14 22:57:52 +000018
19; With function sections enabled make sure that we have a DW_AT_ranges attribute.
20; FUNCTION-SECTIONS: DW_AT_ranges
21
Eric Christopher1ad84572014-01-15 00:04:29 +000022; Check that we have a relocation against the .debug_ranges section.
23; FUNCTION-SECTIONS-RELOCS: R_X86_64_32 .debug_ranges 0x0
24
Eric Christopherfb4a99c2014-01-14 22:57:52 +000025; Without function sections enabled make sure that we have no DW_AT_ranges attribute.
26; NO-FUNCTION-SECTIONS-NOT: DW_AT_ranges
David Blaikiec42f9ac2014-09-07 17:31:42 +000027; NO-FUNCTION-SECTIONS: DW_AT_low_pc DW_FORM_addr
28; NO-FUNCTION-SECTIONS-NOT: DW_AT_ranges
Eric Christopherfb4a99c2014-01-14 22:57:52 +000029
Wolfgang Pieb9ea65082018-07-26 22:48:52 +000030; For Dwarf 5 check that we neither generate DW_AT_rnglists_base for the CU DIE nor
31; a .debug_rnglists section. There is only 1 CU range with no scope ranges.
32;
33; DWARF5: .debug_info contents:
34; DWARF5: DW_TAG_compile_unit
35; DWARF5-NOT: DW_AT_rnglists_base [DW_FORM_sec_offset]
36; DWARF5-NOT: .debug_rnglists contents:
37
Eric Christopherfb4a99c2014-01-14 22:57:52 +000038; Function Attrs: nounwind uwtable
Peter Collingbourned4bff302015-11-05 22:03:56 +000039define i32 @foo(i32 %a) #0 !dbg !4 {
Eric Christopherfb4a99c2014-01-14 22:57:52 +000040entry:
41 %a.addr = alloca i32, align 4
42 store i32 %a, i32* %a.addr, align 4
Duncan P. N. Exon Smitha9308c42015-04-29 16:38:44 +000043 call void @llvm.dbg.declare(metadata i32* %a.addr, metadata !13, metadata !DIExpression()), !dbg !14
David Blaikiea79ac142015-02-27 21:17:42 +000044 %0 = load i32, i32* %a.addr, align 4, !dbg !14
Eric Christopherfb4a99c2014-01-14 22:57:52 +000045 %add = add nsw i32 %0, 1, !dbg !14
46 ret i32 %add, !dbg !14
47}
48
49; Function Attrs: nounwind readnone
Adrian Prantl87b7eb92014-10-01 18:55:02 +000050declare void @llvm.dbg.declare(metadata, metadata, metadata) #1
Eric Christopherfb4a99c2014-01-14 22:57:52 +000051
Eric Christopher384f3fe2014-03-20 19:16:16 +000052; Function Attrs: nounwind uwtable
Peter Collingbourned4bff302015-11-05 22:03:56 +000053define i32 @bar(i32 %b) #0 !dbg !9 {
Eric Christopher384f3fe2014-03-20 19:16:16 +000054entry:
55 %b.addr = alloca i32, align 4
56 store i32 %b, i32* %b.addr, align 4
Duncan P. N. Exon Smitha9308c42015-04-29 16:38:44 +000057 call void @llvm.dbg.declare(metadata i32* %b.addr, metadata !15, metadata !DIExpression()), !dbg !16
David Blaikiea79ac142015-02-27 21:17:42 +000058 %0 = load i32, i32* %b.addr, align 4, !dbg !16
Eric Christopher384f3fe2014-03-20 19:16:16 +000059 %add = add nsw i32 %0, 2, !dbg !16
60 ret i32 %add, !dbg !16
61}
62
Eric Christopherfb4a99c2014-01-14 22:57:52 +000063attributes #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" }
64attributes #1 = { nounwind readnone }
65
66!llvm.dbg.cu = !{!0}
Eric Christopher384f3fe2014-03-20 19:16:16 +000067!llvm.module.flags = !{!10, !11}
68!llvm.ident = !{!12}
Eric Christopherfb4a99c2014-01-14 22:57:52 +000069
Adrian Prantl75819ae2016-04-15 15:57:41 +000070!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)
Duncan P. N. Exon Smitha9308c42015-04-29 16:38:44 +000071!1 = !DIFile(filename: "z.c", directory: "/usr/local/google/home/echristo")
Duncan P. N. Exon Smithbe7ea192014-12-15 19:07:53 +000072!2 = !{}
Shiva Chen2c864552018-05-09 02:40:45 +000073!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, retainedNodes: !2)
Duncan P. N. Exon Smitha9308c42015-04-29 16:38:44 +000074!5 = !DIFile(filename: "z.c", directory: "/usr/local/google/home/echristo")
75!6 = !DISubroutineType(types: !7)
Duncan P. N. Exon Smithbe7ea192014-12-15 19:07:53 +000076!7 = !{!8, !8}
Duncan P. N. Exon Smitha9308c42015-04-29 16:38:44 +000077!8 = !DIBasicType(tag: DW_TAG_base_type, name: "int", size: 32, align: 32, encoding: DW_ATE_signed)
Shiva Chen2c864552018-05-09 02:40:45 +000078!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, retainedNodes: !2)
Duncan P. N. Exon Smithbe7ea192014-12-15 19:07:53 +000079!10 = !{i32 2, !"Dwarf Version", i32 4}
Duncan P. N. Exon Smithe2741802015-03-03 17:24:31 +000080!11 = !{i32 1, !"Debug Info Version", i32 3}
Duncan P. N. Exon Smithbe7ea192014-12-15 19:07:53 +000081!12 = !{!"clang version 3.5.0 (trunk 204164) (llvm/trunk 204183)"}
Duncan P. N. Exon Smithed013cd2015-07-31 18:58:39 +000082!13 = !DILocalVariable(name: "a", line: 1, arg: 1, scope: !4, file: !5, type: !8)
Duncan P. N. Exon Smitha9308c42015-04-29 16:38:44 +000083!14 = !DILocation(line: 1, scope: !4)
Duncan P. N. Exon Smithed013cd2015-07-31 18:58:39 +000084!15 = !DILocalVariable(name: "b", line: 2, arg: 1, scope: !9, file: !5, type: !8)
Duncan P. N. Exon Smitha9308c42015-04-29 16:38:44 +000085!16 = !DILocation(line: 2, scope: !9)