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 <- [R{{.*}}+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 { 28 tail call void @llvm.dbg.value(metadata i32* %p, i64 0, metadata !11, metadata !MDExpression()), !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 { 35 %array = alloca [4 x i32], align 16 36 tail call void @llvm.dbg.value(metadata i32 %argc, i64 0, metadata !19, metadata !MDExpression()), !dbg !35 37 tail call void @llvm.dbg.value(metadata i8** %argv, i64 0, metadata !20, metadata !MDExpression()), !dbg !35 38 tail call void @llvm.dbg.value(metadata [4 x i32]* %array, i64 0, metadata !21, metadata !MDExpression()), !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 !MDExpression()), !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 !MDExpression()), !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 = !MDCompileUnit(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) 64!1 = !MDFile(filename: "array.c", directory: "") 65!2 = !{} 66!3 = !{!4, !12} 67!4 = !MDSubprogram(name: "f", line: 1, isLocal: false, isDefinition: true, virtualIndex: 6, flags: DIFlagPrototyped, isOptimized: true, scopeLine: 1, file: !1, scope: !5, type: !6, function: void (i32*)* @f, variables: !10) 68!5 = !MDFile(filename: "array.c", directory: "") 69!6 = !MDSubroutineType(types: !7) 70!7 = !{null, !8} 71!8 = !MDDerivedType(tag: DW_TAG_pointer_type, size: 64, align: 64, baseType: !9) 72!9 = !MDBasicType(tag: DW_TAG_base_type, name: "int", size: 32, align: 32, encoding: DW_ATE_signed) 73!10 = !{!11} 74!11 = !MDLocalVariable(tag: DW_TAG_arg_variable, name: "p", line: 1, arg: 1, scope: !4, file: !5, type: !8) 75!12 = !MDSubprogram(name: "main", line: 5, isLocal: false, isDefinition: true, virtualIndex: 6, flags: DIFlagPrototyped, isOptimized: true, scopeLine: 5, file: !1, scope: !5, type: !13, function: i32 (i32, i8**)* @main, variables: !18) 76!13 = !MDSubroutineType(types: !14) 77!14 = !{!9, !9, !15} 78!15 = !MDDerivedType(tag: DW_TAG_pointer_type, size: 64, align: 64, baseType: !16) 79!16 = !MDDerivedType(tag: DW_TAG_pointer_type, size: 64, align: 64, baseType: !17) 80!17 = !MDBasicType(tag: DW_TAG_base_type, name: "char", size: 8, align: 8, encoding: DW_ATE_signed_char) 81!18 = !{!19, !20, !21} 82!19 = !MDLocalVariable(tag: DW_TAG_arg_variable, name: "argc", line: 5, arg: 1, scope: !12, file: !5, type: !9) 83!20 = !MDLocalVariable(tag: DW_TAG_arg_variable, name: "argv", line: 5, arg: 2, scope: !12, file: !5, type: !15) 84!21 = !MDLocalVariable(tag: DW_TAG_auto_variable, name: "array", line: 6, scope: !12, file: !5, type: !22) 85!22 = !MDCompositeType(tag: DW_TAG_array_type, size: 128, align: 32, baseType: !9, elements: !23) 86!23 = !{!24} 87!24 = !MDSubrange(count: 4) 88!25 = !{i32 2, !"Dwarf Version", i32 2} 89!26 = !{i32 1, !"Debug Info Version", i32 3} 90!27 = !{!"clang version 3.5.0 "} 91!28 = !MDLocation(line: 1, scope: !4) 92!29 = !MDLocation(line: 2, scope: !4) 93!30 = !{!31, !31, i64 0} 94!31 = !{!"int", !32, i64 0} 95!32 = !{!"omnipotent char", !33, i64 0} 96!33 = !{!"Simple C/C++ TBAA"} 97!34 = !MDLocation(line: 3, scope: !4) 98!35 = !MDLocation(line: 5, scope: !12) 99!36 = !MDLocation(line: 6, scope: !12) 100!37 = !MDLocation(line: 7, scope: !12) 101!38 = !MDLocation(line: 8, scope: !12) 102