1*9880d681SAndroid Build Coastguard Worker; RUN: llc -O0 -mtriple=x86_64-apple-darwin < %s -filetype=obj \ 2*9880d681SAndroid Build Coastguard Worker; RUN: | llvm-dwarfdump -debug-dump=info - \ 3*9880d681SAndroid Build Coastguard Worker; RUN: | FileCheck %s -check-prefix=CHECK -check-prefix=DWARF4 4*9880d681SAndroid Build Coastguard Worker; RUN: llc -O0 -mtriple=x86_64-apple-darwin < %s -filetype=obj -dwarf-version=3 \ 5*9880d681SAndroid Build Coastguard Worker; RUN: | llvm-dwarfdump -debug-dump=info - \ 6*9880d681SAndroid Build Coastguard Worker; RUN: | FileCheck %s -check-prefix=CHECK -check-prefix=DWARF3 7*9880d681SAndroid Build Coastguard Worker 8*9880d681SAndroid Build Coastguard Worker; FIXME: The location here needs to be fixed, but llvm-dwarfdump doesn't handle 9*9880d681SAndroid Build Coastguard Worker; DW_AT_location lists yet. 10*9880d681SAndroid Build Coastguard Worker; DWARF4: DW_AT_location [DW_FORM_sec_offset] (0x00000000) 11*9880d681SAndroid Build Coastguard Worker 12*9880d681SAndroid Build Coastguard Worker; FIXME: The location here needs to be fixed, but llvm-dwarfdump doesn't handle 13*9880d681SAndroid Build Coastguard Worker; DW_AT_location lists yet. 14*9880d681SAndroid Build Coastguard Worker; DWARF3: DW_AT_location [DW_FORM_data4] (0x00000000) 15*9880d681SAndroid Build Coastguard Worker 16*9880d681SAndroid Build Coastguard Worker; CHECK-NOT: DW_TAG 17*9880d681SAndroid Build Coastguard Worker; CHECK: DW_AT_name [DW_FORM_strp] ( .debug_str[0x00000067] = "vla") 18*9880d681SAndroid Build Coastguard Worker 19*9880d681SAndroid Build Coastguard Worker; Unfortunately llvm-dwarfdump can't unparse a list of DW_AT_locations 20*9880d681SAndroid Build Coastguard Worker; right now, so we check the asm output: 21*9880d681SAndroid Build Coastguard Worker; RUN: llc -O0 -mtriple=x86_64-apple-darwin %s -o - -filetype=asm | FileCheck %s -check-prefix=ASM-CHECK 22*9880d681SAndroid Build Coastguard Worker; vla should have a register-indirect address at one point. 23*9880d681SAndroid Build Coastguard Worker; ASM-CHECK: DEBUG_VALUE: vla <- [%RCX+0] 24*9880d681SAndroid Build Coastguard Worker; ASM-CHECK: DW_OP_breg2 25*9880d681SAndroid Build Coastguard Worker 26*9880d681SAndroid Build Coastguard Worker; RUN: llvm-as %s -o - | llvm-dis - | FileCheck %s --check-prefix=PRETTY-PRINT 27*9880d681SAndroid Build Coastguard Worker; PRETTY-PRINT: DIExpression(DW_OP_deref) 28*9880d681SAndroid Build Coastguard Worker 29*9880d681SAndroid Build Coastguard Workerdefine void @testVLAwithSize(i32 %s) nounwind uwtable ssp !dbg !5 { 30*9880d681SAndroid Build Coastguard Workerentry: 31*9880d681SAndroid Build Coastguard Worker %s.addr = alloca i32, align 4 32*9880d681SAndroid Build Coastguard Worker %saved_stack = alloca i8* 33*9880d681SAndroid Build Coastguard Worker %i = alloca i32, align 4 34*9880d681SAndroid Build Coastguard Worker store i32 %s, i32* %s.addr, align 4 35*9880d681SAndroid Build Coastguard Worker call void @llvm.dbg.declare(metadata i32* %s.addr, metadata !10, metadata !DIExpression()), !dbg !11 36*9880d681SAndroid Build Coastguard Worker %0 = load i32, i32* %s.addr, align 4, !dbg !12 37*9880d681SAndroid Build Coastguard Worker %1 = zext i32 %0 to i64, !dbg !12 38*9880d681SAndroid Build Coastguard Worker %2 = call i8* @llvm.stacksave(), !dbg !12 39*9880d681SAndroid Build Coastguard Worker store i8* %2, i8** %saved_stack, !dbg !12 40*9880d681SAndroid Build Coastguard Worker %vla = alloca i32, i64 %1, align 16, !dbg !12 41*9880d681SAndroid Build Coastguard Worker call void @llvm.dbg.declare(metadata i32* %vla, metadata !14, metadata !30), !dbg !18 42*9880d681SAndroid Build Coastguard Worker call void @llvm.dbg.declare(metadata i32* %i, metadata !19, metadata !DIExpression()), !dbg !20 43*9880d681SAndroid Build Coastguard Worker store i32 0, i32* %i, align 4, !dbg !21 44*9880d681SAndroid Build Coastguard Worker br label %for.cond, !dbg !21 45*9880d681SAndroid Build Coastguard Worker 46*9880d681SAndroid Build Coastguard Workerfor.cond: ; preds = %for.inc, %entry 47*9880d681SAndroid Build Coastguard Worker %3 = load i32, i32* %i, align 4, !dbg !21 48*9880d681SAndroid Build Coastguard Worker %4 = load i32, i32* %s.addr, align 4, !dbg !21 49*9880d681SAndroid Build Coastguard Worker %cmp = icmp slt i32 %3, %4, !dbg !21 50*9880d681SAndroid Build Coastguard Worker br i1 %cmp, label %for.body, label %for.end, !dbg !21 51*9880d681SAndroid Build Coastguard Worker 52*9880d681SAndroid Build Coastguard Workerfor.body: ; preds = %for.cond 53*9880d681SAndroid Build Coastguard Worker %5 = load i32, i32* %i, align 4, !dbg !23 54*9880d681SAndroid Build Coastguard Worker %6 = load i32, i32* %i, align 4, !dbg !23 55*9880d681SAndroid Build Coastguard Worker %mul = mul nsw i32 %5, %6, !dbg !23 56*9880d681SAndroid Build Coastguard Worker %7 = load i32, i32* %i, align 4, !dbg !23 57*9880d681SAndroid Build Coastguard Worker %idxprom = sext i32 %7 to i64, !dbg !23 58*9880d681SAndroid Build Coastguard Worker %arrayidx = getelementptr inbounds i32, i32* %vla, i64 %idxprom, !dbg !23 59*9880d681SAndroid Build Coastguard Worker store i32 %mul, i32* %arrayidx, align 4, !dbg !23 60*9880d681SAndroid Build Coastguard Worker br label %for.inc, !dbg !25 61*9880d681SAndroid Build Coastguard Worker 62*9880d681SAndroid Build Coastguard Workerfor.inc: ; preds = %for.body 63*9880d681SAndroid Build Coastguard Worker %8 = load i32, i32* %i, align 4, !dbg !26 64*9880d681SAndroid Build Coastguard Worker %inc = add nsw i32 %8, 1, !dbg !26 65*9880d681SAndroid Build Coastguard Worker store i32 %inc, i32* %i, align 4, !dbg !26 66*9880d681SAndroid Build Coastguard Worker br label %for.cond, !dbg !26 67*9880d681SAndroid Build Coastguard Worker 68*9880d681SAndroid Build Coastguard Workerfor.end: ; preds = %for.cond 69*9880d681SAndroid Build Coastguard Worker %9 = load i8*, i8** %saved_stack, !dbg !27 70*9880d681SAndroid Build Coastguard Worker call void @llvm.stackrestore(i8* %9), !dbg !27 71*9880d681SAndroid Build Coastguard Worker ret void, !dbg !27 72*9880d681SAndroid Build Coastguard Worker} 73*9880d681SAndroid Build Coastguard Worker 74*9880d681SAndroid Build Coastguard Workerdeclare void @llvm.dbg.declare(metadata, metadata, metadata) nounwind readnone 75*9880d681SAndroid Build Coastguard Worker 76*9880d681SAndroid Build Coastguard Workerdeclare i8* @llvm.stacksave() nounwind 77*9880d681SAndroid Build Coastguard Worker 78*9880d681SAndroid Build Coastguard Workerdeclare void @llvm.stackrestore(i8*) nounwind 79*9880d681SAndroid Build Coastguard Worker 80*9880d681SAndroid Build Coastguard Worker!llvm.dbg.cu = !{!0} 81*9880d681SAndroid Build Coastguard Worker!llvm.module.flags = !{!29} 82*9880d681SAndroid Build Coastguard Worker 83*9880d681SAndroid Build Coastguard Worker!0 = distinct !DICompileUnit(language: DW_LANG_C99, producer: "clang version 3.2 (trunk 156005) (llvm/trunk 156000)", isOptimized: false, emissionKind: FullDebug, file: !28, enums: !1, retainedTypes: !1, globals: !1, imports: !1) 84*9880d681SAndroid Build Coastguard Worker!1 = !{} 85*9880d681SAndroid Build Coastguard Worker!5 = distinct !DISubprogram(name: "testVLAwithSize", line: 1, isLocal: false, isDefinition: true, virtualIndex: 6, flags: DIFlagPrototyped, isOptimized: false, unit: !0, scopeLine: 2, file: !28, scope: !6, type: !7, variables: !1) 86*9880d681SAndroid Build Coastguard Worker!6 = !DIFile(filename: "bar.c", directory: "/Users/echristo/tmp") 87*9880d681SAndroid Build Coastguard Worker!7 = !DISubroutineType(types: !8) 88*9880d681SAndroid Build Coastguard Worker!8 = !{null, !9} 89*9880d681SAndroid Build Coastguard Worker!9 = !DIBasicType(tag: DW_TAG_base_type, name: "int", size: 32, align: 32, encoding: DW_ATE_signed) 90*9880d681SAndroid Build Coastguard Worker!10 = !DILocalVariable(name: "s", line: 1, arg: 1, scope: !5, file: !6, type: !9) 91*9880d681SAndroid Build Coastguard Worker!11 = !DILocation(line: 1, column: 26, scope: !5) 92*9880d681SAndroid Build Coastguard Worker!12 = !DILocation(line: 3, column: 13, scope: !13) 93*9880d681SAndroid Build Coastguard Worker!13 = distinct !DILexicalBlock(line: 2, column: 1, file: !28, scope: !5) 94*9880d681SAndroid Build Coastguard Worker!14 = !DILocalVariable(name: "vla", line: 3, scope: !13, file: !6, type: !15) 95*9880d681SAndroid Build Coastguard Worker!15 = !DICompositeType(tag: DW_TAG_array_type, align: 32, baseType: !9, elements: !16) 96*9880d681SAndroid Build Coastguard Worker!16 = !{!17} 97*9880d681SAndroid Build Coastguard Worker!17 = !DISubrange(count: -1) 98*9880d681SAndroid Build Coastguard Worker!18 = !DILocation(line: 3, column: 7, scope: !13) 99*9880d681SAndroid Build Coastguard Worker!19 = !DILocalVariable(name: "i", line: 4, scope: !13, file: !6, type: !9) 100*9880d681SAndroid Build Coastguard Worker!20 = !DILocation(line: 4, column: 7, scope: !13) 101*9880d681SAndroid Build Coastguard Worker!21 = !DILocation(line: 5, column: 8, scope: !22) 102*9880d681SAndroid Build Coastguard Worker!22 = distinct !DILexicalBlock(line: 5, column: 3, file: !28, scope: !13) 103*9880d681SAndroid Build Coastguard Worker!23 = !DILocation(line: 6, column: 5, scope: !24) 104*9880d681SAndroid Build Coastguard Worker!24 = distinct !DILexicalBlock(line: 5, column: 27, file: !28, scope: !22) 105*9880d681SAndroid Build Coastguard Worker!25 = !DILocation(line: 7, column: 3, scope: !24) 106*9880d681SAndroid Build Coastguard Worker!26 = !DILocation(line: 5, column: 22, scope: !22) 107*9880d681SAndroid Build Coastguard Worker!27 = !DILocation(line: 8, column: 1, scope: !13) 108*9880d681SAndroid Build Coastguard Worker!28 = !DIFile(filename: "bar.c", directory: "/Users/echristo/tmp") 109*9880d681SAndroid Build Coastguard Worker!29 = !{i32 1, !"Debug Info Version", i32 3} 110*9880d681SAndroid Build Coastguard Worker!30 = !DIExpression(DW_OP_deref) 111