Home | History | Annotate | Download | only in X86
      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:     ##DEBUG_VALUE: main:array <- [%R{{.*}}+0]
     21 ; CHECK:     ##DEBUG_VALUE: main:array <- [%R{{.*}}+0]
     22 ; CHECK-NOT: ##DEBUG_VALUE: main:array <- %R{{.*}}
     23 target datalayout = "e-m:o-i64:64-f80:128-n8:16:32:64-S128"
     24 target triple = "x86_64-apple-macosx10.9.0"
     25 
     26 @main.array = private unnamed_addr constant [4 x i32] [i32 0, i32 1, i32 2, i32 3], align 16
     27 
     28 ; Function Attrs: nounwind ssp uwtable
     29 define void @f(i32* nocapture %p) #0 !dbg !4 {
     30   tail call void @llvm.dbg.value(metadata i32* %p, i64 0, metadata !11, metadata !DIExpression()), !dbg !28
     31   store i32 42, i32* %p, align 4, !dbg !29, !tbaa !30
     32   ret void, !dbg !34
     33 }
     34 
     35 ; Function Attrs: nounwind ssp uwtable
     36 define i32 @main(i32 %argc, i8** nocapture readnone %argv) #0 !dbg !12 {
     37   %array = alloca [4 x i32], align 16
     38   tail call void @llvm.dbg.value(metadata i32 %argc, i64 0, metadata !19, metadata !DIExpression()), !dbg !35
     39   tail call void @llvm.dbg.value(metadata i8** %argv, i64 0, metadata !20, metadata !DIExpression()), !dbg !35
     40   tail call void @llvm.dbg.value(metadata [4 x i32]* %array, i64 0, metadata !21, metadata !DIExpression(DW_OP_deref)), !dbg !36
     41   %1 = bitcast [4 x i32]* %array to i8*, !dbg !36
     42   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
     43   tail call void @llvm.dbg.value(metadata [4 x i32]* %array, i64 0, metadata !21, metadata !DIExpression(DW_OP_deref)), !dbg !36
     44   %2 = getelementptr inbounds [4 x i32], [4 x i32]* %array, i64 0, i64 0, !dbg !37
     45   call void @f(i32* %2), !dbg !37
     46   tail call void @llvm.dbg.value(metadata [4 x i32]* %array, i64 0, metadata !21, metadata !DIExpression(DW_OP_deref)), !dbg !36
     47   %3 = load i32, i32* %2, align 16, !dbg !38, !tbaa !30
     48   ret i32 %3, !dbg !38
     49 }
     50 
     51 ; Function Attrs: nounwind
     52 declare void @llvm.memcpy.p0i8.p0i8.i64(i8* nocapture, i8* nocapture readonly, i64, i32, i1) #1
     53 
     54 ; Function Attrs: nounwind readnone
     55 declare void @llvm.dbg.value(metadata, i64, metadata, metadata) #2
     56 
     57 attributes #0 = { nounwind ssp uwtable }
     58 attributes #1 = { nounwind }
     59 attributes #2 = { nounwind readnone }
     60 
     61 !llvm.dbg.cu = !{!0}
     62 !llvm.module.flags = !{!25, !26}
     63 !llvm.ident = !{!27}
     64 
     65 !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)
     66 !1 = !DIFile(filename: "array.c", directory: "")
     67 !2 = !{}
     68 !3 = !{!4, !12}
     69 !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)
     70 !5 = !DIFile(filename: "array.c", directory: "")
     71 !6 = !DISubroutineType(types: !7)
     72 !7 = !{null, !8}
     73 !8 = !DIDerivedType(tag: DW_TAG_pointer_type, size: 64, align: 64, baseType: !9)
     74 !9 = !DIBasicType(tag: DW_TAG_base_type, name: "int", size: 32, align: 32, encoding: DW_ATE_signed)
     75 !10 = !{!11}
     76 !11 = !DILocalVariable(name: "p", line: 1, arg: 1, scope: !4, file: !5, type: !8)
     77 !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)
     78 !13 = !DISubroutineType(types: !14)
     79 !14 = !{!9, !9, !15}
     80 !15 = !DIDerivedType(tag: DW_TAG_pointer_type, size: 64, align: 64, baseType: !16)
     81 !16 = !DIDerivedType(tag: DW_TAG_pointer_type, size: 64, align: 64, baseType: !17)
     82 !17 = !DIBasicType(tag: DW_TAG_base_type, name: "char", size: 8, align: 8, encoding: DW_ATE_signed_char)
     83 !18 = !{!19, !20, !21}
     84 !19 = !DILocalVariable(name: "argc", line: 5, arg: 1, scope: !12, file: !5, type: !9)
     85 !20 = !DILocalVariable(name: "argv", line: 5, arg: 2, scope: !12, file: !5, type: !15)
     86 !21 = !DILocalVariable(name: "array", line: 6, scope: !12, file: !5, type: !22)
     87 !22 = !DICompositeType(tag: DW_TAG_array_type, size: 128, align: 32, baseType: !9, elements: !23)
     88 !23 = !{!24}
     89 !24 = !DISubrange(count: 4)
     90 !25 = !{i32 2, !"Dwarf Version", i32 2}
     91 !26 = !{i32 1, !"Debug Info Version", i32 3}
     92 !27 = !{!"clang version 3.5.0 "}
     93 !28 = !DILocation(line: 1, scope: !4)
     94 !29 = !DILocation(line: 2, scope: !4)
     95 !30 = !{!31, !31, i64 0}
     96 !31 = !{!"int", !32, i64 0}
     97 !32 = !{!"omnipotent char", !33, i64 0}
     98 !33 = !{!"Simple C/C++ TBAA"}
     99 !34 = !DILocation(line: 3, scope: !4)
    100 !35 = !DILocation(line: 5, scope: !12)
    101 !36 = !DILocation(line: 6, scope: !12)
    102 !37 = !DILocation(line: 7, scope: !12)
    103 !38 = !DILocation(line: 8, scope: !12)
    104