126 lines · plain
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 %s16; RUN: llc -filetype=obj %s -o - | llvm-dwarfdump -v - --debug-info | FileCheck %s --check-prefix=DWARF17 18; CHECK-LABEL: _main:19; CHECK: movaps {{.*}}, (%rsp)20; CHECK: movq %rsp, %rdi21; CHECK: callq _f22 23; DWARF: DW_TAG_variable24; 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'28source_filename = "/tmp/array.c"29target datalayout = "e-m:o-i64:64-f80:128-n8:16:32:64-S128"30target 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 1633 34; Function Attrs: nounwind ssp uwtable35define void @f(ptr nocapture %p) local_unnamed_addr #0 !dbg !8 {36entry:37 tail call void @llvm.dbg.value(metadata ptr %p, metadata !14, metadata !15), !dbg !1638 store i32 42, ptr %p, align 4, !dbg !17, !tbaa !1839 ret void, !dbg !2240}41 42; Function Attrs: nounwind readnone speculatable43declare void @llvm.dbg.declare(metadata, metadata, metadata) #144 45; Function Attrs: nounwind ssp uwtable46define i32 @main(i32 %argc, ptr nocapture readnone %argv) local_unnamed_addr #0 !dbg !23 {47entry:48 %array = alloca [4 x i32], align 1649 tail call void @llvm.dbg.value(metadata i32 %argc, metadata !30, metadata !15), !dbg !3650 tail call void @llvm.dbg.value(metadata ptr %argv, metadata !31, metadata !15), !dbg !3751 call void @llvm.lifetime.start.p0(i64 16, ptr nonnull %array) #3, !dbg !3852 tail call void @llvm.dbg.declare(metadata ptr %array, metadata !32, metadata !15), !dbg !3953 call void @llvm.memcpy.p0.p0.i64(ptr align 16 nonnull %array, ptr align 16 @main.array, i64 16, i1 false), !dbg !3954 call void @f(ptr nonnull %array), !dbg !4155 %0 = load i32, ptr %array, align 16, !dbg !42, !tbaa !1856 call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %array) #3, !dbg !4357 ret i32 %0, !dbg !4458}59 60; Function Attrs: argmemonly nounwind61declare void @llvm.lifetime.start.p0(i64, ptr nocapture) #262 63; Function Attrs: argmemonly nounwind64declare void @llvm.memcpy.p0.p0.i64(ptr nocapture writeonly, ptr nocapture readonly, i64, i1) #265 66; Function Attrs: argmemonly nounwind67declare void @llvm.lifetime.end.p0(i64, ptr nocapture) #268 69; Function Attrs: nounwind readnone speculatable70declare void @llvm.dbg.value(metadata, metadata, metadata) #171 72attributes #0 = { nounwind ssp uwtable }73attributes #1 = { nounwind readnone speculatable }74attributes #2 = { argmemonly nounwind }75attributes #3 = { nounwind }76 77!llvm.dbg.cu = !{!0}78!llvm.module.flags = !{!3, !4, !5, !6}79!llvm.ident = !{!7}80 81!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)82!1 = !DIFile(filename: "/tmp/array.c", directory: "/")83!2 = !{}84!3 = !{i32 2, !"Dwarf Version", i32 4}85!4 = !{i32 2, !"Debug Info Version", i32 3}86!5 = !{i32 1, !"wchar_size", i32 4}87!6 = !{i32 7, !"PIC Level", i32 2}88!7 = !{!"clang version 5.0.0 (trunk 303873) (llvm/trunk 303875)"}89!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)90!9 = !DISubroutineType(types: !10)91!10 = !{null, !11}92!11 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !12, size: 64)93!12 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)94!13 = !{!14}95!14 = !DILocalVariable(name: "p", arg: 1, scope: !8, file: !1, line: 1, type: !11)96!15 = !DIExpression()97!16 = !DILocation(line: 1, column: 13, scope: !8)98!17 = !DILocation(line: 2, column: 8, scope: !8)99!18 = !{!19, !19, i64 0}100!19 = !{!"int", !20, i64 0}101!20 = !{!"omnipotent char", !21, i64 0}102!21 = !{!"Simple C/C++ TBAA"}103!22 = !DILocation(line: 3, column: 1, scope: !8)104!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)105!24 = !DISubroutineType(types: !25)106!25 = !{!12, !12, !26}107!26 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !27, size: 64)108!27 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !28, size: 64)109!28 = !DIBasicType(name: "char", size: 8, encoding: DW_ATE_signed_char)110!29 = !{!30, !31, !32}111!30 = !DILocalVariable(name: "argc", arg: 1, scope: !23, file: !1, line: 5, type: !12)112!31 = !DILocalVariable(name: "argv", arg: 2, scope: !23, file: !1, line: 5, type: !26)113!32 = !DILocalVariable(name: "array", scope: !23, file: !1, line: 6, type: !33)114!33 = !DICompositeType(tag: DW_TAG_array_type, baseType: !12, size: 128, elements: !34)115!34 = !{!35}116!35 = !DISubrange(count: 4)117!36 = !DILocation(line: 5, column: 14, scope: !23)118!37 = !DILocation(line: 5, column: 27, scope: !23)119!38 = !DILocation(line: 6, column: 3, scope: !23)120!39 = !DILocation(line: 6, column: 7, scope: !23)121!40 = !DILocation(line: 7, column: 5, scope: !23)122!41 = !DILocation(line: 7, column: 3, scope: !23)123!42 = !DILocation(line: 8, column: 10, scope: !23)124!43 = !DILocation(line: 9, column: 1, scope: !23)125!44 = !DILocation(line: 8, column: 3, scope: !23)126