blob: 78dc12b4d3773fd31b47242cd2b49b7f13c82af3 [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-NOT: ##DEBUG_VALUE: main:array <- %R{{.*}}
Adrian Prantlf0621922017-05-25 18:54:10 +000020; CHECK: movq %rsp, %rdi
21; CHECK-NOT: ##DEBUG_VALUE: main:array <- %R{{.*}}
22; CHECK: ##DEBUG_VALUE: main:array <- [%RDI+0]
23; CHECK-NOT: ##DEBUG_VALUE: main:array <- %R{{.*}}
24; ModuleID = '/tmp/array.c'
25source_filename = "/tmp/array.c"
Adrian Prantl32da8892014-04-25 20:49:25 +000026target datalayout = "e-m:o-i64:64-f80:128-n8:16:32:64-S128"
Adrian Prantlf0621922017-05-25 18:54:10 +000027target triple = "x86_64-apple-macosx10.12.0"
Adrian Prantl32da8892014-04-25 20:49:25 +000028
29@main.array = private unnamed_addr constant [4 x i32] [i32 0, i32 1, i32 2, i32 3], align 16
30
31; Function Attrs: nounwind ssp uwtable
Adrian Prantlf0621922017-05-25 18:54:10 +000032define void @f(i32* nocapture %p) local_unnamed_addr #0 !dbg !8 {
33entry:
34 tail call void @llvm.dbg.value(metadata i32* %p, i64 0, metadata !14, metadata !15), !dbg !16
35 store i32 42, i32* %p, align 4, !dbg !17, !tbaa !18
36 ret void, !dbg !22
Adrian Prantl32da8892014-04-25 20:49:25 +000037}
38
Adrian Prantlf0621922017-05-25 18:54:10 +000039; Function Attrs: nounwind readnone speculatable
40declare void @llvm.dbg.declare(metadata, metadata, metadata) #1
41
Adrian Prantl32da8892014-04-25 20:49:25 +000042; Function Attrs: nounwind ssp uwtable
Adrian Prantlf0621922017-05-25 18:54:10 +000043define i32 @main(i32 %argc, i8** nocapture readnone %argv) local_unnamed_addr #0 !dbg !23 {
44entry:
Adrian Prantl32da8892014-04-25 20:49:25 +000045 %array = alloca [4 x i32], align 16
Adrian Prantlf0621922017-05-25 18:54:10 +000046 tail call void @llvm.dbg.value(metadata i32 %argc, i64 0, metadata !30, metadata !15), !dbg !36
47 tail call void @llvm.dbg.value(metadata i8** %argv, i64 0, metadata !31, metadata !15), !dbg !37
48 %0 = bitcast [4 x i32]* %array to i8*, !dbg !38
49 call void @llvm.lifetime.start.p0i8(i64 16, i8* nonnull %0) #3, !dbg !38
50 tail call void @llvm.dbg.declare(metadata [4 x i32]* %array, metadata !32, metadata !15), !dbg !39
51 call void @llvm.memcpy.p0i8.p0i8.i64(i8* nonnull %0, i8* bitcast ([4 x i32]* @main.array to i8*), i64 16, i32 16, i1 false), !dbg !39
52 %arraydecay = getelementptr inbounds [4 x i32], [4 x i32]* %array, i64 0, i64 0, !dbg !40
53 call void @f(i32* nonnull %arraydecay), !dbg !41
54 %1 = load i32, i32* %arraydecay, align 16, !dbg !42, !tbaa !18
55 call void @llvm.lifetime.end.p0i8(i64 16, i8* nonnull %0) #3, !dbg !43
56 ret i32 %1, !dbg !44
Adrian Prantl32da8892014-04-25 20:49:25 +000057}
58
Adrian Prantlf0621922017-05-25 18:54:10 +000059; Function Attrs: argmemonly nounwind
60declare void @llvm.lifetime.start.p0i8(i64, i8* nocapture) #2
Adrian Prantl32da8892014-04-25 20:49:25 +000061
Adrian Prantlf0621922017-05-25 18:54:10 +000062; Function Attrs: argmemonly nounwind
63declare void @llvm.memcpy.p0i8.p0i8.i64(i8* nocapture writeonly, i8* nocapture readonly, i64, i32, i1) #2
64
65; Function Attrs: argmemonly nounwind
66declare void @llvm.lifetime.end.p0i8(i64, i8* nocapture) #2
67
68; Function Attrs: nounwind readnone speculatable
69declare void @llvm.dbg.value(metadata, i64, metadata, metadata) #1
Adrian Prantl32da8892014-04-25 20:49:25 +000070
71attributes #0 = { nounwind ssp uwtable }
Adrian Prantlf0621922017-05-25 18:54:10 +000072attributes #1 = { nounwind readnone speculatable }
73attributes #2 = { argmemonly nounwind }
74attributes #3 = { nounwind }
Adrian Prantl32da8892014-04-25 20:49:25 +000075
76!llvm.dbg.cu = !{!0}
Adrian Prantlf0621922017-05-25 18:54:10 +000077!llvm.module.flags = !{!3, !4, !5, !6}
78!llvm.ident = !{!7}
Adrian Prantl32da8892014-04-25 20:49:25 +000079
Adrian Prantlf0621922017-05-25 18:54:10 +000080!0 = distinct !DICompileUnit(language: DW_LANG_C99, file: !1, producer: "clang version 5.0.0 (trunk 303873) (llvm/trunk 303875)", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, enums: !2)
81!1 = !DIFile(filename: "/tmp/array.c", directory: "/")
Duncan P. N. Exon Smithbe7ea192014-12-15 19:07:53 +000082!2 = !{}
Adrian Prantlf0621922017-05-25 18:54:10 +000083!3 = !{i32 2, !"Dwarf Version", i32 4}
84!4 = !{i32 2, !"Debug Info Version", i32 3}
85!5 = !{i32 1, !"wchar_size", i32 4}
86!6 = !{i32 7, !"PIC Level", i32 2}
87!7 = !{!"clang version 5.0.0 (trunk 303873) (llvm/trunk 303875)"}
88!8 = distinct !DISubprogram(name: "f", scope: !1, file: !1, line: 1, type: !9, isLocal: false, isDefinition: true, scopeLine: 1, flags: DIFlagPrototyped, isOptimized: true, unit: !0, variables: !13)
89!9 = !DISubroutineType(types: !10)
90!10 = !{null, !11}
91!11 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !12, size: 64)
92!12 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)
93!13 = !{!14}
94!14 = !DILocalVariable(name: "p", arg: 1, scope: !8, file: !1, line: 1, type: !11)
95!15 = !DIExpression()
96!16 = !DILocation(line: 1, column: 13, scope: !8)
97!17 = !DILocation(line: 2, column: 8, scope: !8)
98!18 = !{!19, !19, i64 0}
99!19 = !{!"int", !20, i64 0}
100!20 = !{!"omnipotent char", !21, i64 0}
101!21 = !{!"Simple C/C++ TBAA"}
102!22 = !DILocation(line: 3, column: 1, scope: !8)
103!23 = distinct !DISubprogram(name: "main", scope: !1, file: !1, line: 5, type: !24, isLocal: false, isDefinition: true, scopeLine: 5, flags: DIFlagPrototyped, isOptimized: true, unit: !0, variables: !29)
104!24 = !DISubroutineType(types: !25)
105!25 = !{!12, !12, !26}
106!26 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !27, size: 64)
107!27 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !28, size: 64)
108!28 = !DIBasicType(name: "char", size: 8, encoding: DW_ATE_signed_char)
109!29 = !{!30, !31, !32}
110!30 = !DILocalVariable(name: "argc", arg: 1, scope: !23, file: !1, line: 5, type: !12)
111!31 = !DILocalVariable(name: "argv", arg: 2, scope: !23, file: !1, line: 5, type: !26)
112!32 = !DILocalVariable(name: "array", scope: !23, file: !1, line: 6, type: !33)
113!33 = !DICompositeType(tag: DW_TAG_array_type, baseType: !12, size: 128, elements: !34)
114!34 = !{!35}
115!35 = !DISubrange(count: 4)
116!36 = !DILocation(line: 5, column: 14, scope: !23)
117!37 = !DILocation(line: 5, column: 27, scope: !23)
118!38 = !DILocation(line: 6, column: 3, scope: !23)
119!39 = !DILocation(line: 6, column: 7, scope: !23)
120!40 = !DILocation(line: 7, column: 5, scope: !23)
121!41 = !DILocation(line: 7, column: 3, scope: !23)
122!42 = !DILocation(line: 8, column: 10, scope: !23)
123!43 = !DILocation(line: 9, column: 1, scope: !23)
124!44 = !DILocation(line: 8, column: 3, scope: !23)