Duncan P. N. Exon Smith | c947892d | 2015-03-26 18:35:30 +0000 | [diff] [blame] | 1 | ; RUN: llvm-link %s %S/Inputs/subprogram-linkonce-weak.ll -S -o %t1 |
| 2 | ; RUN: FileCheck %s -check-prefix=LW -check-prefix=CHECK <%t1 |
| 3 | ; RUN: llvm-link %S/Inputs/subprogram-linkonce-weak.ll %s -S -o %t2 |
| 4 | ; RUN: FileCheck %s -check-prefix=WL -check-prefix=CHECK <%t2 |
Mehdi Amini | d178f4f | 2015-09-16 05:34:32 +0000 | [diff] [blame] | 5 | ; REQUIRES: default_triple |
Duncan P. N. Exon Smith | c947892d | 2015-03-26 18:35:30 +0000 | [diff] [blame] | 6 | |
| 7 | ; This testcase tests the following flow: |
| 8 | ; - File A defines a linkonce version of @foo which has inlined into @bar. |
| 9 | ; - File B defines a weak version of @foo (different definition). |
| 10 | ; - Linkage rules state File B version of @foo wins. |
| 11 | ; - @bar still has inlined debug info related to the linkonce @foo. |
| 12 | ; |
| 13 | ; This should fix PR22792, although the testcase was hand-written. There's a |
| 14 | ; RUN line with a crasher for llc at the end with checks for the DWARF output. |
| 15 | |
| 16 | ; The LW prefix means linkonce (this file) first, then weak (the other file). |
| 17 | ; The WL prefix means weak (the other file) first, then linkonce (this file). |
| 18 | |
| 19 | ; We'll see @bar before @foo if this file is first. |
Peter Collingbourne | d4bff30 | 2015-11-05 22:03:56 +0000 | [diff] [blame] | 20 | ; LW: define i32 @bar({{.*}} !dbg ![[BARSP:[0-9]+]] |
Duncan P. N. Exon Smith | c947892d | 2015-03-26 18:35:30 +0000 | [diff] [blame] | 21 | ; LW: %sum = add i32 %a, %b, !dbg ![[FOOINBAR:[0-9]+]] |
| 22 | ; LW: ret i32 %sum, !dbg ![[BARRET:[0-9]+]] |
Peter Collingbourne | d4bff30 | 2015-11-05 22:03:56 +0000 | [diff] [blame] | 23 | ; LW: define weak i32 @foo({{.*}} !dbg ![[WEAKFOOSP:[0-9]+]] |
Duncan P. N. Exon Smith | c947892d | 2015-03-26 18:35:30 +0000 | [diff] [blame] | 24 | ; LW: %sum = call i32 @fastadd(i32 %a, i32 %b), !dbg ![[FOOCALL:[0-9]+]] |
| 25 | ; LW: ret i32 %sum, !dbg ![[FOORET:[0-9]+]] |
| 26 | |
| 27 | ; We'll see @foo before @bar if this file is second. |
Peter Collingbourne | d4bff30 | 2015-11-05 22:03:56 +0000 | [diff] [blame] | 28 | ; WL: define weak i32 @foo({{.*}} !dbg ![[WEAKFOOSP:[0-9]+]] |
Duncan P. N. Exon Smith | c947892d | 2015-03-26 18:35:30 +0000 | [diff] [blame] | 29 | ; WL: %sum = call i32 @fastadd(i32 %a, i32 %b), !dbg ![[FOOCALL:[0-9]+]] |
| 30 | ; WL: ret i32 %sum, !dbg ![[FOORET:[0-9]+]] |
Peter Collingbourne | d4bff30 | 2015-11-05 22:03:56 +0000 | [diff] [blame] | 31 | ; WL: define i32 @bar({{.*}} !dbg ![[BARSP:[0-9]+]] |
Duncan P. N. Exon Smith | c947892d | 2015-03-26 18:35:30 +0000 | [diff] [blame] | 32 | ; WL: %sum = add i32 %a, %b, !dbg ![[FOOINBAR:[0-9]+]] |
| 33 | ; WL: ret i32 %sum, !dbg ![[BARRET:[0-9]+]] |
| 34 | |
Peter Collingbourne | d4bff30 | 2015-11-05 22:03:56 +0000 | [diff] [blame] | 35 | define i32 @bar(i32 %a, i32 %b) !dbg !3 { |
Duncan P. N. Exon Smith | c947892d | 2015-03-26 18:35:30 +0000 | [diff] [blame] | 36 | entry: |
Duncan P. N. Exon Smith | a9308c4 | 2015-04-29 16:38:44 +0000 | [diff] [blame] | 37 | %sum = add i32 %a, %b, !dbg !DILocation(line: 2, scope: !4, |
| 38 | inlinedAt: !DILocation(line: 12, scope: !3)) |
| 39 | ret i32 %sum, !dbg !DILocation(line: 13, scope: !3) |
Duncan P. N. Exon Smith | c947892d | 2015-03-26 18:35:30 +0000 | [diff] [blame] | 40 | } |
| 41 | |
Peter Collingbourne | d4bff30 | 2015-11-05 22:03:56 +0000 | [diff] [blame] | 42 | define linkonce i32 @foo(i32 %a, i32 %b) !dbg !4 { |
Duncan P. N. Exon Smith | c947892d | 2015-03-26 18:35:30 +0000 | [diff] [blame] | 43 | entry: |
Duncan P. N. Exon Smith | a9308c4 | 2015-04-29 16:38:44 +0000 | [diff] [blame] | 44 | %sum = add i32 %a, %b, !dbg !DILocation(line: 2, scope: !4) |
| 45 | ret i32 %sum, !dbg !DILocation(line: 3, scope: !4) |
Duncan P. N. Exon Smith | c947892d | 2015-03-26 18:35:30 +0000 | [diff] [blame] | 46 | } |
| 47 | |
| 48 | !llvm.module.flags = !{!0} |
| 49 | !0 = !{i32 2, !"Debug Info Version", i32 3} |
| 50 | |
| 51 | ; CHECK-LABEL: !llvm.dbg.cu = |
| 52 | ; LW-SAME: !{![[LCU:[0-9]+]], ![[WCU:[0-9]+]]} |
| 53 | ; WL-SAME: !{![[WCU:[0-9]+]], ![[LCU:[0-9]+]]} |
| 54 | !llvm.dbg.cu = !{!1} |
| 55 | |
Adrian Prantl | 75819ae | 2016-04-15 15:57:41 +0000 | [diff] [blame] | 56 | ; LW: ![[LCU]] = distinct !DICompileUnit( |
| 57 | ; LW: ![[WCU]] = distinct !DICompileUnit( |
| 58 | ; LW: ![[BARSP]] = distinct !DISubprogram(name: "bar",{{.*}} unit: ![[LCU]] |
| 59 | ; LW: ![[FOOINBAR]] = !DILocation(line: 2, scope: ![[FOOSP:.*]], inlinedAt: ![[BARIA:[0-9]+]]) |
| 60 | ; LW: ![[FOOSP]] = distinct !DISubprogram(name: "foo",{{.*}} unit: ![[LCU]] |
Duncan P. N. Exon Smith | a9308c4 | 2015-04-29 16:38:44 +0000 | [diff] [blame] | 61 | ; LW: ![[BARIA]] = !DILocation(line: 12, scope: ![[BARSP]]) |
| 62 | ; LW: ![[BARRET]] = !DILocation(line: 13, scope: ![[BARSP]]) |
Adrian Prantl | 75819ae | 2016-04-15 15:57:41 +0000 | [diff] [blame] | 63 | ; LW: ![[WEAKFOOSP]] = distinct !DISubprogram(name: "foo",{{.*}} unit: ![[WCU]] |
Duncan P. N. Exon Smith | a9308c4 | 2015-04-29 16:38:44 +0000 | [diff] [blame] | 64 | ; LW: ![[FOOCALL]] = !DILocation(line: 52, scope: ![[WEAKFOOSP]]) |
| 65 | ; LW: ![[FOORET]] = !DILocation(line: 53, scope: ![[WEAKFOOSP]]) |
Duncan P. N. Exon Smith | c947892d | 2015-03-26 18:35:30 +0000 | [diff] [blame] | 66 | |
| 67 | ; Same as above, but reordered. |
Adrian Prantl | 75819ae | 2016-04-15 15:57:41 +0000 | [diff] [blame] | 68 | ; WL: ![[WCU]] = distinct !DICompileUnit( |
| 69 | ; WL: ![[LCU]] = distinct !DICompileUnit( |
| 70 | ; WL: ![[WEAKFOOSP]] = distinct !DISubprogram(name: "foo",{{.*}} unit: ![[WCU]] |
Duncan P. N. Exon Smith | a9308c4 | 2015-04-29 16:38:44 +0000 | [diff] [blame] | 71 | ; WL: ![[FOOCALL]] = !DILocation(line: 52, scope: ![[WEAKFOOSP]]) |
| 72 | ; WL: ![[FOORET]] = !DILocation(line: 53, scope: ![[WEAKFOOSP]]) |
Adrian Prantl | 75819ae | 2016-04-15 15:57:41 +0000 | [diff] [blame] | 73 | ; WL: ![[BARSP]] = distinct !DISubprogram(name: "bar",{{.*}} unit: ![[LCU]] |
| 74 | ; WL: ![[FOOINBAR]] = !DILocation(line: 2, scope: ![[FOOSP:.*]], inlinedAt: ![[BARIA:[0-9]+]]) |
| 75 | ; WL: ![[FOOSP]] = distinct !DISubprogram(name: "foo",{{.*}} unit: ![[LCU]] |
Duncan P. N. Exon Smith | a9308c4 | 2015-04-29 16:38:44 +0000 | [diff] [blame] | 76 | ; WL: ![[BARIA]] = !DILocation(line: 12, scope: ![[BARSP]]) |
| 77 | ; WL: ![[BARRET]] = !DILocation(line: 13, scope: ![[BARSP]]) |
Duncan P. N. Exon Smith | c947892d | 2015-03-26 18:35:30 +0000 | [diff] [blame] | 78 | |
Adrian Prantl | 75819ae | 2016-04-15 15:57:41 +0000 | [diff] [blame] | 79 | !1 = distinct !DICompileUnit(language: DW_LANG_C99, file: !2, emissionKind: FullDebug) |
Duncan P. N. Exon Smith | a9308c4 | 2015-04-29 16:38:44 +0000 | [diff] [blame] | 80 | !2 = !DIFile(filename: "bar.c", directory: "/path/to/dir") |
Adrian Prantl | 75819ae | 2016-04-15 15:57:41 +0000 | [diff] [blame] | 81 | !3 = distinct !DISubprogram(file: !2, scope: !2, line: 11, name: "bar", type: !5, unit: !1) |
| 82 | !4 = distinct !DISubprogram(file: !2, scope: !2, line: 1, name: "foo", type: !5, unit: !1) |
Duncan P. N. Exon Smith | a9308c4 | 2015-04-29 16:38:44 +0000 | [diff] [blame] | 83 | !5 = !DISubroutineType(types: !{}) |
Duncan P. N. Exon Smith | c947892d | 2015-03-26 18:35:30 +0000 | [diff] [blame] | 84 | |
| 85 | ; Crasher for llc. |
| 86 | ; REQUIRES: object-emission |
| 87 | ; RUN: %llc_dwarf -filetype=obj -O0 %t1 -o %t1.o |
| 88 | ; RUN: llvm-dwarfdump %t1.o -debug-dump=all | FileCheck %s -check-prefix=DWLW -check-prefix=DW |
| 89 | ; RUN: %llc_dwarf -filetype=obj -O0 %t2 -o %t2.o |
| 90 | ; RUN: llvm-dwarfdump %t2.o -debug-dump=all | FileCheck %s -check-prefix=DWWL -check-prefix=DW |
| 91 | ; Check that the debug info for the discarded linkonce version of @foo doesn't |
| 92 | ; reference any code, and that the other subprograms look correct. |
| 93 | |
| 94 | ; DW-LABEL: .debug_info contents: |
| 95 | ; DWLW: DW_TAG_compile_unit |
| 96 | ; DWLW: DW_AT_name {{.*}}"bar.c" |
| 97 | ; DWLW: DW_TAG_subprogram |
| 98 | ; DWLW-NOT: DW_AT_low_pc |
| 99 | ; DWLW-NOT: DW_AT_high_pc |
| 100 | ; DWLW: DW_AT_name {{.*}}foo |
Yaron Keren | 39972f7 | 2015-03-27 13:52:12 +0000 | [diff] [blame] | 101 | ; DWLW: DW_AT_decl_file {{.*}}"/path/to/dir{{/|\\}}bar.c" |
Duncan P. N. Exon Smith | c947892d | 2015-03-26 18:35:30 +0000 | [diff] [blame] | 102 | ; DWLW: DW_AT_decl_line {{.*}}(1) |
| 103 | ; DWLW: DW_TAG_subprogram |
| 104 | ; DWLW: DW_AT_low_pc |
| 105 | ; DWLW: DW_AT_high_pc |
| 106 | ; DWLW: DW_AT_name {{.*}}bar |
Yaron Keren | 39972f7 | 2015-03-27 13:52:12 +0000 | [diff] [blame] | 107 | ; DWLW: DW_AT_decl_file {{.*}}"/path/to/dir{{/|\\}}bar.c" |
Duncan P. N. Exon Smith | c947892d | 2015-03-26 18:35:30 +0000 | [diff] [blame] | 108 | ; DWLW: DW_AT_decl_line {{.*}}(11) |
| 109 | |
| 110 | ; DWLW: DW_TAG_inlined_subroutine |
| 111 | ; DWLW: DW_AT_abstract_origin |
| 112 | ; DWLW: DW_TAG_compile_unit |
| 113 | ; DWLW: DW_AT_name {{.*}}"foo.c" |
| 114 | ; DWLW: DW_TAG_subprogram |
| 115 | ; DWLW: DW_AT_low_pc |
| 116 | ; DWLW: DW_AT_high_pc |
| 117 | ; DWLW: DW_AT_name {{.*}}foo |
Yaron Keren | 39972f7 | 2015-03-27 13:52:12 +0000 | [diff] [blame] | 118 | ; DWLW: DW_AT_decl_file {{.*}}"/path/to/dir{{/|\\}}foo.c" |
Duncan P. N. Exon Smith | c947892d | 2015-03-26 18:35:30 +0000 | [diff] [blame] | 119 | ; DWLW: DW_AT_decl_line {{.*}}(51) |
| 120 | |
| 121 | ; The DWARF output is already symmetric (just reordered). |
| 122 | ; DWWL: DW_TAG_compile_unit |
| 123 | ; DWWL: DW_AT_name {{.*}}"foo.c" |
| 124 | ; DWWL: DW_TAG_subprogram |
| 125 | ; DWWL: DW_AT_low_pc |
| 126 | ; DWWL: DW_AT_high_pc |
| 127 | ; DWWL: DW_AT_name {{.*}}foo |
Yaron Keren | 39972f7 | 2015-03-27 13:52:12 +0000 | [diff] [blame] | 128 | ; DWWL: DW_AT_decl_file {{.*}}"/path/to/dir{{/|\\}}foo.c" |
Duncan P. N. Exon Smith | c947892d | 2015-03-26 18:35:30 +0000 | [diff] [blame] | 129 | ; DWWL: DW_AT_decl_line {{.*}}(51) |
| 130 | ; DWWL: DW_TAG_compile_unit |
| 131 | ; DWWL: DW_AT_name {{.*}}"bar.c" |
| 132 | ; DWWL: DW_TAG_subprogram |
| 133 | ; DWWL-NOT: DW_AT_low_pc |
| 134 | ; DWWL-NOT: DW_AT_high_pc |
| 135 | ; DWWL: DW_AT_name {{.*}}foo |
Yaron Keren | 39972f7 | 2015-03-27 13:52:12 +0000 | [diff] [blame] | 136 | ; DWWL: DW_AT_decl_file {{.*}}"/path/to/dir{{/|\\}}bar.c" |
Duncan P. N. Exon Smith | c947892d | 2015-03-26 18:35:30 +0000 | [diff] [blame] | 137 | ; DWWL: DW_AT_decl_line {{.*}}(1) |
| 138 | ; DWWL: DW_TAG_subprogram |
| 139 | ; DWWL: DW_AT_low_pc |
| 140 | ; DWWL: DW_AT_high_pc |
| 141 | ; DWWL: DW_AT_name {{.*}}bar |
Yaron Keren | 39972f7 | 2015-03-27 13:52:12 +0000 | [diff] [blame] | 142 | ; DWWL: DW_AT_decl_file {{.*}}"/path/to/dir{{/|\\}}bar.c" |
Duncan P. N. Exon Smith | c947892d | 2015-03-26 18:35:30 +0000 | [diff] [blame] | 143 | ; DWWL: DW_AT_decl_line {{.*}}(11) |
| 144 | ; DWWL: DW_TAG_inlined_subroutine |
| 145 | ; DWWL: DW_AT_abstract_origin |
| 146 | |
| 147 | ; DW-LABEL: .debug_line contents: |
| 148 | ; Check that we have the right things in the line table as well. |
| 149 | |
| 150 | ; DWLW-LABEL: file_names[{{ *}}1]{{.*}} bar.c |
| 151 | ; DWLW: 2 0 1 0 0 is_stmt prologue_end |
| 152 | ; DWLW-LABEL: file_names[{{ *}}1]{{.*}} foo.c |
| 153 | ; DWLW: 52 0 1 0 0 is_stmt prologue_end |
| 154 | ; DWLW-NOT: prologue_end |
| 155 | |
| 156 | ; DWWL-LABEL: file_names[{{ *}}1]{{.*}} foo.c |
| 157 | ; DWWL: 52 0 1 0 0 is_stmt prologue_end |
| 158 | ; DWWL-LABEL: file_names[{{ *}}1]{{.*}} bar.c |
| 159 | ; DWWL: 2 0 1 0 0 is_stmt prologue_end |
| 160 | ; DWWL-NOT: prologue_end |