Home | History | Annotate | Download | only in Linker
      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 source_filename = "test/Linker/only-needed-debug-metadata.ll"
     15 
     16 @X = global i32 5, !dbg !0
     17 @U = global i32 6, !dbg !6
     18 @U_linkonce = linkonce_odr hidden global i32 6
     19 
     20 define i32 @foo() !dbg !12 {
     21   ret i32 7, !dbg !17
     22 }
     23 
     24 define i32 @unused() !dbg !18 {
     25   ret i32 8, !dbg !21
     26 }
     27 
     28 !llvm.dbg.cu = !{!2}
     29 !llvm.module.flags = !{!9, !10}
     30 !llvm.ident = !{!11}
     31 
     32 !0 = !DIGlobalVariableExpression(var: !1, expr: !DIExpression())
     33 !1 = !DIGlobalVariable(name: "X", scope: !2, file: !3, line: 1, type: !8, isLocal: false, isDefinition: true)
     34 !2 = distinct !DICompileUnit(language: DW_LANG_C99, file: !3, producer: "clang version 3.8.0 (trunk 251407) (llvm/trunk 251401)", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, enums: !4, globals: !5)
     35 !3 = !DIFile(filename: "linkused2.c", directory: "/usr/local/google/home/tejohnson/llvm/tmp")
     36 !4 = !{}
     37 !5 = !{!0, !6}
     38 !6 = !DIGlobalVariableExpression(var: !7, expr: !DIExpression())
     39 !7 = !DIGlobalVariable(name: "U", scope: !2, file: !3, line: 2, type: !8, isLocal: false, isDefinition: true)
     40 !8 = !DIBasicType(name: "int", size: 32, align: 32, encoding: DW_ATE_signed)
     41 !9 = !{i32 2, !"Dwarf Version", i32 4}
     42 !10 = !{i32 2, !"Debug Info Version", i32 3}
     43 !11 = !{!"clang version 3.8.0 (trunk 251407) (llvm/trunk 251401)"}
     44 !12 = distinct !DISubprogram(name: "foo", scope: !3, file: !3, line: 4, type: !13, isLocal: false, isDefinition: true, scopeLine: 4, flags: DIFlagPrototyped, isOptimized: true, unit: !2, retainedNodes: !15)
     45 !13 = !DISubroutineType(types: !14)
     46 !14 = !{!8, !8}
     47 !15 = !{!16}
     48 !16 = !DILocalVariable(name: "x", arg: 1, scope: !12, file: !3, line: 4, type: !8)
     49 !17 = !DILocation(line: 4, column: 13, scope: !12)
     50 !18 = distinct !DISubprogram(name: "unused", scope: !3, file: !3, line: 8, type: !19, isLocal: false, isDefinition: true, scopeLine: 8, isOptimized: true, unit: !2, retainedNodes: !4)
     51 !19 = !DISubroutineType(types: !20)
     52 !20 = !{!8}
     53 !21 = !DILocation(line: 9, column: 3, scope: !18)
     54 
     55