Adrian Prantl | 4d36525 | 2015-01-30 01:55:25 +0000 | [diff] [blame] | 1 | ; RUN: opt -inline -S < %s | FileCheck %s |
| 2 | ; struct A { |
| 3 | ; int arg0; |
| 4 | ; double arg1[2]; |
| 5 | ; } a, b; |
| 6 | ; |
| 7 | ; void fn3(A p1) { |
| 8 | ; if (p1.arg0) |
| 9 | ; a = p1; |
| 10 | ; } |
| 11 | ; |
| 12 | ; void fn4() { fn3(b); } |
| 13 | ; |
| 14 | ; void fn5() { |
| 15 | ; while (1) |
| 16 | ; fn4(); |
| 17 | ; } |
| 18 | ; ModuleID = 'test.cpp' |
| 19 | target datalayout = "e-m:o-i64:64-i128:128-n32:64-S128" |
| 20 | target triple = "aarch64-apple-darwin" |
| 21 | |
| 22 | %struct.A = type { i32, [2 x double] } |
| 23 | |
| 24 | @a = global %struct.A zeroinitializer, align 8 |
| 25 | @b = global %struct.A zeroinitializer, align 8 |
| 26 | |
| 27 | ; Function Attrs: nounwind |
| 28 | declare void @_Z3fn31A(%struct.A* nocapture readonly %p1) #0 |
| 29 | |
| 30 | ; Function Attrs: nounwind readnone |
| 31 | declare void @llvm.dbg.declare(metadata, metadata, metadata) #1 |
| 32 | |
| 33 | ; Function Attrs: nounwind |
Pete Cooper | 67cf9a7 | 2015-11-19 05:56:52 +0000 | [diff] [blame] | 34 | declare void @llvm.memcpy.p0i8.p0i8.i64(i8* nocapture, i8* nocapture readonly, i64, i32, i1) #2 |
Adrian Prantl | 4d36525 | 2015-01-30 01:55:25 +0000 | [diff] [blame] | 35 | |
| 36 | ; Function Attrs: nounwind |
Peter Collingbourne | d4bff30 | 2015-11-05 22:03:56 +0000 | [diff] [blame] | 37 | define void @_Z3fn4v() #0 !dbg !21 { |
Adrian Prantl | 4d36525 | 2015-01-30 01:55:25 +0000 | [diff] [blame] | 38 | entry: |
| 39 | ; Test that the dbg.declare is moved together with the alloca. |
| 40 | ; CHECK: define void @_Z3fn5v() |
| 41 | ; CHECK-NEXT: entry: |
| 42 | ; CHECK-NEXT: %agg.tmp.sroa.3.i = alloca [20 x i8], align 4 |
Adrian Prantl | 3e2659e | 2015-01-30 19:37:48 +0000 | [diff] [blame] | 43 | ; CHECK-NEXT: call void @llvm.dbg.declare(metadata [20 x i8]* %agg.tmp.sroa.3.i, |
Adrian Prantl | 4d36525 | 2015-01-30 01:55:25 +0000 | [diff] [blame] | 44 | %agg.tmp.sroa.3 = alloca [20 x i8], align 4 |
| 45 | tail call void @llvm.dbg.declare(metadata [20 x i8]* %agg.tmp.sroa.3, metadata !46, metadata !48), !dbg !49 |
David Blaikie | f72d05b | 2015-03-13 18:20:45 +0000 | [diff] [blame] | 46 | %agg.tmp.sroa.0.0.copyload = load i32, i32* getelementptr inbounds (%struct.A, %struct.A* @b, i64 0, i32 0), align 8, !dbg !50 |
Adrian Prantl | 4d36525 | 2015-01-30 01:55:25 +0000 | [diff] [blame] | 47 | tail call void @llvm.dbg.value(metadata i32 %agg.tmp.sroa.0.0.copyload, i64 0, metadata !46, metadata !51), !dbg !49 |
David Blaikie | 79e6c74 | 2015-02-27 19:29:02 +0000 | [diff] [blame] | 48 | %agg.tmp.sroa.3.0..sroa_idx = getelementptr inbounds [20 x i8], [20 x i8]* %agg.tmp.sroa.3, i64 0, i64 0, !dbg !50 |
Pete Cooper | 67cf9a7 | 2015-11-19 05:56:52 +0000 | [diff] [blame] | 49 | call void @llvm.memcpy.p0i8.p0i8.i64(i8* %agg.tmp.sroa.3.0..sroa_idx, i8* getelementptr (i8, i8* bitcast (%struct.A* @b to i8*), i64 4), i64 20, i32 4, i1 false), !dbg !50 |
Adrian Prantl | 4d36525 | 2015-01-30 01:55:25 +0000 | [diff] [blame] | 50 | tail call void @llvm.dbg.declare(metadata %struct.A* undef, metadata !46, metadata !31) #2, !dbg !49 |
| 51 | %tobool.i = icmp eq i32 %agg.tmp.sroa.0.0.copyload, 0, !dbg !52 |
| 52 | br i1 %tobool.i, label %_Z3fn31A.exit, label %if.then.i, !dbg !53 |
| 53 | |
| 54 | if.then.i: ; preds = %entry |
David Blaikie | f72d05b | 2015-03-13 18:20:45 +0000 | [diff] [blame] | 55 | store i32 %agg.tmp.sroa.0.0.copyload, i32* getelementptr inbounds (%struct.A, %struct.A* @a, i64 0, i32 0), align 8, !dbg !54 |
Pete Cooper | 67cf9a7 | 2015-11-19 05:56:52 +0000 | [diff] [blame] | 56 | call void @llvm.memcpy.p0i8.p0i8.i64(i8* getelementptr (i8, i8* bitcast (%struct.A* @a to i8*), i64 4), i8* %agg.tmp.sroa.3.0..sroa_idx, i64 20, i32 4, i1 false), !dbg !54 |
Adrian Prantl | 4d36525 | 2015-01-30 01:55:25 +0000 | [diff] [blame] | 57 | br label %_Z3fn31A.exit, !dbg !54 |
| 58 | |
| 59 | _Z3fn31A.exit: ; preds = %entry, %if.then.i |
| 60 | ret void, !dbg !50 |
| 61 | } |
| 62 | |
| 63 | ; Function Attrs: noreturn nounwind |
Peter Collingbourne | d4bff30 | 2015-11-05 22:03:56 +0000 | [diff] [blame] | 64 | define void @_Z3fn5v() #3 !dbg !24 { |
Adrian Prantl | 4d36525 | 2015-01-30 01:55:25 +0000 | [diff] [blame] | 65 | entry: |
| 66 | br label %while.body, !dbg !55 |
| 67 | |
| 68 | while.body: ; preds = %entry, %while.body |
| 69 | call void @_Z3fn4v(), !dbg !56 |
| 70 | br label %while.body, !dbg !55 |
| 71 | } |
| 72 | |
| 73 | ; Function Attrs: nounwind readnone |
| 74 | declare void @llvm.dbg.value(metadata, i64, metadata, metadata) #1 |
| 75 | |
| 76 | attributes #0 = { nounwind } |
| 77 | attributes #1 = { nounwind readnone } |
| 78 | attributes #2 = { nounwind } |
| 79 | attributes #3 = { noreturn nounwind } |
| 80 | |
| 81 | !llvm.dbg.cu = !{!0} |
| 82 | !llvm.module.flags = !{!28, !29} |
| 83 | !llvm.ident = !{!30} |
| 84 | |
Adrian Prantl | 75819ae | 2016-04-15 15:57:41 +0000 | [diff] [blame] | 85 | !0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, producer: "clang version 3.7.0 (trunk 227480) (llvm/trunk 227517)", isOptimized: true, emissionKind: FullDebug, file: !1, enums: !2, retainedTypes: !3, globals: !25, imports: !2) |
Duncan P. N. Exon Smith | a9308c4 | 2015-04-29 16:38:44 +0000 | [diff] [blame] | 86 | !1 = !DIFile(filename: "<stdin>", directory: "") |
Adrian Prantl | 4d36525 | 2015-01-30 01:55:25 +0000 | [diff] [blame] | 87 | !2 = !{} |
| 88 | !3 = !{!4} |
Duncan P. N. Exon Smith | a9308c4 | 2015-04-29 16:38:44 +0000 | [diff] [blame] | 89 | !4 = !DICompositeType(tag: DW_TAG_structure_type, name: "A", line: 1, size: 192, align: 64, file: !5, elements: !6, identifier: "_ZTS1A") |
| 90 | !5 = !DIFile(filename: "test.cpp", directory: "") |
Adrian Prantl | 4d36525 | 2015-01-30 01:55:25 +0000 | [diff] [blame] | 91 | !6 = !{!7, !9} |
Duncan P. N. Exon Smith | a59d3e5 | 2016-04-23 21:08:00 +0000 | [diff] [blame] | 92 | !7 = !DIDerivedType(tag: DW_TAG_member, name: "arg0", line: 2, size: 32, align: 32, file: !5, scope: !4, baseType: !8) |
Duncan P. N. Exon Smith | a9308c4 | 2015-04-29 16:38:44 +0000 | [diff] [blame] | 93 | !8 = !DIBasicType(tag: DW_TAG_base_type, name: "int", size: 32, align: 32, encoding: DW_ATE_signed) |
Duncan P. N. Exon Smith | a59d3e5 | 2016-04-23 21:08:00 +0000 | [diff] [blame] | 94 | !9 = !DIDerivedType(tag: DW_TAG_member, name: "arg1", line: 3, size: 128, align: 64, offset: 64, file: !5, scope: !4, baseType: !10) |
Duncan P. N. Exon Smith | a9308c4 | 2015-04-29 16:38:44 +0000 | [diff] [blame] | 95 | !10 = !DICompositeType(tag: DW_TAG_array_type, size: 128, align: 64, baseType: !11, elements: !12) |
| 96 | !11 = !DIBasicType(tag: DW_TAG_base_type, name: "double", size: 64, align: 64, encoding: DW_ATE_float) |
Adrian Prantl | 4d36525 | 2015-01-30 01:55:25 +0000 | [diff] [blame] | 97 | !12 = !{!13} |
Duncan P. N. Exon Smith | a9308c4 | 2015-04-29 16:38:44 +0000 | [diff] [blame] | 98 | !13 = !DISubrange(count: 2) |
Adrian Prantl | 75819ae | 2016-04-15 15:57:41 +0000 | [diff] [blame] | 99 | !15 = distinct !DISubprogram(name: "fn3", linkageName: "_Z3fn31A", line: 6, isLocal: false, isDefinition: true, flags: DIFlagPrototyped, isOptimized: true, unit: !0, scopeLine: 6, file: !5, scope: !16, type: !17, variables: !19) |
Duncan P. N. Exon Smith | a9308c4 | 2015-04-29 16:38:44 +0000 | [diff] [blame] | 100 | !16 = !DIFile(filename: "test.cpp", directory: "") |
| 101 | !17 = !DISubroutineType(types: !18) |
Duncan P. N. Exon Smith | a59d3e5 | 2016-04-23 21:08:00 +0000 | [diff] [blame] | 102 | !18 = !{null, !4} |
Adrian Prantl | 4d36525 | 2015-01-30 01:55:25 +0000 | [diff] [blame] | 103 | !19 = !{!20} |
Duncan P. N. Exon Smith | a59d3e5 | 2016-04-23 21:08:00 +0000 | [diff] [blame] | 104 | !20 = !DILocalVariable(name: "p1", line: 6, arg: 1, scope: !15, file: !16, type: !4) |
Adrian Prantl | 75819ae | 2016-04-15 15:57:41 +0000 | [diff] [blame] | 105 | !21 = distinct !DISubprogram(name: "fn4", linkageName: "_Z3fn4v", line: 11, isLocal: false, isDefinition: true, flags: DIFlagPrototyped, isOptimized: true, unit: !0, scopeLine: 11, file: !5, scope: !16, type: !22, variables: !2) |
Duncan P. N. Exon Smith | a9308c4 | 2015-04-29 16:38:44 +0000 | [diff] [blame] | 106 | !22 = !DISubroutineType(types: !23) |
Adrian Prantl | 4d36525 | 2015-01-30 01:55:25 +0000 | [diff] [blame] | 107 | !23 = !{null} |
Adrian Prantl | 75819ae | 2016-04-15 15:57:41 +0000 | [diff] [blame] | 108 | !24 = distinct !DISubprogram(name: "fn5", linkageName: "_Z3fn5v", line: 13, isLocal: false, isDefinition: true, flags: DIFlagPrototyped, isOptimized: true, unit: !0, scopeLine: 13, file: !5, scope: !16, type: !22, variables: !2) |
Adrian Prantl | 4d36525 | 2015-01-30 01:55:25 +0000 | [diff] [blame] | 109 | !25 = !{!26, !27} |
Duncan P. N. Exon Smith | a59d3e5 | 2016-04-23 21:08:00 +0000 | [diff] [blame] | 110 | !26 = !DIGlobalVariable(name: "a", line: 4, isLocal: false, isDefinition: true, scope: null, file: !16, type: !4, variable: %struct.A* @a) |
| 111 | !27 = !DIGlobalVariable(name: "b", line: 4, isLocal: false, isDefinition: true, scope: null, file: !16, type: !4, variable: %struct.A* @b) |
Adrian Prantl | 4d36525 | 2015-01-30 01:55:25 +0000 | [diff] [blame] | 112 | !28 = !{i32 2, !"Dwarf Version", i32 4} |
Duncan P. N. Exon Smith | e274180 | 2015-03-03 17:24:31 +0000 | [diff] [blame] | 113 | !29 = !{i32 2, !"Debug Info Version", i32 3} |
Adrian Prantl | 4d36525 | 2015-01-30 01:55:25 +0000 | [diff] [blame] | 114 | !30 = !{!"clang version 3.7.0 (trunk 227480) (llvm/trunk 227517)"} |
Duncan P. N. Exon Smith | a9308c4 | 2015-04-29 16:38:44 +0000 | [diff] [blame] | 115 | !31 = !DIExpression(DW_OP_deref) |
| 116 | !32 = !DILocation(line: 6, scope: !15) |
| 117 | !33 = !DILocation(line: 7, scope: !34) |
| 118 | !34 = distinct !DILexicalBlock(line: 7, column: 0, file: !5, scope: !15) |
Adrian Prantl | 4d36525 | 2015-01-30 01:55:25 +0000 | [diff] [blame] | 119 | !35 = !{!36, !37, i64 0} |
Duncan P. N. Exon Smith | a59d3e5 | 2016-04-23 21:08:00 +0000 | [diff] [blame] | 120 | !36 = !{!4, !37, i64 0, !38, i64 8} |
Adrian Prantl | 4d36525 | 2015-01-30 01:55:25 +0000 | [diff] [blame] | 121 | !37 = !{!"int", !38, i64 0} |
| 122 | !38 = !{!"omnipotent char", !39, i64 0} |
| 123 | !39 = !{!"Simple C/C++ TBAA"} |
Duncan P. N. Exon Smith | a9308c4 | 2015-04-29 16:38:44 +0000 | [diff] [blame] | 124 | !40 = !DILocation(line: 7, scope: !15) |
| 125 | !41 = !DILocation(line: 8, scope: !34) |
Adrian Prantl | 4d36525 | 2015-01-30 01:55:25 +0000 | [diff] [blame] | 126 | !42 = !{i64 0, i64 4, !43, i64 8, i64 16, !44} |
| 127 | !43 = !{!37, !37, i64 0} |
| 128 | !44 = !{!38, !38, i64 0} |
Duncan P. N. Exon Smith | a9308c4 | 2015-04-29 16:38:44 +0000 | [diff] [blame] | 129 | !45 = !DILocation(line: 9, scope: !15) |
Duncan P. N. Exon Smith | a59d3e5 | 2016-04-23 21:08:00 +0000 | [diff] [blame] | 130 | !46 = !DILocalVariable(name: "p1", line: 6, arg: 1, scope: !15, file: !16, type: !4) |
Duncan P. N. Exon Smith | a9308c4 | 2015-04-29 16:38:44 +0000 | [diff] [blame] | 131 | !47 = distinct !DILocation(line: 11, scope: !21) |
| 132 | !48 = !DIExpression(DW_OP_bit_piece, 32, 160) |
| 133 | !49 = !DILocation(line: 6, scope: !15, inlinedAt: !47) |
| 134 | !50 = !DILocation(line: 11, scope: !21) |
| 135 | !51 = !DIExpression(DW_OP_bit_piece, 0, 32) |
| 136 | !52 = !DILocation(line: 7, scope: !34, inlinedAt: !47) |
| 137 | !53 = !DILocation(line: 7, scope: !15, inlinedAt: !47) |
| 138 | !54 = !DILocation(line: 8, scope: !34, inlinedAt: !47) |
| 139 | !55 = !DILocation(line: 14, scope: !24) |
| 140 | !56 = !DILocation(line: 15, scope: !24) |