1 ; RUN: llvm-as %s -o %t.bc 2 ; RUN: llvm-as %p/Inputs/only-needed-debug-metadata.ll -o %t2.bc 3 4 ; Without -only-needed, we need to link in both DISubprogram. 5 ; RUN: llvm-link -S %t2.bc %t.bc | FileCheck %s 6 ; CHECK: distinct !DISubprogram(name: "foo" 7 ; CHECK: distinct !DISubprogram(name: "unused" 8 9 ; With -only-needed, we only need to link in foo's DISubprogram. 10 ; RUN: llvm-link -S -only-needed %t2.bc %t.bc | FileCheck %s -check-prefix=ONLYNEEDED 11 ; ONLYNEEDED: distinct !DISubprogram(name: "foo" 12 ; ONLYNEEDED-NOT: distinct !DISubprogram(name: "unused" 13 14 @X = global i32 5 15 @U = global i32 6 16 @U_linkonce = linkonce_odr hidden global i32 6 17 define i32 @foo() !dbg !4 { 18 ret i32 7, !dbg !20 19 } 20 define i32 @unused() !dbg !10 { 21 ret i32 8, !dbg !21 22 } 23 24 !llvm.dbg.cu = !{!0} 25 !llvm.module.flags = !{!16, !17} 26 !llvm.ident = !{!18} 27 28 !0 = distinct !DICompileUnit(language: DW_LANG_C99, file: !1, producer: "clang version 3.8.0 (trunk 251407) (llvm/trunk 251401)", isOptimized: true, runtimeVersion: 0, emissionKind: 1, enums: !2, subprograms: !3, globals: !13) 29 !1 = !DIFile(filename: "linkused2.c", directory: "/usr/local/google/home/tejohnson/llvm/tmp") 30 !2 = !{} 31 !3 = !{!4, !10} 32 !4 = distinct !DISubprogram(name: "foo", scope: !1, file: !1, line: 4, type: !5, isLocal: false, isDefinition: true, scopeLine: 4, flags: DIFlagPrototyped, isOptimized: true, variables: !8) 33 !5 = !DISubroutineType(types: !6) 34 !6 = !{!7, !7} 35 !7 = !DIBasicType(name: "int", size: 32, align: 32, encoding: DW_ATE_signed) 36 !8 = !{!9} 37 !9 = !DILocalVariable(name: "x", arg: 1, scope: !4, file: !1, line: 4, type: !7) 38 !10 = distinct !DISubprogram(name: "unused", scope: !1, file: !1, line: 8, type: !11, isLocal: false, isDefinition: true, scopeLine: 8, isOptimized: true, variables: !2) 39 !11 = !DISubroutineType(types: !12) 40 !12 = !{!7} 41 !13 = !{!14, !15} 42 !14 = !DIGlobalVariable(name: "X", scope: !0, file: !1, line: 1, type: !7, isLocal: false, isDefinition: true, variable: i32* @X) 43 !15 = !DIGlobalVariable(name: "U", scope: !0, file: !1, line: 2, type: !7, isLocal: false, isDefinition: true, variable: i32* @U) 44 !16 = !{i32 2, !"Dwarf Version", i32 4} 45 !17 = !{i32 2, !"Debug Info Version", i32 3} 46 !18 = !{!"clang version 3.8.0 (trunk 251407) (llvm/trunk 251401)"} 47 !19 = !DIExpression() 48 !20 = !DILocation(line: 4, column: 13, scope: !4) 49 !21 = !DILocation(line: 9, column: 3, scope: !10) 50