Adrian Prantl | 16aa4cf | 2017-09-11 23:05:20 +0000 | [diff] [blame] | 1 | ; RUN: %llc_dwarf -O0 -filetype=obj -dwarf-linkage-names=All < %s | llvm-dwarfdump -v -debug-info - | FileCheck -implicit-check-not=DW_TAG %s |
Pavel Labath | 6088c23 | 2018-04-04 14:42:14 +0000 | [diff] [blame] | 2 | ; RUN: %llc_dwarf -accel-tables=Apple -dwarf-linkage-names=All -O0 -filetype=obj < %s | llvm-dwarfdump -v - | FileCheck --check-prefix=CHECK-ACCEL --check-prefix=CHECK %s |
David Blaikie | 1ea9db2 | 2014-05-21 23:14:12 +0000 | [diff] [blame] | 3 | |
| 4 | ; Build from source: |
| 5 | ; $ clang++ a.cpp b.cpp -g -c -emit-llvm |
| 6 | ; $ llvm-link a.bc b.bc -o ab.bc |
| 7 | ; $ opt -inline ab.bc -o ab-opt.bc |
| 8 | ; $ cat a.cpp |
| 9 | ; extern int i; |
| 10 | ; int func(int); |
| 11 | ; int main() { |
| 12 | ; return func(i); |
| 13 | ; } |
| 14 | ; $ cat b.cpp |
| 15 | ; int __attribute__((always_inline)) func(int x) { |
| 16 | ; return x * 2; |
| 17 | ; } |
| 18 | |
| 19 | ; Ensure that func inlined into main is described and references the abstract |
| 20 | ; definition in b.cpp's CU. |
| 21 | |
| 22 | ; CHECK: DW_TAG_compile_unit |
| 23 | ; CHECK: DW_AT_name {{.*}} "a.cpp" |
| 24 | ; CHECK: DW_TAG_subprogram |
Jonas Devlieghere | aa6be82 | 2017-10-10 14:15:25 +0000 | [diff] [blame] | 25 | ; CHECK: DW_AT_type [DW_FORM_ref_addr] (0x00000000[[INT:[a-f0-9]+]] |
Frederic Riss | 3a6b354 | 2014-11-12 23:48:14 +0000 | [diff] [blame] | 26 | ; CHECK: 0x[[INLINED:[0-9a-f]*]]:{{.*}}DW_TAG_inlined_subroutine |
Frederic Riss | d1cfc3c | 2014-10-06 03:36:31 +0000 | [diff] [blame] | 27 | ; CHECK: DW_AT_abstract_origin {{.*}}[[ABS_FUNC:........]] "_Z4funci" |
David Blaikie | 1ea9db2 | 2014-05-21 23:14:12 +0000 | [diff] [blame] | 28 | ; CHECK: DW_TAG_formal_parameter |
Frederic Riss | d4de180 | 2014-10-10 15:51:02 +0000 | [diff] [blame] | 29 | ; CHECK: DW_AT_abstract_origin {{.*}}[[ABS_VAR:........]] "x" |
David Blaikie | 1ea9db2 | 2014-05-21 23:14:12 +0000 | [diff] [blame] | 30 | |
| 31 | ; Check the abstract definition is in the 'b.cpp' CU and doesn't contain any |
| 32 | ; concrete information (address range or variable location) |
| 33 | ; CHECK: DW_TAG_compile_unit |
| 34 | ; CHECK: DW_AT_name {{.*}} "b.cpp" |
| 35 | ; CHECK: 0x[[ABS_FUNC]]: DW_TAG_subprogram |
| 36 | ; CHECK-NOT: DW_AT_low_pc |
| 37 | ; CHECK: 0x[[ABS_VAR]]: DW_TAG_formal_parameter |
David Blaikie | 96fb902 | 2014-05-23 04:23:06 +0000 | [diff] [blame] | 38 | ; CHECK-NOT: DW_AT_location |
David Blaikie | f7221ad | 2014-05-27 18:37:43 +0000 | [diff] [blame] | 39 | ; CHECK: DW_AT_type [DW_FORM_ref4] {{.*}} {0x[[INT]]} |
David Blaikie | 1ea9db2 | 2014-05-21 23:14:12 +0000 | [diff] [blame] | 40 | ; CHECK-NOT: DW_AT_location |
| 41 | |
David Blaikie | f7221ad | 2014-05-27 18:37:43 +0000 | [diff] [blame] | 42 | ; CHECK: 0x[[INT]]: DW_TAG_base_type |
David Blaikie | f7221ad | 2014-05-27 18:37:43 +0000 | [diff] [blame] | 43 | ; CHECK: DW_AT_name {{.*}} "int" |
| 44 | |
David Blaikie | 1ea9db2 | 2014-05-21 23:14:12 +0000 | [diff] [blame] | 45 | ; Check the concrete out of line definition references the abstract and |
| 46 | ; provides the address range and variable location |
Frederic Riss | 3a6b354 | 2014-11-12 23:48:14 +0000 | [diff] [blame] | 47 | ; CHECK: 0x[[FUNC:[0-9a-f]*]]{{.*}}DW_TAG_subprogram |
David Blaikie | 1ea9db2 | 2014-05-21 23:14:12 +0000 | [diff] [blame] | 48 | ; CHECK: DW_AT_low_pc |
Frederic Riss | d1cfc3c | 2014-10-06 03:36:31 +0000 | [diff] [blame] | 49 | ; CHECK: DW_AT_abstract_origin {{.*}} {0x[[ABS_FUNC]]} "_Z4funci" |
David Blaikie | 1ea9db2 | 2014-05-21 23:14:12 +0000 | [diff] [blame] | 50 | ; CHECK: DW_TAG_formal_parameter |
David Blaikie | 1ea9db2 | 2014-05-21 23:14:12 +0000 | [diff] [blame] | 51 | ; CHECK: DW_AT_location |
Frederic Riss | d4de180 | 2014-10-10 15:51:02 +0000 | [diff] [blame] | 52 | ; CHECK: DW_AT_abstract_origin {{.*}} {0x[[ABS_VAR]]} "x" |
David Blaikie | 1ea9db2 | 2014-05-21 23:14:12 +0000 | [diff] [blame] | 53 | |
Frederic Riss | e837ec2 | 2014-11-14 16:15:53 +0000 | [diff] [blame] | 54 | ; Check that both the inline and the non out of line version of func are |
| 55 | ; correctly referenced in the accelerator table. Before r221837, the one |
| 56 | ; in the second compilation unit had a wrong offset |
| 57 | ; CHECK-ACCEL: .apple_names contents: |
Pavel Labath | 394e805 | 2018-01-29 11:33:17 +0000 | [diff] [blame] | 58 | ; CHECK-ACCEL: String{{.*}}"func" |
| 59 | ; CHECK-ACCEL-NOT: String |
Frederic Riss | e837ec2 | 2014-11-14 16:15:53 +0000 | [diff] [blame] | 60 | ; CHECK-ACCEL: Atom[0]{{.*}}[[INLINED]] |
Pavel Labath | 394e805 | 2018-01-29 11:33:17 +0000 | [diff] [blame] | 61 | ; CHECK-ACCEL-NOT: String |
Frederic Riss | e837ec2 | 2014-11-14 16:15:53 +0000 | [diff] [blame] | 62 | ; CHECK-ACCEL: Atom[0]{{.*}}[[FUNC]] |
| 63 | |
David Blaikie | 1ea9db2 | 2014-05-21 23:14:12 +0000 | [diff] [blame] | 64 | @i = external global i32 |
| 65 | |
| 66 | ; Function Attrs: uwtable |
Peter Collingbourne | d4bff30 | 2015-11-05 22:03:56 +0000 | [diff] [blame] | 67 | define i32 @main() #0 !dbg !4 { |
David Blaikie | 1ea9db2 | 2014-05-21 23:14:12 +0000 | [diff] [blame] | 68 | entry: |
| 69 | %x.addr.i = alloca i32, align 4 |
| 70 | %retval = alloca i32, align 4 |
| 71 | store i32 0, i32* %retval |
David Blaikie | a79ac14 | 2015-02-27 21:17:42 +0000 | [diff] [blame] | 72 | %0 = load i32, i32* @i, align 4, !dbg !19 |
David Blaikie | 1ea9db2 | 2014-05-21 23:14:12 +0000 | [diff] [blame] | 73 | %1 = bitcast i32* %x.addr.i to i8* |
| 74 | call void @llvm.lifetime.start(i64 4, i8* %1) |
| 75 | store i32 %0, i32* %x.addr.i, align 4 |
Duncan P. N. Exon Smith | a9308c4 | 2015-04-29 16:38:44 +0000 | [diff] [blame] | 76 | call void @llvm.dbg.declare(metadata i32* %x.addr.i, metadata !120, metadata !DIExpression()), !dbg !21 |
David Blaikie | a79ac14 | 2015-02-27 21:17:42 +0000 | [diff] [blame] | 77 | %2 = load i32, i32* %x.addr.i, align 4, !dbg !22 |
David Blaikie | 1ea9db2 | 2014-05-21 23:14:12 +0000 | [diff] [blame] | 78 | %mul.i = mul nsw i32 %2, 2, !dbg !22 |
| 79 | %3 = bitcast i32* %x.addr.i to i8*, !dbg !22 |
| 80 | call void @llvm.lifetime.end(i64 4, i8* %3), !dbg !22 |
| 81 | ret i32 %mul.i, !dbg !19 |
| 82 | } |
| 83 | |
| 84 | ; Function Attrs: alwaysinline nounwind uwtable |
Peter Collingbourne | d4bff30 | 2015-11-05 22:03:56 +0000 | [diff] [blame] | 85 | define i32 @_Z4funci(i32 %x) #1 !dbg !12 { |
David Blaikie | 1ea9db2 | 2014-05-21 23:14:12 +0000 | [diff] [blame] | 86 | entry: |
| 87 | %x.addr = alloca i32, align 4 |
| 88 | store i32 %x, i32* %x.addr, align 4 |
Duncan P. N. Exon Smith | a9308c4 | 2015-04-29 16:38:44 +0000 | [diff] [blame] | 89 | call void @llvm.dbg.declare(metadata i32* %x.addr, metadata !20, metadata !DIExpression()), !dbg !23 |
David Blaikie | a79ac14 | 2015-02-27 21:17:42 +0000 | [diff] [blame] | 90 | %0 = load i32, i32* %x.addr, align 4, !dbg !24 |
David Blaikie | 1ea9db2 | 2014-05-21 23:14:12 +0000 | [diff] [blame] | 91 | %mul = mul nsw i32 %0, 2, !dbg !24 |
| 92 | ret i32 %mul, !dbg !24 |
| 93 | } |
| 94 | |
| 95 | ; Function Attrs: nounwind readnone |
Adrian Prantl | 87b7eb9 | 2014-10-01 18:55:02 +0000 | [diff] [blame] | 96 | declare void @llvm.dbg.declare(metadata, metadata, metadata) #2 |
David Blaikie | 1ea9db2 | 2014-05-21 23:14:12 +0000 | [diff] [blame] | 97 | |
| 98 | ; Function Attrs: nounwind |
| 99 | declare void @llvm.lifetime.start(i64, i8* nocapture) #3 |
| 100 | |
| 101 | ; Function Attrs: nounwind |
| 102 | declare void @llvm.lifetime.end(i64, i8* nocapture) #3 |
| 103 | |
Fangrui Song | 502a77f | 2019-12-24 15:52:21 -0800 | [diff] [blame] | 104 | attributes #0 = { uwtable "less-precise-fpmad"="false" "frame-pointer"="all" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "stack-protector-buffer-size"="8" "unsafe-fp-math"="false" "use-soft-float"="false" } |
| 105 | attributes #1 = { alwaysinline nounwind uwtable "less-precise-fpmad"="false" "frame-pointer"="all" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "stack-protector-buffer-size"="8" "unsafe-fp-math"="false" "use-soft-float"="false" } |
David Blaikie | 1ea9db2 | 2014-05-21 23:14:12 +0000 | [diff] [blame] | 106 | attributes #2 = { nounwind readnone } |
| 107 | attributes #3 = { nounwind } |
| 108 | |
| 109 | !llvm.dbg.cu = !{!0, !9} |
| 110 | !llvm.module.flags = !{!16, !17} |
| 111 | !llvm.ident = !{!18, !18} |
| 112 | |
Adrian Prantl | 75819ae | 2016-04-15 15:57:41 +0000 | [diff] [blame] | 113 | !0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, producer: "clang version 3.5.0 ", isOptimized: false, emissionKind: FullDebug, file: !1, enums: !2, retainedTypes: !2, globals: !2, imports: !2) |
Duncan P. N. Exon Smith | a9308c4 | 2015-04-29 16:38:44 +0000 | [diff] [blame] | 114 | !1 = !DIFile(filename: "a.cpp", directory: "/tmp/dbginfo") |
Duncan P. N. Exon Smith | be7ea19 | 2014-12-15 19:07:53 +0000 | [diff] [blame] | 115 | !2 = !{} |
Shiva Chen | 2c86455 | 2018-05-09 02:40:45 +0000 | [diff] [blame] | 116 | !4 = distinct !DISubprogram(name: "main", line: 3, isLocal: false, isDefinition: true, virtualIndex: 6, flags: DIFlagPrototyped, isOptimized: false, unit: !0, scopeLine: 3, file: !1, scope: !5, type: !6, retainedNodes: !2) |
Duncan P. N. Exon Smith | a9308c4 | 2015-04-29 16:38:44 +0000 | [diff] [blame] | 117 | !5 = !DIFile(filename: "a.cpp", directory: "/tmp/dbginfo") |
| 118 | !6 = !DISubroutineType(types: !7) |
Duncan P. N. Exon Smith | be7ea19 | 2014-12-15 19:07:53 +0000 | [diff] [blame] | 119 | !7 = !{!8} |
Duncan P. N. Exon Smith | a9308c4 | 2015-04-29 16:38:44 +0000 | [diff] [blame] | 120 | !8 = !DIBasicType(tag: DW_TAG_base_type, name: "int", size: 32, align: 32, encoding: DW_ATE_signed) |
Adrian Prantl | 75819ae | 2016-04-15 15:57:41 +0000 | [diff] [blame] | 121 | !9 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, producer: "clang version 3.5.0 ", isOptimized: false, emissionKind: FullDebug, file: !10, enums: !2, retainedTypes: !2, globals: !2, imports: !2) |
Duncan P. N. Exon Smith | a9308c4 | 2015-04-29 16:38:44 +0000 | [diff] [blame] | 122 | !10 = !DIFile(filename: "b.cpp", directory: "/tmp/dbginfo") |
Shiva Chen | 2c86455 | 2018-05-09 02:40:45 +0000 | [diff] [blame] | 123 | !12 = distinct !DISubprogram(name: "func", linkageName: "_Z4funci", line: 1, isLocal: false, isDefinition: true, virtualIndex: 6, flags: DIFlagPrototyped, isOptimized: false, unit: !9, scopeLine: 1, file: !10, scope: !13, type: !14, retainedNodes: !2) |
Duncan P. N. Exon Smith | a9308c4 | 2015-04-29 16:38:44 +0000 | [diff] [blame] | 124 | !13 = !DIFile(filename: "b.cpp", directory: "/tmp/dbginfo") |
| 125 | !14 = !DISubroutineType(types: !15) |
Duncan P. N. Exon Smith | be7ea19 | 2014-12-15 19:07:53 +0000 | [diff] [blame] | 126 | !15 = !{!8, !8} |
| 127 | !16 = !{i32 2, !"Dwarf Version", i32 4} |
Duncan P. N. Exon Smith | e274180 | 2015-03-03 17:24:31 +0000 | [diff] [blame] | 128 | !17 = !{i32 2, !"Debug Info Version", i32 3} |
Duncan P. N. Exon Smith | be7ea19 | 2014-12-15 19:07:53 +0000 | [diff] [blame] | 129 | !18 = !{!"clang version 3.5.0 "} |
Duncan P. N. Exon Smith | a9308c4 | 2015-04-29 16:38:44 +0000 | [diff] [blame] | 130 | !19 = !DILocation(line: 4, scope: !4) |
Duncan P. N. Exon Smith | ed013cd | 2015-07-31 18:58:39 +0000 | [diff] [blame] | 131 | !20 = !DILocalVariable(name: "x", line: 1, arg: 1, scope: !12, file: !13, type: !8) |
Duncan P. N. Exon Smith | 81f522a | 2015-04-03 16:54:30 +0000 | [diff] [blame] | 132 | |
Duncan P. N. Exon Smith | ed013cd | 2015-07-31 18:58:39 +0000 | [diff] [blame] | 133 | !120 = !DILocalVariable(name: "x", line: 1, arg: 1, scope: !12, file: !13, type: !8) |
Duncan P. N. Exon Smith | 81f522a | 2015-04-03 16:54:30 +0000 | [diff] [blame] | 134 | |
Duncan P. N. Exon Smith | a9308c4 | 2015-04-29 16:38:44 +0000 | [diff] [blame] | 135 | !21 = !DILocation(line: 1, scope: !12, inlinedAt: !19) |
| 136 | !22 = !DILocation(line: 2, scope: !12, inlinedAt: !19) |
| 137 | !23 = !DILocation(line: 1, scope: !12) |
| 138 | !24 = !DILocation(line: 2, scope: !12) |
David Blaikie | 1ea9db2 | 2014-05-21 23:14:12 +0000 | [diff] [blame] | 139 | |