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 ; RUN: llc -filetype=obj %s -o - | llvm-dwarfdump -v - ---debug-info | FileCheck %s --check-prefix=DWARF
     17 
     18 ; CHECK-LABEL: _main:
     19 ; CHECK: movaps {{.*}}, (%rsp)
     20 ; CHECK: movq    %rsp, %rdi
     21 ; CHECK: callq _f
     22 
     23 ; DWARF: DW_TAG_variable
     24 ; DWARF-NEXT:              DW_AT_location [DW_FORM_exprloc]      (DW_OP_fbreg +0)
     25 ; DWARF-NEXT:              DW_AT_name [DW_FORM_strp]     ( {{.*}} = "array")
     26 
     27 ; ModuleID = '/tmp/array.c'
     28 source_filename = "/tmp/array.c"
     29 target datalayout = "e-m:o-i64:64-f80:128-n8:16:32:64-S128"
     30 target triple = "x86_64-apple-macosx10.12.0"
     31 
     32 @main.array = private unnamed_addr constant [4 x i32] [i32 0, i32 1, i32 2, i32 3], align 16
     33 
     34 ; Function Attrs: nounwind ssp uwtable
     35 define void @f(i32* nocapture %p) local_unnamed_addr #0 !dbg !8 {
     36 entry:
     37   tail call void @llvm.dbg.value(metadata i32* %p, metadata !14, metadata !15), !dbg !16
     38   store i32 42, i32* %p, align 4, !dbg !17, !tbaa !18
     39   ret void, !dbg !22
     40 }
     41 
     42 ; Function Attrs: nounwind readnone speculatable
     43 declare void @llvm.dbg.declare(metadata, metadata, metadata) #1
     44 
     45 ; Function Attrs: nounwind ssp uwtable
     46 define i32 @main(i32 %argc, i8** nocapture readnone %argv) local_unnamed_addr #0 !dbg !23 {
     47 entry:
     48   %array = alloca [4 x i32], align 16
     49   tail call void @llvm.dbg.value(metadata i32 %argc, metadata !30, metadata !15), !dbg !36
     50   tail call void @llvm.dbg.value(metadata i8** %argv, metadata !31, metadata !15), !dbg !37
     51   %0 = bitcast [4 x i32]* %array to i8*, !dbg !38
     52   call void @llvm.lifetime.start.p0i8(i64 16, i8* nonnull %0) #3, !dbg !38
     53   tail call void @llvm.dbg.declare(metadata [4 x i32]* %array, metadata !32, metadata !15), !dbg !39
     54   call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 16 nonnull %0, i8* align 16 bitcast ([4 x i32]* @main.array to i8*), i64 16, i1 false), !dbg !39
     55   %arraydecay = getelementptr inbounds [4 x i32], [4 x i32]* %array, i64 0, i64 0, !dbg !40
     56   call void @f(i32* nonnull %arraydecay), !dbg !41
     57   %1 = load i32, i32* %arraydecay, align 16, !dbg !42, !tbaa !18
     58   call void @llvm.lifetime.end.p0i8(i64 16, i8* nonnull %0) #3, !dbg !43
     59   ret i32 %1, !dbg !44
     60 }
     61 
     62 ; Function Attrs: argmemonly nounwind
     63 declare void @llvm.lifetime.start.p0i8(i64, i8* nocapture) #2
     64 
     65 ; Function Attrs: argmemonly nounwind
     66 declare void @llvm.memcpy.p0i8.p0i8.i64(i8* nocapture writeonly, i8* nocapture readonly, i64, i1) #2
     67 
     68 ; Function Attrs: argmemonly nounwind
     69 declare void @llvm.lifetime.end.p0i8(i64, i8* nocapture) #2
     70 
     71 ; Function Attrs: nounwind readnone speculatable
     72 declare void @llvm.dbg.value(metadata, metadata, metadata) #1
     73 
     74 attributes #0 = { nounwind ssp uwtable }
     75 attributes #1 = { nounwind readnone speculatable }
     76 attributes #2 = { argmemonly nounwind }
     77 attributes #3 = { nounwind }
     78 
     79 !llvm.dbg.cu = !{!0}
     80 !llvm.module.flags = !{!3, !4, !5, !6}
     81 !llvm.ident = !{!7}
     82 
     83 !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)
     84 !1 = !DIFile(filename: "/tmp/array.c", directory: "/")
     85 !2 = !{}
     86 !3 = !{i32 2, !"Dwarf Version", i32 4}
     87 !4 = !{i32 2, !"Debug Info Version", i32 3}
     88 !5 = !{i32 1, !"wchar_size", i32 4}
     89 !6 = !{i32 7, !"PIC Level", i32 2}
     90 !7 = !{!"clang version 5.0.0 (trunk 303873) (llvm/trunk 303875)"}
     91 !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, retainedNodes: !13)
     92 !9 = !DISubroutineType(types: !10)
     93 !10 = !{null, !11}
     94 !11 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !12, size: 64)
     95 !12 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)
     96 !13 = !{!14}
     97 !14 = !DILocalVariable(name: "p", arg: 1, scope: !8, file: !1, line: 1, type: !11)
     98 !15 = !DIExpression()
     99 !16 = !DILocation(line: 1, column: 13, scope: !8)
    100 !17 = !DILocation(line: 2, column: 8, scope: !8)
    101 !18 = !{!19, !19, i64 0}
    102 !19 = !{!"int", !20, i64 0}
    103 !20 = !{!"omnipotent char", !21, i64 0}
    104 !21 = !{!"Simple C/C++ TBAA"}
    105 !22 = !DILocation(line: 3, column: 1, scope: !8)
    106 !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, retainedNodes: !29)
    107 !24 = !DISubroutineType(types: !25)
    108 !25 = !{!12, !12, !26}
    109 !26 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !27, size: 64)
    110 !27 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !28, size: 64)
    111 !28 = !DIBasicType(name: "char", size: 8, encoding: DW_ATE_signed_char)
    112 !29 = !{!30, !31, !32}
    113 !30 = !DILocalVariable(name: "argc", arg: 1, scope: !23, file: !1, line: 5, type: !12)
    114 !31 = !DILocalVariable(name: "argv", arg: 2, scope: !23, file: !1, line: 5, type: !26)
    115 !32 = !DILocalVariable(name: "array", scope: !23, file: !1, line: 6, type: !33)
    116 !33 = !DICompositeType(tag: DW_TAG_array_type, baseType: !12, size: 128, elements: !34)
    117 !34 = !{!35}
    118 !35 = !DISubrange(count: 4)
    119 !36 = !DILocation(line: 5, column: 14, scope: !23)
    120 !37 = !DILocation(line: 5, column: 27, scope: !23)
    121 !38 = !DILocation(line: 6, column: 3, scope: !23)
    122 !39 = !DILocation(line: 6, column: 7, scope: !23)
    123 !40 = !DILocation(line: 7, column: 5, scope: !23)
    124 !41 = !DILocation(line: 7, column: 3, scope: !23)
    125 !42 = !DILocation(line: 8, column: 10, scope: !23)
    126 !43 = !DILocation(line: 9, column: 1, scope: !23)
    127 !44 = !DILocation(line: 8, column: 3, scope: !23)
    128