Adrian Prantl | 7bc1b28 | 2017-09-11 22:59:45 +0000 | [diff] [blame] | 1 | ; RUN: llc -O1 -filetype=obj -o - %s | llvm-dwarfdump -all - | FileCheck %s |
Adrian Prantl | 75ce62a | 2014-04-01 21:04:18 +0000 | [diff] [blame] | 2 | ; Generated with -O1 from: |
| 3 | ; int f1(); |
| 4 | ; void f2(int*); |
| 5 | ; int f3(int); |
| 6 | ; |
| 7 | ; int foo() { |
| 8 | ; int i = 3; |
| 9 | ; f3(i); |
| 10 | ; i = 7; |
| 11 | ; i = f1(); |
| 12 | ; f2(&i); |
| 13 | ; return 0; |
| 14 | ; } |
| 15 | ; |
| 16 | ; Test that we generate valid debug info for optimized code, |
Alp Toker | 16f98b2 | 2014-04-09 14:47:27 +0000 | [diff] [blame] | 17 | ; particularly variables that are described as constants and passed |
Adrian Prantl | 75ce62a | 2014-04-01 21:04:18 +0000 | [diff] [blame] | 18 | ; by reference. |
| 19 | ; rdar://problem/14874886 |
| 20 | ; |
| 21 | ; CHECK: .debug_info contents: |
| 22 | ; CHECK: DW_TAG_variable |
Adrian Prantl | 75ce62a | 2014-04-01 21:04:18 +0000 | [diff] [blame] | 23 | ; CHECK-NOT: DW_TAG |
Reid Kleckner | a058736 | 2017-08-29 21:41:21 +0000 | [diff] [blame] | 24 | ; CHECK: DW_AT_location {{.*}}({{.*}} |
Jonas Devlieghere | 6f24c87 | 2018-01-16 11:17:57 +0000 | [diff] [blame] | 25 | ; CHECK-NEXT: [0x{{0*.*}}, 0x[[C1:.*]]): DW_OP_consts +3 |
| 26 | ; CHECK-NEXT: [0x[[C1]], 0x[[C2:.*]]): DW_OP_consts +7 |
| 27 | ; CHECK-NEXT: [0x[[C2]], 0x[[R1:.*]]): DW_OP_reg0 RAX |
Vedant Kumar | b572f64 | 2018-07-26 20:56:53 +0000 | [diff] [blame] | 28 | ; CHECK-NEXT: [0x[[R1]], 0x[[R2:.*]]): DW_OP_breg7 RSP+4) |
David Blaikie | eb1a272 | 2014-06-13 22:18:23 +0000 | [diff] [blame] | 29 | ; CHECK-NOT: DW_TAG |
| 30 | ; CHECK: DW_AT_name{{.*}}"i" |
Reid Kleckner | a058736 | 2017-08-29 21:41:21 +0000 | [diff] [blame] | 31 | |
Adrian Prantl | 75ce62a | 2014-04-01 21:04:18 +0000 | [diff] [blame] | 32 | target datalayout = "e-m:o-i64:64-f80:128-n8:16:32:64-S128" |
| 33 | target triple = "x86_64-apple-macosx10.9.0" |
| 34 | |
| 35 | ; Function Attrs: nounwind ssp uwtable |
Peter Collingbourne | d4bff30 | 2015-11-05 22:03:56 +0000 | [diff] [blame] | 36 | define i32 @foo() #0 !dbg !4 { |
Adrian Prantl | 75ce62a | 2014-04-01 21:04:18 +0000 | [diff] [blame] | 37 | entry: |
| 38 | %i = alloca i32, align 4 |
Adrian Prantl | abe0475 | 2017-07-28 20:21:02 +0000 | [diff] [blame] | 39 | call void @llvm.dbg.value(metadata i32 3, metadata !10, metadata !DIExpression()), !dbg !15 |
Adrian Prantl | 75ce62a | 2014-04-01 21:04:18 +0000 | [diff] [blame] | 40 | %call = call i32 @f3(i32 3) #3, !dbg !16 |
Adrian Prantl | abe0475 | 2017-07-28 20:21:02 +0000 | [diff] [blame] | 41 | call void @llvm.dbg.value(metadata i32 7, metadata !10, metadata !DIExpression()), !dbg !18 |
David Blaikie | 23af648 | 2015-04-16 23:24:18 +0000 | [diff] [blame] | 42 | %call1 = call i32 (...) @f1() #3, !dbg !19 |
Adrian Prantl | abe0475 | 2017-07-28 20:21:02 +0000 | [diff] [blame] | 43 | call void @llvm.dbg.value(metadata i32 %call1, metadata !10, metadata !DIExpression()), !dbg !19 |
Adrian Prantl | 75ce62a | 2014-04-01 21:04:18 +0000 | [diff] [blame] | 44 | store i32 %call1, i32* %i, align 4, !dbg !19, !tbaa !20 |
Adrian Prantl | abe0475 | 2017-07-28 20:21:02 +0000 | [diff] [blame] | 45 | call void @llvm.dbg.value(metadata i32* %i, metadata !10, metadata !DIExpression(DW_OP_deref)), !dbg !24 |
Adrian Prantl | 75ce62a | 2014-04-01 21:04:18 +0000 | [diff] [blame] | 46 | call void @f2(i32* %i) #3, !dbg !24 |
| 47 | ret i32 0, !dbg !25 |
| 48 | } |
| 49 | |
| 50 | declare i32 @f3(i32) |
| 51 | |
| 52 | declare i32 @f1(...) |
| 53 | |
| 54 | declare void @f2(i32*) |
| 55 | |
| 56 | ; Function Attrs: nounwind readnone |
Adrian Prantl | abe0475 | 2017-07-28 20:21:02 +0000 | [diff] [blame] | 57 | declare void @llvm.dbg.value(metadata, metadata, metadata) #2 |
Adrian Prantl | 75ce62a | 2014-04-01 21:04:18 +0000 | [diff] [blame] | 58 | |
| 59 | attributes #0 = { nounwind ssp uwtable } |
| 60 | attributes #2 = { nounwind readnone } |
| 61 | attributes #3 = { nounwind } |
| 62 | |
| 63 | !llvm.dbg.cu = !{!0} |
| 64 | !llvm.module.flags = !{!11, !12} |
| 65 | !llvm.ident = !{!13} |
| 66 | |
Adrian Prantl | 75819ae | 2016-04-15 15:57:41 +0000 | [diff] [blame] | 67 | !0 = distinct !DICompileUnit(language: DW_LANG_C99, producer: "clang version 3.5.0 ", isOptimized: true, 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] | 68 | !1 = !DIFile(filename: "dbg-value-const-byref.c", directory: "") |
Duncan P. N. Exon Smith | be7ea19 | 2014-12-15 19:07:53 +0000 | [diff] [blame] | 69 | !2 = !{} |
Shiva Chen | 2c86455 | 2018-05-09 02:40:45 +0000 | [diff] [blame] | 70 | !4 = distinct !DISubprogram(name: "foo", line: 5, isLocal: false, isDefinition: true, virtualIndex: 6, isOptimized: true, unit: !0, scopeLine: 5, file: !1, scope: !5, type: !6, retainedNodes: !9) |
Duncan P. N. Exon Smith | a9308c4 | 2015-04-29 16:38:44 +0000 | [diff] [blame] | 71 | !5 = !DIFile(filename: "dbg-value-const-byref.c", directory: "") |
| 72 | !6 = !DISubroutineType(types: !7) |
Duncan P. N. Exon Smith | be7ea19 | 2014-12-15 19:07:53 +0000 | [diff] [blame] | 73 | !7 = !{!8} |
Duncan P. N. Exon Smith | a9308c4 | 2015-04-29 16:38:44 +0000 | [diff] [blame] | 74 | !8 = !DIBasicType(tag: DW_TAG_base_type, name: "int", size: 32, align: 32, encoding: DW_ATE_signed) |
Duncan P. N. Exon Smith | be7ea19 | 2014-12-15 19:07:53 +0000 | [diff] [blame] | 75 | !9 = !{!10} |
Duncan P. N. Exon Smith | ed013cd | 2015-07-31 18:58:39 +0000 | [diff] [blame] | 76 | !10 = !DILocalVariable(name: "i", line: 6, scope: !4, file: !5, type: !8) |
Duncan P. N. Exon Smith | be7ea19 | 2014-12-15 19:07:53 +0000 | [diff] [blame] | 77 | !11 = !{i32 2, !"Dwarf Version", i32 2} |
Duncan P. N. Exon Smith | e274180 | 2015-03-03 17:24:31 +0000 | [diff] [blame] | 78 | !12 = !{i32 1, !"Debug Info Version", i32 3} |
Duncan P. N. Exon Smith | be7ea19 | 2014-12-15 19:07:53 +0000 | [diff] [blame] | 79 | !13 = !{!"clang version 3.5.0 "} |
| 80 | !14 = !{i32 3} |
Duncan P. N. Exon Smith | a9308c4 | 2015-04-29 16:38:44 +0000 | [diff] [blame] | 81 | !15 = !DILocation(line: 6, scope: !4) |
| 82 | !16 = !DILocation(line: 7, scope: !4) |
Duncan P. N. Exon Smith | be7ea19 | 2014-12-15 19:07:53 +0000 | [diff] [blame] | 83 | !17 = !{i32 7} |
Duncan P. N. Exon Smith | a9308c4 | 2015-04-29 16:38:44 +0000 | [diff] [blame] | 84 | !18 = !DILocation(line: 8, scope: !4) |
| 85 | !19 = !DILocation(line: 9, scope: !4) |
Duncan P. N. Exon Smith | be7ea19 | 2014-12-15 19:07:53 +0000 | [diff] [blame] | 86 | !20 = !{!21, !21, i64 0} |
| 87 | !21 = !{!"int", !22, i64 0} |
| 88 | !22 = !{!"omnipotent char", !23, i64 0} |
| 89 | !23 = !{!"Simple C/C++ TBAA"} |
Duncan P. N. Exon Smith | a9308c4 | 2015-04-29 16:38:44 +0000 | [diff] [blame] | 90 | !24 = !DILocation(line: 10, scope: !4) |
| 91 | !25 = !DILocation(line: 11, scope: !4) |