| David Blaikie | 6fa9966 | 2014-04-01 23:19:23 +0000 | [diff] [blame] | 1 | ; RUN: llc -O1 -filetype=obj -mtriple=x86_64-apple-darwin < %s > %t |
| Adrian Prantl | 16aa4cf | 2017-09-11 23:05:20 +0000 | [diff] [blame] | 2 | ; RUN: llvm-dwarfdump -v %t | FileCheck %s |
| Rafael Espindola | 0cc9ba1 | 2014-04-03 23:20:02 +0000 | [diff] [blame] | 3 | ; RUN: llvm-objdump -r %t | FileCheck -check-prefix=DARWIN %s |
| David Blaikie | 6fa9966 | 2014-04-01 23:19:23 +0000 | [diff] [blame] | 4 | ; RUN: llc -O1 -filetype=obj -mtriple=x86_64-pc-linux-gnu < %s > %t |
| Adrian Prantl | 16aa4cf | 2017-09-11 23:05:20 +0000 | [diff] [blame] | 5 | ; RUN: llvm-dwarfdump -v %t | FileCheck %s |
| David Blaikie | 6fa9966 | 2014-04-01 23:19:23 +0000 | [diff] [blame] | 6 | ; RUN: llvm-objdump -r %t | FileCheck -check-prefix=LINUX %s |
| 7 | |
| Nick Lewycky | 33da336 | 2012-06-22 01:25:12 +0000 | [diff] [blame] | 8 | ; PR9493 |
| 9 | ; Adapted from the original test case in r127757. |
| 10 | ; We use 'llc -O1' to induce variable 'x' to live in different locations. |
| 11 | ; We don't actually care where 'x' lives, or what exact optimizations get |
| 12 | ; used, as long as 'x' moves around we're fine. |
| 13 | |
| 14 | ; // The variable 'x' lives in different locations, so it needs an entry in |
| 15 | ; // the .debug_loc table section, referenced by DW_AT_location. |
| 16 | ; // This ref is not relocatable on Darwin, and is relocatable elsewhere. |
| 17 | ; extern int g(int, int); |
| 18 | ; extern int a; |
| Jonas Devlieghere | 6f24c87 | 2018-01-16 11:17:57 +0000 | [diff] [blame] | 19 | ; |
| Nick Lewycky | 33da336 | 2012-06-22 01:25:12 +0000 | [diff] [blame] | 20 | ; void f(void) { |
| 21 | ; int x; |
| 22 | ; a = g(0, 0); |
| 23 | ; x = 1; |
| 24 | ; while (x & 1) { x *= a; } |
| 25 | ; a = g(x, 0); |
| 26 | ; x = 2; |
| 27 | ; while (x & 2) { x *= a; } |
| 28 | ; a = g(0, x); |
| 29 | ; } |
| 30 | |
| 31 | ; // The 'x' variable and its symbol reference location |
| David Blaikie | 6fa9966 | 2014-04-01 23:19:23 +0000 | [diff] [blame] | 32 | ; CHECK: .debug_info contents: |
| 33 | ; CHECK: DW_TAG_variable |
| Reid Kleckner | a058736 | 2017-08-29 21:41:21 +0000 | [diff] [blame] | 34 | ; CHECK-NEXT: DW_AT_location [DW_FORM_sec_offset] (0x00000000 |
| 35 | ; Check that the location contains only 4 ranges - this verifies that the 4th |
| 36 | ; and 5th ranges were successfully merged into a single range. |
| Jonas Devlieghere | 6f24c87 | 2018-01-16 11:17:57 +0000 | [diff] [blame] | 37 | ; CHECK-NEXT: [0x{{[0-9a-f]*}}, 0x{{[0-9a-f]*}}): |
| 38 | ; CHECK-NEXT: [0x{{[0-9a-f]*}}, 0x{{[0-9a-f]*}}): |
| 39 | ; CHECK-NEXT: [0x{{[0-9a-f]*}}, 0x{{[0-9a-f]*}}): |
| 40 | ; CHECK-NEXT: [0x{{[0-9a-f]*}}, 0x{{[0-9a-f]*}}): {{.*}}) |
| David Blaikie | 6fa9966 | 2014-04-01 23:19:23 +0000 | [diff] [blame] | 41 | ; CHECK-NEXT: DW_AT_name {{.*}} "x" |
| 42 | ; CHECK-NEXT: DW_AT_decl_file |
| 43 | ; CHECK-NEXT: DW_AT_decl_line |
| 44 | ; CHECK-NEXT: DW_AT_type |
| Nick Lewycky | 33da336 | 2012-06-22 01:25:12 +0000 | [diff] [blame] | 45 | |
| David Blaikie | 6fa9966 | 2014-04-01 23:19:23 +0000 | [diff] [blame] | 46 | ; Check that we have no relocations in Darwin's output. |
| 47 | ; DARWIN-NOT: X86_64_RELOC{{.*}} __debug_loc |
| 48 | |
| 49 | ; Check we have a relocation for the debug_loc entry in Linux output. |
| 50 | ; LINUX: RELOCATION RECORDS FOR [.rela.debug_info] |
| 51 | ; LINUX-NOT: RELOCATION RECORDS |
| Daniel Cederman | d72b9fd | 2018-06-01 05:31:58 +0000 | [diff] [blame] | 52 | ; LINUX: R_X86_64{{.*}} .debug_loc |
| Nick Lewycky | 33da336 | 2012-06-22 01:25:12 +0000 | [diff] [blame] | 53 | |
| 54 | ; ModuleID = 'simple.c' |
| 55 | target datalayout = "e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-n32" |
| 56 | |
| 57 | @a = external global i32 |
| 58 | |
| Peter Collingbourne | d4bff30 | 2015-11-05 22:03:56 +0000 | [diff] [blame] | 59 | define void @f() nounwind !dbg !0 { |
| Nick Lewycky | 33da336 | 2012-06-22 01:25:12 +0000 | [diff] [blame] | 60 | entry: |
| 61 | %call = tail call i32 @g(i32 0, i32 0) nounwind, !dbg !8 |
| Manman Ren | 1a5ff28 | 2013-04-30 17:52:57 +0000 | [diff] [blame] | 62 | store i32 %call, i32* @a, align 4, !dbg !8 |
| Adrian Prantl | abe0475 | 2017-07-28 20:21:02 +0000 | [diff] [blame] | 63 | tail call void @llvm.dbg.value(metadata i32 1, metadata !5, metadata !DIExpression()), !dbg !13 |
| Nick Lewycky | 33da336 | 2012-06-22 01:25:12 +0000 | [diff] [blame] | 64 | br label %while.body |
| 65 | |
| 66 | while.body: ; preds = %entry, %while.body |
| 67 | %x.017 = phi i32 [ 1, %entry ], [ %mul, %while.body ] |
| 68 | %mul = mul nsw i32 %call, %x.017, !dbg !14 |
| 69 | %and = and i32 %mul, 1, !dbg !14 |
| 70 | %tobool = icmp eq i32 %and, 0, !dbg !14 |
| 71 | br i1 %tobool, label %while.end, label %while.body, !dbg !14 |
| 72 | |
| 73 | while.end: ; preds = %while.body |
| Adrian Prantl | abe0475 | 2017-07-28 20:21:02 +0000 | [diff] [blame] | 74 | tail call void @llvm.dbg.value(metadata i32 %mul, metadata !5, metadata !DIExpression()), !dbg !14 |
| Nick Lewycky | 33da336 | 2012-06-22 01:25:12 +0000 | [diff] [blame] | 75 | %call4 = tail call i32 @g(i32 %mul, i32 0) nounwind, !dbg !15 |
| Manman Ren | 1a5ff28 | 2013-04-30 17:52:57 +0000 | [diff] [blame] | 76 | store i32 %call4, i32* @a, align 4, !dbg !15 |
| Adrian Prantl | abe0475 | 2017-07-28 20:21:02 +0000 | [diff] [blame] | 77 | tail call void @llvm.dbg.value(metadata i32 2, metadata !5, metadata !DIExpression()), !dbg !17 |
| Nick Lewycky | 33da336 | 2012-06-22 01:25:12 +0000 | [diff] [blame] | 78 | br label %while.body9 |
| 79 | |
| 80 | while.body9: ; preds = %while.end, %while.body9 |
| 81 | %x.116 = phi i32 [ 2, %while.end ], [ %mul12, %while.body9 ] |
| 82 | %mul12 = mul nsw i32 %call4, %x.116, !dbg !18 |
| 83 | %and7 = and i32 %mul12, 2, !dbg !18 |
| 84 | %tobool8 = icmp eq i32 %and7, 0, !dbg !18 |
| 85 | br i1 %tobool8, label %while.end13, label %while.body9, !dbg !18 |
| 86 | |
| 87 | while.end13: ; preds = %while.body9 |
| Adrian Prantl | abe0475 | 2017-07-28 20:21:02 +0000 | [diff] [blame] | 88 | tail call void @llvm.dbg.value(metadata i32 %mul12, metadata !5, metadata !DIExpression()), !dbg !18 |
| Nick Lewycky | 33da336 | 2012-06-22 01:25:12 +0000 | [diff] [blame] | 89 | %call15 = tail call i32 @g(i32 0, i32 %mul12) nounwind, !dbg !19 |
| Manman Ren | 1a5ff28 | 2013-04-30 17:52:57 +0000 | [diff] [blame] | 90 | store i32 %call15, i32* @a, align 4, !dbg !19 |
| Nick Lewycky | 33da336 | 2012-06-22 01:25:12 +0000 | [diff] [blame] | 91 | ret void, !dbg !20 |
| 92 | } |
| 93 | |
| 94 | declare i32 @g(i32, i32) |
| 95 | |
| Adrian Prantl | abe0475 | 2017-07-28 20:21:02 +0000 | [diff] [blame] | 96 | declare void @llvm.dbg.value(metadata, metadata, metadata) nounwind readnone |
| Nick Lewycky | 33da336 | 2012-06-22 01:25:12 +0000 | [diff] [blame] | 97 | |
| David Blaikie | e5a2f70 | 2013-03-08 00:23:31 +0000 | [diff] [blame] | 98 | !llvm.dbg.cu = !{!2} |
| Manman Ren | 409558f | 2013-11-22 21:49:45 +0000 | [diff] [blame] | 99 | !llvm.module.flags = !{!24} |
| Nick Lewycky | 33da336 | 2012-06-22 01:25:12 +0000 | [diff] [blame] | 100 | |
| Shiva Chen | 2c86455 | 2018-05-09 02:40:45 +0000 | [diff] [blame] | 101 | !0 = distinct !DISubprogram(name: "f", line: 4, isLocal: false, isDefinition: true, virtualIndex: 6, flags: DIFlagPrototyped, isOptimized: true, unit: !2, scopeLine: 4, file: !23, scope: !1, type: !3, retainedNodes: !22) |
| Duncan P. N. Exon Smith | a9308c4 | 2015-04-29 16:38:44 +0000 | [diff] [blame] | 102 | !1 = !DIFile(filename: "simple.c", directory: "/home/rengol01/temp/tests/dwarf/relocation") |
| Adrian Prantl | 75819ae | 2016-04-15 15:57:41 +0000 | [diff] [blame] | 103 | !2 = distinct !DICompileUnit(language: DW_LANG_C99, producer: "clang version 3.0 (trunk)", isOptimized: true, emissionKind: FullDebug, file: !23, enums: !{}, retainedTypes: !{}, imports: null) |
| Duncan P. N. Exon Smith | a9308c4 | 2015-04-29 16:38:44 +0000 | [diff] [blame] | 104 | !3 = !DISubroutineType(types: !4) |
| Duncan P. N. Exon Smith | be7ea19 | 2014-12-15 19:07:53 +0000 | [diff] [blame] | 105 | !4 = !{null} |
| Duncan P. N. Exon Smith | ed013cd | 2015-07-31 18:58:39 +0000 | [diff] [blame] | 106 | !5 = !DILocalVariable(name: "x", line: 5, scope: !6, file: !1, type: !7) |
| Duncan P. N. Exon Smith | a9308c4 | 2015-04-29 16:38:44 +0000 | [diff] [blame] | 107 | !6 = distinct !DILexicalBlock(line: 4, column: 14, file: !23, scope: !0) |
| 108 | !7 = !DIBasicType(tag: DW_TAG_base_type, name: "int", size: 32, align: 32, encoding: DW_ATE_signed) |
| 109 | !8 = !DILocation(line: 6, column: 3, scope: !6) |
| Duncan P. N. Exon Smith | be7ea19 | 2014-12-15 19:07:53 +0000 | [diff] [blame] | 110 | !12 = !{i32 1} |
| Duncan P. N. Exon Smith | a9308c4 | 2015-04-29 16:38:44 +0000 | [diff] [blame] | 111 | !13 = !DILocation(line: 7, column: 3, scope: !6) |
| 112 | !14 = !DILocation(line: 8, column: 3, scope: !6) |
| 113 | !15 = !DILocation(line: 9, column: 3, scope: !6) |
| Duncan P. N. Exon Smith | be7ea19 | 2014-12-15 19:07:53 +0000 | [diff] [blame] | 114 | !16 = !{i32 2} |
| Duncan P. N. Exon Smith | a9308c4 | 2015-04-29 16:38:44 +0000 | [diff] [blame] | 115 | !17 = !DILocation(line: 10, column: 3, scope: !6) |
| 116 | !18 = !DILocation(line: 11, column: 3, scope: !6) |
| 117 | !19 = !DILocation(line: 12, column: 3, scope: !6) |
| 118 | !20 = !DILocation(line: 13, column: 1, scope: !6) |
| Duncan P. N. Exon Smith | be7ea19 | 2014-12-15 19:07:53 +0000 | [diff] [blame] | 119 | !22 = !{!5} |
| Duncan P. N. Exon Smith | a9308c4 | 2015-04-29 16:38:44 +0000 | [diff] [blame] | 120 | !23 = !DIFile(filename: "simple.c", directory: "/home/rengol01/temp/tests/dwarf/relocation") |
| Duncan P. N. Exon Smith | e274180 | 2015-03-03 17:24:31 +0000 | [diff] [blame] | 121 | !24 = !{i32 1, !"Debug Info Version", i32 3} |