1e5a61917STeresa Johnson; Do setup work for all below tests: generate bitcode and combined index 2*68da426eSMehdi Amini; RUN: opt -module-summary %s -o %t.bc 3*68da426eSMehdi Amini; RUN: opt -module-summary %p/Inputs/thinlto_funcimport_debug.ll -o %t2.bc 4e5a61917STeresa Johnson; RUN: llvm-lto -thinlto -o %t3 %t.bc %t2.bc 5e5a61917STeresa Johnson 60e7c82cbSTeresa Johnson; If we import func1 and not func2 we should only link DISubprogram for func1 726ab5772STeresa Johnson; RUN: llvm-link %t2.bc -summary-index=%t3.thinlto.bc -import=func1:%t.bc -S | FileCheck %s 8e5a61917STeresa Johnson 9e5a61917STeresa Johnson; CHECK: declare i32 @func2 10e5a61917STeresa Johnson; CHECK: define available_externally i32 @func1 110e7c82cbSTeresa Johnson 120e7c82cbSTeresa Johnson; Extract out the list of subprograms from each compile unit and ensure 130e7c82cbSTeresa Johnson; that neither contains null. 140e7c82cbSTeresa Johnson; CHECK: !{{[0-9]+}} = distinct !DICompileUnit({{.*}} subprograms: ![[SPs1:[0-9]+]] 150e7c82cbSTeresa Johnson; CHECK-NOT: ![[SPs1]] = !{{{.*}}null{{.*}}} 160e7c82cbSTeresa Johnson; CHECK: !{{[0-9]+}} = distinct !DICompileUnit({{.*}} subprograms: ![[SPs2:[0-9]+]] 170e7c82cbSTeresa Johnson; CHECK-NOT: ![[SPs2]] = !{{{.*}}null{{.*}}} 180e7c82cbSTeresa Johnson 19e5a61917STeresa Johnson; CHECK: distinct !DISubprogram(name: "func1" 200e7c82cbSTeresa Johnson; CHECK-NOT: distinct !DISubprogram(name: "func2" 2171d12d2aSTeresa Johnson; CHECK: distinct !DISubprogram(name: "func3" 2271d12d2aSTeresa Johnson; CHECK: distinct !DISubprogram(name: "func4" 230e7c82cbSTeresa Johnson 24e5a61917STeresa Johnson 25e5a61917STeresa Johnson; ModuleID = 'dbg.o' 26e5a61917STeresa Johnsontarget datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128" 27e5a61917STeresa Johnsontarget triple = "x86_64-unknown-linux-gnu" 28e5a61917STeresa Johnson 29e5a61917STeresa Johnson; Function Attrs: nounwind readnone uwtable 30e5a61917STeresa Johnsondefine i32 @func1(i32 %n) #0 !dbg !4 { 31e5a61917STeresa Johnsonentry: 32e5a61917STeresa Johnson tail call void @llvm.dbg.value(metadata i32 %n, i64 0, metadata !9, metadata !17), !dbg !18 33e5a61917STeresa Johnson tail call void @llvm.dbg.value(metadata i32 5, i64 0, metadata !10, metadata !17), !dbg !19 34e5a61917STeresa Johnson %cmp = icmp sgt i32 %n, 10, !dbg !20 35e5a61917STeresa Johnson %. = select i1 %cmp, i32 10, i32 5, !dbg !22 36e5a61917STeresa Johnson tail call void @llvm.dbg.value(metadata i32 %., i64 0, metadata !10, metadata !17), !dbg !19 37e5a61917STeresa Johnson ret i32 %., !dbg !23 38e5a61917STeresa Johnson} 39e5a61917STeresa Johnson 40e5a61917STeresa Johnson; Function Attrs: nounwind readnone uwtable 41e5a61917STeresa Johnsondefine i32 @func2(i32 %n) #0 !dbg !11 { 42e5a61917STeresa Johnsonentry: 43e5a61917STeresa Johnson tail call void @llvm.dbg.value(metadata i32 %n, i64 0, metadata !13, metadata !17), !dbg !24 44e5a61917STeresa Johnson ret i32 %n, !dbg !25 45e5a61917STeresa Johnson} 46e5a61917STeresa Johnson 47e5a61917STeresa Johnson; Function Attrs: nounwind readnone 48e5a61917STeresa Johnsondeclare void @llvm.dbg.value(metadata, i64, metadata, metadata) #1 49e5a61917STeresa Johnson 50e5a61917STeresa Johnsonattributes #0 = { nounwind readnone uwtable "disable-tail-calls"="false" "less-precise-fpmad"="false" "no-frame-pointer-elim"="false" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+fxsr,+mmx,+sse,+sse2" "unsafe-fp-math"="false" "use-soft-float"="false" } 51e5a61917STeresa Johnsonattributes #1 = { nounwind readnone } 52e5a61917STeresa Johnson 53e5a61917STeresa Johnson!llvm.dbg.cu = !{!0} 54e5a61917STeresa Johnson!llvm.module.flags = !{!14, !15} 55e5a61917STeresa Johnson!llvm.ident = !{!16} 56e5a61917STeresa Johnson 57b8089516SAdrian Prantl!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: FullDebug, enums: !2, subprograms: !3) 58e5a61917STeresa Johnson!1 = !DIFile(filename: "dbg.c", directory: ".") 59e5a61917STeresa Johnson!2 = !{} 6071d12d2aSTeresa Johnson!3 = !{!4, !11, !27, !30} 61e5a61917STeresa Johnson!4 = distinct !DISubprogram(name: "func1", scope: !1, file: !1, line: 1, type: !5, isLocal: false, isDefinition: true, scopeLine: 1, flags: DIFlagPrototyped, isOptimized: true, variables: !8) 62e5a61917STeresa Johnson!5 = !DISubroutineType(types: !6) 63e5a61917STeresa Johnson!6 = !{!7, !7} 64e5a61917STeresa Johnson!7 = !DIBasicType(name: "int", size: 32, align: 32, encoding: DW_ATE_signed) 65e5a61917STeresa Johnson!8 = !{!9, !10} 66e5a61917STeresa Johnson!9 = !DILocalVariable(name: "n", arg: 1, scope: !4, file: !1, line: 1, type: !7) 67e5a61917STeresa Johnson!10 = !DILocalVariable(name: "x", scope: !4, file: !1, line: 2, type: !7) 68e5a61917STeresa Johnson!11 = distinct !DISubprogram(name: "func2", scope: !1, file: !1, line: 8, type: !5, isLocal: false, isDefinition: true, scopeLine: 8, flags: DIFlagPrototyped, isOptimized: true, variables: !12) 69e5a61917STeresa Johnson!12 = !{!13} 70e5a61917STeresa Johnson!13 = !DILocalVariable(name: "n", arg: 1, scope: !11, file: !1, line: 8, type: !7) 71e5a61917STeresa Johnson!14 = !{i32 2, !"Dwarf Version", i32 4} 72e5a61917STeresa Johnson!15 = !{i32 2, !"Debug Info Version", i32 3} 73e5a61917STeresa Johnson!16 = !{!"clang version 3.8.0 (trunk 251407) (llvm/trunk 251401)"} 74e5a61917STeresa Johnson!17 = !DIExpression() 75e5a61917STeresa Johnson!18 = !DILocation(line: 1, column: 15, scope: !4) 76e5a61917STeresa Johnson!19 = !DILocation(line: 2, column: 7, scope: !4) 7771d12d2aSTeresa Johnson!20 = !DILocation(line: 3, column: 9, scope: !21, inlinedAt: !26) 7871d12d2aSTeresa Johnson!21 = distinct !DILexicalBlock(scope: !27, file: !1, line: 3, column: 7) 79e5a61917STeresa Johnson!22 = !DILocation(line: 3, column: 7, scope: !4) 80e5a61917STeresa Johnson!23 = !DILocation(line: 5, column: 3, scope: !4) 81e5a61917STeresa Johnson!24 = !DILocation(line: 8, column: 15, scope: !11) 82e5a61917STeresa Johnson!25 = !DILocation(line: 9, column: 3, scope: !11) 8371d12d2aSTeresa Johnson!26 = !DILocation(line: 9, column: 3, scope: !4) 8471d12d2aSTeresa Johnson!27 = distinct !DISubprogram(name: "func3", scope: !1, file: !1, line: 8, type: !5, isLocal: false, isDefinition: true, scopeLine: 8, flags: DIFlagPrototyped, isOptimized: true, variables: !28) 8571d12d2aSTeresa Johnson!28 = !{!29} 8671d12d2aSTeresa Johnson!29 = !DILocalVariable(name: "n", arg: 1, scope: !30, file: !1, line: 8, type: !7) 8771d12d2aSTeresa Johnson!30 = distinct !DISubprogram(name: "func4", scope: !1, file: !1, line: 8, type: !5, isLocal: false, isDefinition: true, scopeLine: 8, flags: DIFlagPrototyped, isOptimized: true, variables: !31) 8871d12d2aSTeresa Johnson!31 = !{!32} 8971d12d2aSTeresa Johnson!32 = !DILocalVariable(name: "n", arg: 1, scope: !30, file: !1, line: 8, type: !7) 9071d12d2aSTeresa Johnson 91