Teresa Johnson | e5a6191 | 2015-12-17 17:14:09 +0000 | [diff] [blame] | 1 | ; Do setup work for all below tests: generate bitcode and combined index |
Mehdi Amini | 68da426 | 2016-04-12 21:35:18 +0000 | [diff] [blame] | 2 | ; RUN: opt -module-summary %s -o %t.bc |
| 3 | ; RUN: opt -module-summary %p/Inputs/thinlto_funcimport_debug.ll -o %t2.bc |
Teresa Johnson | e5a6191 | 2015-12-17 17:14:09 +0000 | [diff] [blame] | 4 | ; RUN: llvm-lto -thinlto -o %t3 %t.bc %t2.bc |
| 5 | |
Teresa Johnson | 0e7c82c | 2015-12-18 17:51:37 +0000 | [diff] [blame] | 6 | ; If we import func1 and not func2 we should only link DISubprogram for func1 |
Teresa Johnson | 26ab577 | 2016-03-15 00:04:37 +0000 | [diff] [blame] | 7 | ; RUN: llvm-link %t2.bc -summary-index=%t3.thinlto.bc -import=func1:%t.bc -S | FileCheck %s |
Teresa Johnson | e5a6191 | 2015-12-17 17:14:09 +0000 | [diff] [blame] | 8 | |
| 9 | ; CHECK: declare i32 @func2 |
| 10 | ; CHECK: define available_externally i32 @func1 |
Teresa Johnson | 0e7c82c | 2015-12-18 17:51:37 +0000 | [diff] [blame] | 11 | |
Adrian Prantl | 75819ae | 2016-04-15 15:57:41 +0000 | [diff] [blame] | 12 | ; Ensure that each subprogram points to the correct CU. |
| 13 | ; CHECK: ![[CU1:[0-9]+]] = distinct !DICompileUnit( |
| 14 | ; CHECK: ![[CU2:[0-9]+]] = distinct !DICompileUnit( |
Teresa Johnson | 0e7c82c | 2015-12-18 17:51:37 +0000 | [diff] [blame] | 15 | |
Adrian Prantl | 75819ae | 2016-04-15 15:57:41 +0000 | [diff] [blame] | 16 | ; CHECK: distinct !DISubprogram(name: "main", {{.*}}, unit: ![[CU1]] |
| 17 | ; CHECK: distinct !DISubprogram(name: "func1", {{.*}}, unit: ![[CU2]] |
Teresa Johnson | 0e7c82c | 2015-12-18 17:51:37 +0000 | [diff] [blame] | 18 | ; CHECK-NOT: distinct !DISubprogram(name: "func2" |
Adrian Prantl | 75819ae | 2016-04-15 15:57:41 +0000 | [diff] [blame] | 19 | ; CHECK: distinct !DISubprogram(name: "func3", {{.*}}, unit: ![[CU2]] |
| 20 | ; CHECK: distinct !DISubprogram(name: "func4", {{.*}}, unit: ![[CU2]] |
Teresa Johnson | 0e7c82c | 2015-12-18 17:51:37 +0000 | [diff] [blame] | 21 | |
Teresa Johnson | e5a6191 | 2015-12-17 17:14:09 +0000 | [diff] [blame] | 22 | |
| 23 | ; ModuleID = 'dbg.o' |
| 24 | target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128" |
| 25 | target triple = "x86_64-unknown-linux-gnu" |
| 26 | |
| 27 | ; Function Attrs: nounwind readnone uwtable |
| 28 | define i32 @func1(i32 %n) #0 !dbg !4 { |
| 29 | entry: |
| 30 | tail call void @llvm.dbg.value(metadata i32 %n, i64 0, metadata !9, metadata !17), !dbg !18 |
| 31 | tail call void @llvm.dbg.value(metadata i32 5, i64 0, metadata !10, metadata !17), !dbg !19 |
| 32 | %cmp = icmp sgt i32 %n, 10, !dbg !20 |
| 33 | %. = select i1 %cmp, i32 10, i32 5, !dbg !22 |
| 34 | tail call void @llvm.dbg.value(metadata i32 %., i64 0, metadata !10, metadata !17), !dbg !19 |
| 35 | ret i32 %., !dbg !23 |
| 36 | } |
| 37 | |
| 38 | ; Function Attrs: nounwind readnone uwtable |
| 39 | define i32 @func2(i32 %n) #0 !dbg !11 { |
| 40 | entry: |
| 41 | tail call void @llvm.dbg.value(metadata i32 %n, i64 0, metadata !13, metadata !17), !dbg !24 |
| 42 | ret i32 %n, !dbg !25 |
| 43 | } |
| 44 | |
| 45 | ; Function Attrs: nounwind readnone |
| 46 | declare void @llvm.dbg.value(metadata, i64, metadata, metadata) #1 |
| 47 | |
| 48 | attributes #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" } |
| 49 | attributes #1 = { nounwind readnone } |
| 50 | |
| 51 | !llvm.dbg.cu = !{!0} |
| 52 | !llvm.module.flags = !{!14, !15} |
| 53 | !llvm.ident = !{!16} |
| 54 | |
Adrian Prantl | 75819ae | 2016-04-15 15:57:41 +0000 | [diff] [blame] | 55 | !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) |
Teresa Johnson | e5a6191 | 2015-12-17 17:14:09 +0000 | [diff] [blame] | 56 | !1 = !DIFile(filename: "dbg.c", directory: ".") |
| 57 | !2 = !{} |
Shiva Chen | 2c86455 | 2018-05-09 02:40:45 +0000 | [diff] [blame] | 58 | !4 = distinct !DISubprogram(name: "func1", scope: !1, file: !1, line: 1, type: !5, isLocal: false, isDefinition: true, scopeLine: 1, flags: DIFlagPrototyped, isOptimized: true, unit: !0, retainedNodes: !8) |
Teresa Johnson | e5a6191 | 2015-12-17 17:14:09 +0000 | [diff] [blame] | 59 | !5 = !DISubroutineType(types: !6) |
| 60 | !6 = !{!7, !7} |
| 61 | !7 = !DIBasicType(name: "int", size: 32, align: 32, encoding: DW_ATE_signed) |
| 62 | !8 = !{!9, !10} |
| 63 | !9 = !DILocalVariable(name: "n", arg: 1, scope: !4, file: !1, line: 1, type: !7) |
| 64 | !10 = !DILocalVariable(name: "x", scope: !4, file: !1, line: 2, type: !7) |
Shiva Chen | 2c86455 | 2018-05-09 02:40:45 +0000 | [diff] [blame] | 65 | !11 = distinct !DISubprogram(name: "func2", scope: !1, file: !1, line: 8, type: !5, isLocal: false, isDefinition: true, scopeLine: 8, flags: DIFlagPrototyped, isOptimized: true, unit: !0, retainedNodes: !12) |
Teresa Johnson | e5a6191 | 2015-12-17 17:14:09 +0000 | [diff] [blame] | 66 | !12 = !{!13} |
| 67 | !13 = !DILocalVariable(name: "n", arg: 1, scope: !11, file: !1, line: 8, type: !7) |
| 68 | !14 = !{i32 2, !"Dwarf Version", i32 4} |
| 69 | !15 = !{i32 2, !"Debug Info Version", i32 3} |
| 70 | !16 = !{!"clang version 3.8.0 (trunk 251407) (llvm/trunk 251401)"} |
| 71 | !17 = !DIExpression() |
| 72 | !18 = !DILocation(line: 1, column: 15, scope: !4) |
| 73 | !19 = !DILocation(line: 2, column: 7, scope: !4) |
Teresa Johnson | 71d12d2 | 2016-01-25 22:04:56 +0000 | [diff] [blame] | 74 | !20 = !DILocation(line: 3, column: 9, scope: !21, inlinedAt: !26) |
| 75 | !21 = distinct !DILexicalBlock(scope: !27, file: !1, line: 3, column: 7) |
Teresa Johnson | e5a6191 | 2015-12-17 17:14:09 +0000 | [diff] [blame] | 76 | !22 = !DILocation(line: 3, column: 7, scope: !4) |
| 77 | !23 = !DILocation(line: 5, column: 3, scope: !4) |
| 78 | !24 = !DILocation(line: 8, column: 15, scope: !11) |
| 79 | !25 = !DILocation(line: 9, column: 3, scope: !11) |
Teresa Johnson | 71d12d2 | 2016-01-25 22:04:56 +0000 | [diff] [blame] | 80 | !26 = !DILocation(line: 9, column: 3, scope: !4) |
Shiva Chen | 2c86455 | 2018-05-09 02:40:45 +0000 | [diff] [blame] | 81 | !27 = distinct !DISubprogram(name: "func3", scope: !1, file: !1, line: 8, type: !5, isLocal: false, isDefinition: true, scopeLine: 8, flags: DIFlagPrototyped, isOptimized: true, unit: !0, retainedNodes: !28) |
Teresa Johnson | 71d12d2 | 2016-01-25 22:04:56 +0000 | [diff] [blame] | 82 | !28 = !{!29} |
| 83 | !29 = !DILocalVariable(name: "n", arg: 1, scope: !30, file: !1, line: 8, type: !7) |
Shiva Chen | 2c86455 | 2018-05-09 02:40:45 +0000 | [diff] [blame] | 84 | !30 = distinct !DISubprogram(name: "func4", scope: !1, file: !1, line: 8, type: !5, isLocal: false, isDefinition: true, scopeLine: 8, flags: DIFlagPrototyped, isOptimized: true, unit: !0, retainedNodes: !31) |
Teresa Johnson | 71d12d2 | 2016-01-25 22:04:56 +0000 | [diff] [blame] | 85 | !31 = !{!32} |
| 86 | !32 = !DILocalVariable(name: "n", arg: 1, scope: !30, file: !1, line: 8, type: !7) |
| 87 | |