1; 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;
19; CHECK:     ##DEBUG_VALUE: main:array <- [%RSP+0]
20; CHECK-NOT: ##DEBUG_VALUE: main:array <- %R{{.*}}
21target 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
27define void @f(i32* nocapture %p) #0 !dbg !4 {
28  tail call void @llvm.dbg.value(metadata i32* %p, i64 0, metadata !11, metadata !DIExpression()), !dbg !28
29  store i32 42, i32* %p, align 4, !dbg !29, !tbaa !30
30  ret void, !dbg !34
31}
32
33; Function Attrs: nounwind ssp uwtable
34define i32 @main(i32 %argc, i8** nocapture readnone %argv) #0 !dbg !12 {
35  %array = alloca [4 x i32], align 16
36  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(DW_OP_deref)), !dbg !36
39  %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
41  tail call void @llvm.dbg.value(metadata [4 x i32]* %array, i64 0, metadata !21, metadata !DIExpression(DW_OP_deref)), !dbg !36
42  %2 = getelementptr inbounds [4 x i32], [4 x i32]* %array, i64 0, i64 0, !dbg !37
43  call void @f(i32* %2), !dbg !37
44  tail call void @llvm.dbg.value(metadata [4 x i32]* %array, i64 0, metadata !21, metadata !DIExpression(DW_OP_deref)), !dbg !36
45  %3 = load i32, i32* %2, align 16, !dbg !38, !tbaa !30
46  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
53declare void @llvm.dbg.value(metadata, i64, metadata, metadata) #2
54
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
63!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)
64!1 = !DIFile(filename: "array.c", directory: "")
65!2 = !{}
66!4 = distinct !DISubprogram(name: "f", line: 1, isLocal: false, isDefinition: true, virtualIndex: 6, flags: DIFlagPrototyped, isOptimized: true, unit: !0, scopeLine: 1, file: !1, scope: !5, type: !6, variables: !10)
67!5 = !DIFile(filename: "array.c", directory: "")
68!6 = !DISubroutineType(types: !7)
69!7 = !{null, !8}
70!8 = !DIDerivedType(tag: DW_TAG_pointer_type, size: 64, align: 64, baseType: !9)
71!9 = !DIBasicType(tag: DW_TAG_base_type, name: "int", size: 32, align: 32, encoding: DW_ATE_signed)
72!10 = !{!11}
73!11 = !DILocalVariable(name: "p", line: 1, arg: 1, scope: !4, file: !5, type: !8)
74!12 = distinct !DISubprogram(name: "main", line: 5, isLocal: false, isDefinition: true, virtualIndex: 6, flags: DIFlagPrototyped, isOptimized: true, unit: !0, scopeLine: 5, file: !1, scope: !5, type: !13, variables: !18)
75!13 = !DISubroutineType(types: !14)
76!14 = !{!9, !9, !15}
77!15 = !DIDerivedType(tag: DW_TAG_pointer_type, size: 64, align: 64, baseType: !16)
78!16 = !DIDerivedType(tag: DW_TAG_pointer_type, size: 64, align: 64, baseType: !17)
79!17 = !DIBasicType(tag: DW_TAG_base_type, name: "char", size: 8, align: 8, encoding: DW_ATE_signed_char)
80!18 = !{!19, !20, !21}
81!19 = !DILocalVariable(name: "argc", line: 5, arg: 1, scope: !12, file: !5, type: !9)
82!20 = !DILocalVariable(name: "argv", line: 5, arg: 2, scope: !12, file: !5, type: !15)
83!21 = !DILocalVariable(name: "array", line: 6, scope: !12, file: !5, type: !22)
84!22 = !DICompositeType(tag: DW_TAG_array_type, size: 128, align: 32, baseType: !9, elements: !23)
85!23 = !{!24}
86!24 = !DISubrange(count: 4)
87!25 = !{i32 2, !"Dwarf Version", i32 2}
88!26 = !{i32 1, !"Debug Info Version", i32 3}
89!27 = !{!"clang version 3.5.0 "}
90!28 = !DILocation(line: 1, scope: !4)
91!29 = !DILocation(line: 2, scope: !4)
92!30 = !{!31, !31, i64 0}
93!31 = !{!"int", !32, i64 0}
94!32 = !{!"omnipotent char", !33, i64 0}
95!33 = !{!"Simple C/C++ TBAA"}
96!34 = !DILocation(line: 3, scope: !4)
97!35 = !DILocation(line: 5, scope: !12)
98!36 = !DILocation(line: 6, scope: !12)
99!37 = !DILocation(line: 7, scope: !12)
100!38 = !DILocation(line: 8, scope: !12)
101