blob: 034f461dd5bb2fa9a84a7f123d830253c155d13f [file] [log] [blame]
Teresa Johnsone5a61912015-12-17 17:14:09 +00001; Do setup work for all below tests: generate bitcode and combined index
Mehdi Amini68da4262016-04-12 21:35:18 +00002; RUN: opt -module-summary %s -o %t.bc
3; RUN: opt -module-summary %p/Inputs/thinlto_funcimport_debug.ll -o %t2.bc
Teresa Johnsone5a61912015-12-17 17:14:09 +00004; RUN: llvm-lto -thinlto -o %t3 %t.bc %t2.bc
5
Teresa Johnson0e7c82c2015-12-18 17:51:37 +00006; If we import func1 and not func2 we should only link DISubprogram for func1
Teresa Johnson26ab5772016-03-15 00:04:37 +00007; RUN: llvm-link %t2.bc -summary-index=%t3.thinlto.bc -import=func1:%t.bc -S | FileCheck %s
Teresa Johnsone5a61912015-12-17 17:14:09 +00008
9; CHECK: declare i32 @func2
10; CHECK: define available_externally i32 @func1
Teresa Johnson0e7c82c2015-12-18 17:51:37 +000011
12; Extract out the list of subprograms from each compile unit and ensure
13; that neither contains null.
14; CHECK: !{{[0-9]+}} = distinct !DICompileUnit({{.*}} subprograms: ![[SPs1:[0-9]+]]
15; CHECK-NOT: ![[SPs1]] = !{{{.*}}null{{.*}}}
16; CHECK: !{{[0-9]+}} = distinct !DICompileUnit({{.*}} subprograms: ![[SPs2:[0-9]+]]
17; CHECK-NOT: ![[SPs2]] = !{{{.*}}null{{.*}}}
18
Teresa Johnsone5a61912015-12-17 17:14:09 +000019; CHECK: distinct !DISubprogram(name: "func1"
Teresa Johnson0e7c82c2015-12-18 17:51:37 +000020; CHECK-NOT: distinct !DISubprogram(name: "func2"
Teresa Johnson71d12d22016-01-25 22:04:56 +000021; CHECK: distinct !DISubprogram(name: "func3"
22; CHECK: distinct !DISubprogram(name: "func4"
Teresa Johnson0e7c82c2015-12-18 17:51:37 +000023
Teresa Johnsone5a61912015-12-17 17:14:09 +000024
25; ModuleID = 'dbg.o'
26target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
27target triple = "x86_64-unknown-linux-gnu"
28
29; Function Attrs: nounwind readnone uwtable
30define i32 @func1(i32 %n) #0 !dbg !4 {
31entry:
32 tail call void @llvm.dbg.value(metadata i32 %n, i64 0, metadata !9, metadata !17), !dbg !18
33 tail call void @llvm.dbg.value(metadata i32 5, i64 0, metadata !10, metadata !17), !dbg !19
34 %cmp = icmp sgt i32 %n, 10, !dbg !20
35 %. = select i1 %cmp, i32 10, i32 5, !dbg !22
36 tail call void @llvm.dbg.value(metadata i32 %., i64 0, metadata !10, metadata !17), !dbg !19
37 ret i32 %., !dbg !23
38}
39
40; Function Attrs: nounwind readnone uwtable
41define i32 @func2(i32 %n) #0 !dbg !11 {
42entry:
43 tail call void @llvm.dbg.value(metadata i32 %n, i64 0, metadata !13, metadata !17), !dbg !24
44 ret i32 %n, !dbg !25
45}
46
47; Function Attrs: nounwind readnone
48declare void @llvm.dbg.value(metadata, i64, metadata, metadata) #1
49
50attributes #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" }
51attributes #1 = { nounwind readnone }
52
53!llvm.dbg.cu = !{!0}
54!llvm.module.flags = !{!14, !15}
55!llvm.ident = !{!16}
56
Adrian Prantlb8089512016-04-01 00:16:49 +000057!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)
Teresa Johnsone5a61912015-12-17 17:14:09 +000058!1 = !DIFile(filename: "dbg.c", directory: ".")
59!2 = !{}
Teresa Johnson71d12d22016-01-25 22:04:56 +000060!3 = !{!4, !11, !27, !30}
Teresa Johnsone5a61912015-12-17 17:14:09 +000061!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)
62!5 = !DISubroutineType(types: !6)
63!6 = !{!7, !7}
64!7 = !DIBasicType(name: "int", size: 32, align: 32, encoding: DW_ATE_signed)
65!8 = !{!9, !10}
66!9 = !DILocalVariable(name: "n", arg: 1, scope: !4, file: !1, line: 1, type: !7)
67!10 = !DILocalVariable(name: "x", scope: !4, file: !1, line: 2, type: !7)
68!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)
69!12 = !{!13}
70!13 = !DILocalVariable(name: "n", arg: 1, scope: !11, file: !1, line: 8, type: !7)
71!14 = !{i32 2, !"Dwarf Version", i32 4}
72!15 = !{i32 2, !"Debug Info Version", i32 3}
73!16 = !{!"clang version 3.8.0 (trunk 251407) (llvm/trunk 251401)"}
74!17 = !DIExpression()
75!18 = !DILocation(line: 1, column: 15, scope: !4)
76!19 = !DILocation(line: 2, column: 7, scope: !4)
Teresa Johnson71d12d22016-01-25 22:04:56 +000077!20 = !DILocation(line: 3, column: 9, scope: !21, inlinedAt: !26)
78!21 = distinct !DILexicalBlock(scope: !27, file: !1, line: 3, column: 7)
Teresa Johnsone5a61912015-12-17 17:14:09 +000079!22 = !DILocation(line: 3, column: 7, scope: !4)
80!23 = !DILocation(line: 5, column: 3, scope: !4)
81!24 = !DILocation(line: 8, column: 15, scope: !11)
82!25 = !DILocation(line: 9, column: 3, scope: !11)
Teresa Johnson71d12d22016-01-25 22:04:56 +000083!26 = !DILocation(line: 9, column: 3, scope: !4)
84!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)
85!28 = !{!29}
86!29 = !DILocalVariable(name: "n", arg: 1, scope: !30, file: !1, line: 8, type: !7)
87!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)
88!31 = !{!32}
89!32 = !DILocalVariable(name: "n", arg: 1, scope: !30, file: !1, line: 8, type: !7)
90