David Blaikie | 96b1ed5 | 2017-04-21 23:35:26 +0000 | [diff] [blame^] | 1 | ; RUN: llc -split-dwarf-file=foo.dwo -O0 %s -function-sections -mtriple=x86_64-unknown-linux-gnu -filetype=obj -o %t |
David Blaikie | c42f9ac | 2014-09-07 17:31:42 +0000 | [diff] [blame] | 2 | ; RUN: llvm-dwarfdump -debug-dump=abbrev %t | FileCheck --check-prefix=FUNCTION-SECTIONS %s |
Eric Christopher | 1ad8457 | 2014-01-15 00:04:29 +0000 | [diff] [blame] | 3 | ; RUN: llvm-readobj --relocations %t | FileCheck --check-prefix=FUNCTION-SECTIONS-RELOCS %s |
Eric Christopher | fb4a99c | 2014-01-14 22:57:52 +0000 | [diff] [blame] | 4 | |
David Blaikie | 96b1ed5 | 2017-04-21 23:35:26 +0000 | [diff] [blame^] | 5 | ; RUN: llc -split-dwarf-file=foo.dwo -O0 %s -mtriple=x86_64-unknown-linux-gnu -filetype=obj -o %t |
David Blaikie | c42f9ac | 2014-09-07 17:31:42 +0000 | [diff] [blame] | 6 | ; RUN: llvm-dwarfdump -debug-dump=abbrev %t | FileCheck --check-prefix=NO-FUNCTION-SECTIONS %s |
Eric Christopher | fb4a99c | 2014-01-14 22:57:52 +0000 | [diff] [blame] | 7 | |
| 8 | ; From: |
| 9 | ; int foo (int a) { |
| 10 | ; return a+1; |
| 11 | ; } |
Eric Christopher | 384f3fe | 2014-03-20 19:16:16 +0000 | [diff] [blame] | 12 | ; int bar (int b) { |
| 13 | ; return b+2; |
| 14 | ; } |
Eric Christopher | fb4a99c | 2014-01-14 22:57:52 +0000 | [diff] [blame] | 15 | |
| 16 | ; With function sections enabled make sure that we have a DW_AT_ranges attribute. |
| 17 | ; FUNCTION-SECTIONS: DW_AT_ranges |
| 18 | |
Eric Christopher | 1ad8457 | 2014-01-15 00:04:29 +0000 | [diff] [blame] | 19 | ; Check that we have a relocation against the .debug_ranges section. |
| 20 | ; FUNCTION-SECTIONS-RELOCS: R_X86_64_32 .debug_ranges 0x0 |
| 21 | |
Eric Christopher | fb4a99c | 2014-01-14 22:57:52 +0000 | [diff] [blame] | 22 | ; Without function sections enabled make sure that we have no DW_AT_ranges attribute. |
| 23 | ; NO-FUNCTION-SECTIONS-NOT: DW_AT_ranges |
David Blaikie | c42f9ac | 2014-09-07 17:31:42 +0000 | [diff] [blame] | 24 | ; NO-FUNCTION-SECTIONS: DW_AT_low_pc DW_FORM_addr |
| 25 | ; NO-FUNCTION-SECTIONS-NOT: DW_AT_ranges |
Eric Christopher | fb4a99c | 2014-01-14 22:57:52 +0000 | [diff] [blame] | 26 | |
| 27 | ; Function Attrs: nounwind uwtable |
Peter Collingbourne | d4bff30 | 2015-11-05 22:03:56 +0000 | [diff] [blame] | 28 | define i32 @foo(i32 %a) #0 !dbg !4 { |
Eric Christopher | fb4a99c | 2014-01-14 22:57:52 +0000 | [diff] [blame] | 29 | entry: |
| 30 | %a.addr = alloca i32, align 4 |
| 31 | store i32 %a, i32* %a.addr, align 4 |
Duncan P. N. Exon Smith | a9308c4 | 2015-04-29 16:38:44 +0000 | [diff] [blame] | 32 | call void @llvm.dbg.declare(metadata i32* %a.addr, metadata !13, metadata !DIExpression()), !dbg !14 |
David Blaikie | a79ac14 | 2015-02-27 21:17:42 +0000 | [diff] [blame] | 33 | %0 = load i32, i32* %a.addr, align 4, !dbg !14 |
Eric Christopher | fb4a99c | 2014-01-14 22:57:52 +0000 | [diff] [blame] | 34 | %add = add nsw i32 %0, 1, !dbg !14 |
| 35 | ret i32 %add, !dbg !14 |
| 36 | } |
| 37 | |
| 38 | ; Function Attrs: nounwind readnone |
Adrian Prantl | 87b7eb9 | 2014-10-01 18:55:02 +0000 | [diff] [blame] | 39 | declare void @llvm.dbg.declare(metadata, metadata, metadata) #1 |
Eric Christopher | fb4a99c | 2014-01-14 22:57:52 +0000 | [diff] [blame] | 40 | |
Eric Christopher | 384f3fe | 2014-03-20 19:16:16 +0000 | [diff] [blame] | 41 | ; Function Attrs: nounwind uwtable |
Peter Collingbourne | d4bff30 | 2015-11-05 22:03:56 +0000 | [diff] [blame] | 42 | define i32 @bar(i32 %b) #0 !dbg !9 { |
Eric Christopher | 384f3fe | 2014-03-20 19:16:16 +0000 | [diff] [blame] | 43 | entry: |
| 44 | %b.addr = alloca i32, align 4 |
| 45 | store i32 %b, i32* %b.addr, align 4 |
Duncan P. N. Exon Smith | a9308c4 | 2015-04-29 16:38:44 +0000 | [diff] [blame] | 46 | call void @llvm.dbg.declare(metadata i32* %b.addr, metadata !15, metadata !DIExpression()), !dbg !16 |
David Blaikie | a79ac14 | 2015-02-27 21:17:42 +0000 | [diff] [blame] | 47 | %0 = load i32, i32* %b.addr, align 4, !dbg !16 |
Eric Christopher | 384f3fe | 2014-03-20 19:16:16 +0000 | [diff] [blame] | 48 | %add = add nsw i32 %0, 2, !dbg !16 |
| 49 | ret i32 %add, !dbg !16 |
| 50 | } |
| 51 | |
Eric Christopher | fb4a99c | 2014-01-14 22:57:52 +0000 | [diff] [blame] | 52 | attributes #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 | attributes #1 = { nounwind readnone } |
| 54 | |
| 55 | !llvm.dbg.cu = !{!0} |
Eric Christopher | 384f3fe | 2014-03-20 19:16:16 +0000 | [diff] [blame] | 56 | !llvm.module.flags = !{!10, !11} |
| 57 | !llvm.ident = !{!12} |
Eric Christopher | fb4a99c | 2014-01-14 22:57:52 +0000 | [diff] [blame] | 58 | |
Adrian Prantl | 75819ae | 2016-04-15 15:57:41 +0000 | [diff] [blame] | 59 | !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 Smith | a9308c4 | 2015-04-29 16:38:44 +0000 | [diff] [blame] | 60 | !1 = !DIFile(filename: "z.c", directory: "/usr/local/google/home/echristo") |
Duncan P. N. Exon Smith | be7ea19 | 2014-12-15 19:07:53 +0000 | [diff] [blame] | 61 | !2 = !{} |
Adrian Prantl | 75819ae | 2016-04-15 15:57:41 +0000 | [diff] [blame] | 62 | !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) |
Duncan P. N. Exon Smith | a9308c4 | 2015-04-29 16:38:44 +0000 | [diff] [blame] | 63 | !5 = !DIFile(filename: "z.c", directory: "/usr/local/google/home/echristo") |
| 64 | !6 = !DISubroutineType(types: !7) |
Duncan P. N. Exon Smith | be7ea19 | 2014-12-15 19:07:53 +0000 | [diff] [blame] | 65 | !7 = !{!8, !8} |
Duncan P. N. Exon Smith | a9308c4 | 2015-04-29 16:38:44 +0000 | [diff] [blame] | 66 | !8 = !DIBasicType(tag: DW_TAG_base_type, name: "int", size: 32, align: 32, encoding: DW_ATE_signed) |
Adrian Prantl | 75819ae | 2016-04-15 15:57:41 +0000 | [diff] [blame] | 67 | !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) |
Duncan P. N. Exon Smith | be7ea19 | 2014-12-15 19:07:53 +0000 | [diff] [blame] | 68 | !10 = !{i32 2, !"Dwarf Version", i32 4} |
Duncan P. N. Exon Smith | e274180 | 2015-03-03 17:24:31 +0000 | [diff] [blame] | 69 | !11 = !{i32 1, !"Debug Info Version", i32 3} |
Duncan P. N. Exon Smith | be7ea19 | 2014-12-15 19:07:53 +0000 | [diff] [blame] | 70 | !12 = !{!"clang version 3.5.0 (trunk 204164) (llvm/trunk 204183)"} |
Duncan P. N. Exon Smith | ed013cd | 2015-07-31 18:58:39 +0000 | [diff] [blame] | 71 | !13 = !DILocalVariable(name: "a", line: 1, arg: 1, scope: !4, file: !5, type: !8) |
Duncan P. N. Exon Smith | a9308c4 | 2015-04-29 16:38:44 +0000 | [diff] [blame] | 72 | !14 = !DILocation(line: 1, scope: !4) |
Duncan P. N. Exon Smith | ed013cd | 2015-07-31 18:58:39 +0000 | [diff] [blame] | 73 | !15 = !DILocalVariable(name: "b", line: 2, arg: 1, scope: !9, file: !5, type: !8) |
Duncan P. N. Exon Smith | a9308c4 | 2015-04-29 16:38:44 +0000 | [diff] [blame] | 74 | !16 = !DILocation(line: 2, scope: !9) |