Adrian Prantl | 232897f | 2014-04-25 23:00:25 +0000 | [diff] [blame] | 1 | ; ModuleID = 'array.c' |
| 2 | ; |
| 3 | ; From (clang -g -c -O0): |
| 4 | ; |
| 5 | ; void f(int* p) { |
| 6 | ; p[0] = 42; |
| 7 | ; } |
| 8 | ; |
| 9 | ; int main(int argc, char** argv) { |
| 10 | ; int array[4] = { 0, 1, 2, 3 }; |
| 11 | ; f(array); |
| 12 | ; return array[0]; |
| 13 | ; } |
| 14 | ; |
| 15 | ; RUN: opt %s -O2 -S -o - | FileCheck %s |
Adrian Prantl | 565cc18 | 2015-01-20 19:42:22 +0000 | [diff] [blame] | 16 | ; Test that we correctly lower dbg.declares for arrays. |
Adrian Prantl | 232897f | 2014-04-25 23:00:25 +0000 | [diff] [blame] | 17 | ; |
| 18 | ; CHECK: define i32 @main |
Adrian Prantl | 565cc18 | 2015-01-20 19:42:22 +0000 | [diff] [blame] | 19 | ; CHECK: call void @llvm.dbg.value(metadata i32 42, i64 0, metadata ![[ARRAY:[0-9]+]], metadata ![[EXPR:[0-9]+]]) |
Duncan P. N. Exon Smith | ed013cd | 2015-07-31 18:58:39 +0000 | [diff] [blame] | 20 | ; CHECK: ![[ARRAY]] = !DILocalVariable(name: "array",{{.*}} line: 6 |
Duncan P. N. Exon Smith | a9308c4 | 2015-04-29 16:38:44 +0000 | [diff] [blame] | 21 | ; CHECK: ![[EXPR]] = !DIExpression(DW_OP_bit_piece, 0, 32) |
Adrian Prantl | 232897f | 2014-04-25 23:00:25 +0000 | [diff] [blame] | 22 | target datalayout = "e-m:o-i64:64-f80:128-n8:16:32:64-S128" |
| 23 | target triple = "x86_64-apple-macosx10.9.0" |
| 24 | |
| 25 | @main.array = private unnamed_addr constant [4 x i32] [i32 0, i32 1, i32 2, i32 3], align 16 |
| 26 | |
| 27 | ; Function Attrs: nounwind ssp uwtable |
Peter Collingbourne | d4bff30 | 2015-11-05 22:03:56 +0000 | [diff] [blame] | 28 | define void @f(i32* %p) #0 !dbg !4 { |
Adrian Prantl | 232897f | 2014-04-25 23:00:25 +0000 | [diff] [blame] | 29 | entry: |
| 30 | %p.addr = alloca i32*, align 8 |
| 31 | store i32* %p, i32** %p.addr, align 8 |
Duncan P. N. Exon Smith | a9308c4 | 2015-04-29 16:38:44 +0000 | [diff] [blame] | 32 | call void @llvm.dbg.declare(metadata i32** %p.addr, metadata !19, metadata !DIExpression()), !dbg !20 |
David Blaikie | a79ac14 | 2015-02-27 21:17:42 +0000 | [diff] [blame] | 33 | %0 = load i32*, i32** %p.addr, align 8, !dbg !21 |
David Blaikie | 79e6c74 | 2015-02-27 19:29:02 +0000 | [diff] [blame] | 34 | %arrayidx = getelementptr inbounds i32, i32* %0, i64 0, !dbg !21 |
Adrian Prantl | 232897f | 2014-04-25 23:00:25 +0000 | [diff] [blame] | 35 | store i32 42, i32* %arrayidx, align 4, !dbg !21 |
| 36 | ret void, !dbg !22 |
| 37 | } |
| 38 | |
| 39 | ; Function Attrs: nounwind readnone |
Adrian Prantl | 87b7eb9 | 2014-10-01 18:55:02 +0000 | [diff] [blame] | 40 | declare void @llvm.dbg.declare(metadata, metadata, metadata) #1 |
Adrian Prantl | 232897f | 2014-04-25 23:00:25 +0000 | [diff] [blame] | 41 | |
| 42 | ; Function Attrs: nounwind ssp uwtable |
Peter Collingbourne | d4bff30 | 2015-11-05 22:03:56 +0000 | [diff] [blame] | 43 | define i32 @main(i32 %argc, i8** %argv) #0 !dbg !10 { |
Adrian Prantl | 232897f | 2014-04-25 23:00:25 +0000 | [diff] [blame] | 44 | entry: |
| 45 | %retval = alloca i32, align 4 |
| 46 | %argc.addr = alloca i32, align 4 |
| 47 | %argv.addr = alloca i8**, align 8 |
| 48 | %array = alloca [4 x i32], align 16 |
| 49 | store i32 0, i32* %retval |
| 50 | store i32 %argc, i32* %argc.addr, align 4 |
Duncan P. N. Exon Smith | a9308c4 | 2015-04-29 16:38:44 +0000 | [diff] [blame] | 51 | call void @llvm.dbg.declare(metadata i32* %argc.addr, metadata !23, metadata !DIExpression()), !dbg !24 |
Adrian Prantl | 232897f | 2014-04-25 23:00:25 +0000 | [diff] [blame] | 52 | store i8** %argv, i8*** %argv.addr, align 8 |
Duncan P. N. Exon Smith | a9308c4 | 2015-04-29 16:38:44 +0000 | [diff] [blame] | 53 | call void @llvm.dbg.declare(metadata i8*** %argv.addr, metadata !25, metadata !DIExpression()), !dbg !24 |
| 54 | call void @llvm.dbg.declare(metadata [4 x i32]* %array, metadata !26, metadata !DIExpression()), !dbg !30 |
Adrian Prantl | 232897f | 2014-04-25 23:00:25 +0000 | [diff] [blame] | 55 | %0 = bitcast [4 x i32]* %array to i8*, !dbg !30 |
Pete Cooper | 67cf9a7 | 2015-11-19 05:56:52 +0000 | [diff] [blame] | 56 | call void @llvm.memcpy.p0i8.p0i8.i64(i8* %0, i8* bitcast ([4 x i32]* @main.array to i8*), i64 16, i32 16, i1 false), !dbg !30 |
David Blaikie | 79e6c74 | 2015-02-27 19:29:02 +0000 | [diff] [blame] | 57 | %arraydecay = getelementptr inbounds [4 x i32], [4 x i32]* %array, i32 0, i32 0, !dbg !31 |
Adrian Prantl | 232897f | 2014-04-25 23:00:25 +0000 | [diff] [blame] | 58 | call void @f(i32* %arraydecay), !dbg !31 |
David Blaikie | 79e6c74 | 2015-02-27 19:29:02 +0000 | [diff] [blame] | 59 | %arrayidx = getelementptr inbounds [4 x i32], [4 x i32]* %array, i32 0, i64 0, !dbg !32 |
David Blaikie | a79ac14 | 2015-02-27 21:17:42 +0000 | [diff] [blame] | 60 | %1 = load i32, i32* %arrayidx, align 4, !dbg !32 |
Adrian Prantl | 232897f | 2014-04-25 23:00:25 +0000 | [diff] [blame] | 61 | ret i32 %1, !dbg !32 |
| 62 | } |
| 63 | |
| 64 | ; Function Attrs: nounwind |
Pete Cooper | 67cf9a7 | 2015-11-19 05:56:52 +0000 | [diff] [blame] | 65 | declare void @llvm.memcpy.p0i8.p0i8.i64(i8* nocapture, i8* nocapture readonly, i64, i32, i1) #2 |
Adrian Prantl | 232897f | 2014-04-25 23:00:25 +0000 | [diff] [blame] | 66 | |
| 67 | attributes #0 = { nounwind ssp uwtable } |
| 68 | attributes #1 = { nounwind readnone } |
| 69 | attributes #2 = { nounwind } |
| 70 | |
| 71 | !llvm.dbg.cu = !{!0} |
| 72 | !llvm.module.flags = !{!16, !17} |
| 73 | !llvm.ident = !{!18} |
| 74 | |
Adrian Prantl | 75819ae | 2016-04-15 15:57:41 +0000 | [diff] [blame] | 75 | !0 = distinct !DICompileUnit(language: DW_LANG_C99, 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] | 76 | !1 = !DIFile(filename: "array.c", directory: "") |
Duncan P. N. Exon Smith | be7ea19 | 2014-12-15 19:07:53 +0000 | [diff] [blame] | 77 | !2 = !{} |
Adrian Prantl | 75819ae | 2016-04-15 15:57:41 +0000 | [diff] [blame] | 78 | !4 = distinct !DISubprogram(name: "f", line: 1, isLocal: false, isDefinition: true, virtualIndex: 6, flags: DIFlagPrototyped, isOptimized: false, unit: !0, scopeLine: 1, file: !1, scope: !5, type: !6, variables: !2) |
Duncan P. N. Exon Smith | a9308c4 | 2015-04-29 16:38:44 +0000 | [diff] [blame] | 79 | !5 = !DIFile(filename: "array.c", directory: "") |
| 80 | !6 = !DISubroutineType(types: !7) |
Duncan P. N. Exon Smith | be7ea19 | 2014-12-15 19:07:53 +0000 | [diff] [blame] | 81 | !7 = !{null, !8} |
Duncan P. N. Exon Smith | a9308c4 | 2015-04-29 16:38:44 +0000 | [diff] [blame] | 82 | !8 = !DIDerivedType(tag: DW_TAG_pointer_type, size: 64, align: 64, baseType: !9) |
| 83 | !9 = !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] | 84 | !10 = distinct !DISubprogram(name: "main", line: 5, isLocal: false, isDefinition: true, virtualIndex: 6, flags: DIFlagPrototyped, isOptimized: false, unit: !0, scopeLine: 5, file: !1, scope: !5, type: !11, variables: !2) |
Duncan P. N. Exon Smith | a9308c4 | 2015-04-29 16:38:44 +0000 | [diff] [blame] | 85 | !11 = !DISubroutineType(types: !12) |
Duncan P. N. Exon Smith | be7ea19 | 2014-12-15 19:07:53 +0000 | [diff] [blame] | 86 | !12 = !{!9, !9, !13} |
Duncan P. N. Exon Smith | a9308c4 | 2015-04-29 16:38:44 +0000 | [diff] [blame] | 87 | !13 = !DIDerivedType(tag: DW_TAG_pointer_type, size: 64, align: 64, baseType: !14) |
| 88 | !14 = !DIDerivedType(tag: DW_TAG_pointer_type, size: 64, align: 64, baseType: !15) |
| 89 | !15 = !DIBasicType(tag: DW_TAG_base_type, name: "char", size: 8, align: 8, encoding: DW_ATE_signed_char) |
Duncan P. N. Exon Smith | be7ea19 | 2014-12-15 19:07:53 +0000 | [diff] [blame] | 90 | !16 = !{i32 2, !"Dwarf Version", i32 2} |
Duncan P. N. Exon Smith | e274180 | 2015-03-03 17:24:31 +0000 | [diff] [blame] | 91 | !17 = !{i32 1, !"Debug Info Version", i32 3} |
Duncan P. N. Exon Smith | be7ea19 | 2014-12-15 19:07:53 +0000 | [diff] [blame] | 92 | !18 = !{!"clang version 3.5.0 "} |
Duncan P. N. Exon Smith | ed013cd | 2015-07-31 18:58:39 +0000 | [diff] [blame] | 93 | !19 = !DILocalVariable(name: "p", line: 1, arg: 1, scope: !4, file: !5, type: !8) |
Duncan P. N. Exon Smith | a9308c4 | 2015-04-29 16:38:44 +0000 | [diff] [blame] | 94 | !20 = !DILocation(line: 1, scope: !4) |
| 95 | !21 = !DILocation(line: 2, scope: !4) |
| 96 | !22 = !DILocation(line: 3, scope: !4) |
Duncan P. N. Exon Smith | ed013cd | 2015-07-31 18:58:39 +0000 | [diff] [blame] | 97 | !23 = !DILocalVariable(name: "argc", line: 5, arg: 1, scope: !10, file: !5, type: !9) |
Duncan P. N. Exon Smith | a9308c4 | 2015-04-29 16:38:44 +0000 | [diff] [blame] | 98 | !24 = !DILocation(line: 5, scope: !10) |
Duncan P. N. Exon Smith | ed013cd | 2015-07-31 18:58:39 +0000 | [diff] [blame] | 99 | !25 = !DILocalVariable(name: "argv", line: 5, arg: 2, scope: !10, file: !5, type: !13) |
| 100 | !26 = !DILocalVariable(name: "array", line: 6, scope: !10, file: !5, type: !27) |
Duncan P. N. Exon Smith | a9308c4 | 2015-04-29 16:38:44 +0000 | [diff] [blame] | 101 | !27 = !DICompositeType(tag: DW_TAG_array_type, size: 128, align: 32, baseType: !9, elements: !28) |
Duncan P. N. Exon Smith | be7ea19 | 2014-12-15 19:07:53 +0000 | [diff] [blame] | 102 | !28 = !{!29} |
Duncan P. N. Exon Smith | a9308c4 | 2015-04-29 16:38:44 +0000 | [diff] [blame] | 103 | !29 = !DISubrange(count: 4) |
| 104 | !30 = !DILocation(line: 6, scope: !10) |
| 105 | !31 = !DILocation(line: 7, scope: !10) |
| 106 | !32 = !DILocation(line: 8, scope: !10) |