blob: a50a44cfb954b82f139e99fdf3d9e7779c5d0c71 [file] [log] [blame]
Adrian Prantl32da8892014-04-25 20:49:25 +00001; ModuleID = 'array.c'
2;
3; From (clang -g -c -O1):
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: llc -filetype=asm %s -o - | FileCheck %s
16; Test that we only emit register-indirect locations for the array array.
17; rdar://problem/14874886
18;
Dan Gohman6c1b0b92015-11-17 16:15:11 +000019; CHECK: ##DEBUG_VALUE: main:array <- [%R{{.*}}+0]
20; CHECK-NOT: ##DEBUG_VALUE: main:array <- %R{{.*}}
Adrian Prantl32da8892014-04-25 20:49:25 +000021target datalayout = "e-m:o-i64:64-f80:128-n8:16:32:64-S128"
22target triple = "x86_64-apple-macosx10.9.0"
23
24@main.array = private unnamed_addr constant [4 x i32] [i32 0, i32 1, i32 2, i32 3], align 16
25
26; Function Attrs: nounwind ssp uwtable
Peter Collingbourned4bff302015-11-05 22:03:56 +000027define void @f(i32* nocapture %p) #0 !dbg !4 {
Duncan P. N. Exon Smitha9308c42015-04-29 16:38:44 +000028 tail call void @llvm.dbg.value(metadata i32* %p, i64 0, metadata !11, metadata !DIExpression()), !dbg !28
Adrian Prantl32da8892014-04-25 20:49:25 +000029 store i32 42, i32* %p, align 4, !dbg !29, !tbaa !30
30 ret void, !dbg !34
31}
32
33; Function Attrs: nounwind ssp uwtable
Peter Collingbourned4bff302015-11-05 22:03:56 +000034define i32 @main(i32 %argc, i8** nocapture readnone %argv) #0 !dbg !12 {
Adrian Prantl32da8892014-04-25 20:49:25 +000035 %array = alloca [4 x i32], align 16
Duncan P. N. Exon Smitha9308c42015-04-29 16:38:44 +000036 tail call void @llvm.dbg.value(metadata i32 %argc, i64 0, metadata !19, metadata !DIExpression()), !dbg !35
37 tail call void @llvm.dbg.value(metadata i8** %argv, i64 0, metadata !20, metadata !DIExpression()), !dbg !35
38 tail call void @llvm.dbg.value(metadata [4 x i32]* %array, i64 0, metadata !21, metadata !DIExpression()), !dbg !36
Adrian Prantl32da8892014-04-25 20:49:25 +000039 %1 = bitcast [4 x i32]* %array to i8*, !dbg !36
40 call void @llvm.memcpy.p0i8.p0i8.i64(i8* %1, i8* bitcast ([4 x i32]* @main.array to i8*), i64 16, i32 16, i1 false), !dbg !36
Duncan P. N. Exon Smitha9308c42015-04-29 16:38:44 +000041 tail call void @llvm.dbg.value(metadata [4 x i32]* %array, i64 0, metadata !21, metadata !DIExpression()), !dbg !36
David Blaikie79e6c742015-02-27 19:29:02 +000042 %2 = getelementptr inbounds [4 x i32], [4 x i32]* %array, i64 0, i64 0, !dbg !37
Adrian Prantl32da8892014-04-25 20:49:25 +000043 call void @f(i32* %2), !dbg !37
Duncan P. N. Exon Smitha9308c42015-04-29 16:38:44 +000044 tail call void @llvm.dbg.value(metadata [4 x i32]* %array, i64 0, metadata !21, metadata !DIExpression()), !dbg !36
David Blaikiea79ac142015-02-27 21:17:42 +000045 %3 = load i32, i32* %2, align 16, !dbg !38, !tbaa !30
Adrian Prantl32da8892014-04-25 20:49:25 +000046 ret i32 %3, !dbg !38
47}
48
49; Function Attrs: nounwind
50declare void @llvm.memcpy.p0i8.p0i8.i64(i8* nocapture, i8* nocapture readonly, i64, i32, i1) #1
51
52; Function Attrs: nounwind readnone
Adrian Prantl87b7eb92014-10-01 18:55:02 +000053declare void @llvm.dbg.value(metadata, i64, metadata, metadata) #2
Adrian Prantl32da8892014-04-25 20:49:25 +000054
55attributes #0 = { nounwind ssp uwtable }
56attributes #1 = { nounwind }
57attributes #2 = { nounwind readnone }
58
59!llvm.dbg.cu = !{!0}
60!llvm.module.flags = !{!25, !26}
61!llvm.ident = !{!27}
62
Duncan P. N. Exon Smith55ca9642015-08-03 17:26:41 +000063!0 = distinct !DICompileUnit(language: DW_LANG_C99, producer: "clang version 3.5.0 ", isOptimized: true, emissionKind: 1, file: !1, enums: !2, retainedTypes: !2, subprograms: !3, globals: !2, imports: !2)
Duncan P. N. Exon Smitha9308c42015-04-29 16:38:44 +000064!1 = !DIFile(filename: "array.c", directory: "")
Duncan P. N. Exon Smithbe7ea192014-12-15 19:07:53 +000065!2 = !{}
66!3 = !{!4, !12}
Peter Collingbourned4bff302015-11-05 22:03:56 +000067!4 = distinct !DISubprogram(name: "f", line: 1, isLocal: false, isDefinition: true, virtualIndex: 6, flags: DIFlagPrototyped, isOptimized: true, scopeLine: 1, file: !1, scope: !5, type: !6, variables: !10)
Duncan P. N. Exon Smitha9308c42015-04-29 16:38:44 +000068!5 = !DIFile(filename: "array.c", directory: "")
69!6 = !DISubroutineType(types: !7)
Duncan P. N. Exon Smithbe7ea192014-12-15 19:07:53 +000070!7 = !{null, !8}
Duncan P. N. Exon Smitha9308c42015-04-29 16:38:44 +000071!8 = !DIDerivedType(tag: DW_TAG_pointer_type, size: 64, align: 64, baseType: !9)
72!9 = !DIBasicType(tag: DW_TAG_base_type, name: "int", size: 32, align: 32, encoding: DW_ATE_signed)
Duncan P. N. Exon Smithbe7ea192014-12-15 19:07:53 +000073!10 = !{!11}
Duncan P. N. Exon Smithed013cd2015-07-31 18:58:39 +000074!11 = !DILocalVariable(name: "p", line: 1, arg: 1, scope: !4, file: !5, type: !8)
Peter Collingbourned4bff302015-11-05 22:03:56 +000075!12 = distinct !DISubprogram(name: "main", line: 5, isLocal: false, isDefinition: true, virtualIndex: 6, flags: DIFlagPrototyped, isOptimized: true, scopeLine: 5, file: !1, scope: !5, type: !13, variables: !18)
Duncan P. N. Exon Smitha9308c42015-04-29 16:38:44 +000076!13 = !DISubroutineType(types: !14)
Duncan P. N. Exon Smithbe7ea192014-12-15 19:07:53 +000077!14 = !{!9, !9, !15}
Duncan P. N. Exon Smitha9308c42015-04-29 16:38:44 +000078!15 = !DIDerivedType(tag: DW_TAG_pointer_type, size: 64, align: 64, baseType: !16)
79!16 = !DIDerivedType(tag: DW_TAG_pointer_type, size: 64, align: 64, baseType: !17)
80!17 = !DIBasicType(tag: DW_TAG_base_type, name: "char", size: 8, align: 8, encoding: DW_ATE_signed_char)
Duncan P. N. Exon Smithbe7ea192014-12-15 19:07:53 +000081!18 = !{!19, !20, !21}
Duncan P. N. Exon Smithed013cd2015-07-31 18:58:39 +000082!19 = !DILocalVariable(name: "argc", line: 5, arg: 1, scope: !12, file: !5, type: !9)
83!20 = !DILocalVariable(name: "argv", line: 5, arg: 2, scope: !12, file: !5, type: !15)
84!21 = !DILocalVariable(name: "array", line: 6, scope: !12, file: !5, type: !22)
Duncan P. N. Exon Smitha9308c42015-04-29 16:38:44 +000085!22 = !DICompositeType(tag: DW_TAG_array_type, size: 128, align: 32, baseType: !9, elements: !23)
Duncan P. N. Exon Smithbe7ea192014-12-15 19:07:53 +000086!23 = !{!24}
Duncan P. N. Exon Smitha9308c42015-04-29 16:38:44 +000087!24 = !DISubrange(count: 4)
Duncan P. N. Exon Smithbe7ea192014-12-15 19:07:53 +000088!25 = !{i32 2, !"Dwarf Version", i32 2}
Duncan P. N. Exon Smithe2741802015-03-03 17:24:31 +000089!26 = !{i32 1, !"Debug Info Version", i32 3}
Duncan P. N. Exon Smithbe7ea192014-12-15 19:07:53 +000090!27 = !{!"clang version 3.5.0 "}
Duncan P. N. Exon Smitha9308c42015-04-29 16:38:44 +000091!28 = !DILocation(line: 1, scope: !4)
92!29 = !DILocation(line: 2, scope: !4)
Duncan P. N. Exon Smithbe7ea192014-12-15 19:07:53 +000093!30 = !{!31, !31, i64 0}
94!31 = !{!"int", !32, i64 0}
95!32 = !{!"omnipotent char", !33, i64 0}
96!33 = !{!"Simple C/C++ TBAA"}
Duncan P. N. Exon Smitha9308c42015-04-29 16:38:44 +000097!34 = !DILocation(line: 3, scope: !4)
98!35 = !DILocation(line: 5, scope: !12)
99!36 = !DILocation(line: 6, scope: !12)
100!37 = !DILocation(line: 7, scope: !12)
101!38 = !DILocation(line: 8, scope: !12)