1; RUN: llc -split-dwarf=Enable -O0 %s -function-sections -mtriple=x86_64-unknown-linux-gnu -filetype=obj -o %t 2; RUN: llvm-dwarfdump -debug-dump=abbrev %t | FileCheck --check-prefix=FUNCTION-SECTIONS %s 3; RUN: llvm-readobj --relocations %t | FileCheck --check-prefix=FUNCTION-SECTIONS-RELOCS %s 4 5; RUN: llc -split-dwarf=Enable -O0 %s -mtriple=x86_64-unknown-linux-gnu -filetype=obj -o %t 6; RUN: llvm-dwarfdump -debug-dump=abbrev %t | FileCheck --check-prefix=NO-FUNCTION-SECTIONS %s 7 8; From: 9; int foo (int a) { 10; return a+1; 11; } 12; int bar (int b) { 13; return b+2; 14; } 15 16; With function sections enabled make sure that we have a DW_AT_ranges attribute. 17; FUNCTION-SECTIONS: DW_AT_ranges 18 19; Check that we have a relocation against the .debug_ranges section. 20; FUNCTION-SECTIONS-RELOCS: R_X86_64_32 .debug_ranges 0x0 21 22; Without function sections enabled make sure that we have no DW_AT_ranges attribute. 23; NO-FUNCTION-SECTIONS-NOT: DW_AT_ranges 24; NO-FUNCTION-SECTIONS: DW_AT_low_pc DW_FORM_addr 25; NO-FUNCTION-SECTIONS-NOT: DW_AT_ranges 26 27; Function Attrs: nounwind uwtable 28define i32 @foo(i32 %a) #0 { 29entry: 30 %a.addr = alloca i32, align 4 31 store i32 %a, i32* %a.addr, align 4 32 call void @llvm.dbg.declare(metadata i32* %a.addr, metadata !13, metadata !MDExpression()), !dbg !14 33 %0 = load i32, i32* %a.addr, align 4, !dbg !14 34 %add = add nsw i32 %0, 1, !dbg !14 35 ret i32 %add, !dbg !14 36} 37 38; Function Attrs: nounwind readnone 39declare void @llvm.dbg.declare(metadata, metadata, metadata) #1 40 41; Function Attrs: nounwind uwtable 42define i32 @bar(i32 %b) #0 { 43entry: 44 %b.addr = alloca i32, align 4 45 store i32 %b, i32* %b.addr, align 4 46 call void @llvm.dbg.declare(metadata i32* %b.addr, metadata !15, metadata !MDExpression()), !dbg !16 47 %0 = load i32, i32* %b.addr, align 4, !dbg !16 48 %add = add nsw i32 %0, 2, !dbg !16 49 ret i32 %add, !dbg !16 50} 51 52attributes #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" } 53attributes #1 = { nounwind readnone } 54 55!llvm.dbg.cu = !{!0} 56!llvm.module.flags = !{!10, !11} 57!llvm.ident = !{!12} 58 59!0 = !MDCompileUnit(language: DW_LANG_C99, producer: "clang version 3.5.0 (trunk 204164) (llvm/trunk 204183)", isOptimized: false, emissionKind: 1, file: !1, enums: !2, retainedTypes: !2, subprograms: !3, globals: !2, imports: !2) 60!1 = !MDFile(filename: "z.c", directory: "/usr/local/google/home/echristo") 61!2 = !{} 62!3 = !{!4, !9} 63!4 = !MDSubprogram(name: "foo", line: 1, isLocal: false, isDefinition: true, virtualIndex: 6, flags: DIFlagPrototyped, isOptimized: false, scopeLine: 1, file: !1, scope: !5, type: !6, function: i32 (i32)* @foo, variables: !2) 64!5 = !MDFile(filename: "z.c", directory: "/usr/local/google/home/echristo") 65!6 = !MDSubroutineType(types: !7) 66!7 = !{!8, !8} 67!8 = !MDBasicType(tag: DW_TAG_base_type, name: "int", size: 32, align: 32, encoding: DW_ATE_signed) 68!9 = !MDSubprogram(name: "bar", line: 2, isLocal: false, isDefinition: true, virtualIndex: 6, flags: DIFlagPrototyped, isOptimized: false, scopeLine: 2, file: !1, scope: !5, type: !6, function: i32 (i32)* @bar, variables: !2) 69!10 = !{i32 2, !"Dwarf Version", i32 4} 70!11 = !{i32 1, !"Debug Info Version", i32 3} 71!12 = !{!"clang version 3.5.0 (trunk 204164) (llvm/trunk 204183)"} 72!13 = !MDLocalVariable(tag: DW_TAG_arg_variable, name: "a", line: 1, arg: 1, scope: !4, file: !5, type: !8) 73!14 = !MDLocation(line: 1, scope: !4) 74!15 = !MDLocalVariable(tag: DW_TAG_arg_variable, name: "b", line: 2, arg: 1, scope: !9, file: !5, type: !8) 75!16 = !MDLocation(line: 2, scope: !9) 76