1 ; RUN: llc -O0 -mtriple=x86_64-apple-darwin < %s -filetype=obj \ 2 ; RUN: | llvm-dwarfdump -debug-dump=info - \ 3 ; RUN: | FileCheck %s -check-prefix=CHECK -check-prefix=DWARF4 4 ; RUN: llc -O0 -mtriple=x86_64-apple-darwin < %s -filetype=obj -dwarf-version=3 \ 5 ; RUN: | llvm-dwarfdump -debug-dump=info - \ 6 ; RUN: | FileCheck %s -check-prefix=CHECK -check-prefix=DWARF3 7 8 ; FIXME: The location here needs to be fixed, but llvm-dwarfdump doesn't handle 9 ; DW_AT_location lists yet. 10 ; DWARF4: DW_AT_location [DW_FORM_sec_offset] (0x00000000) 11 12 ; FIXME: The location here needs to be fixed, but llvm-dwarfdump doesn't handle 13 ; DW_AT_location lists yet. 14 ; DWARF3: DW_AT_location [DW_FORM_data4] (0x00000000) 15 16 ; CHECK-NOT: DW_TAG 17 ; CHECK: DW_AT_name [DW_FORM_strp] ( .debug_str[0x00000067] = "vla") 18 19 ; Unfortunately llvm-dwarfdump can't unparse a list of DW_AT_locations 20 ; right now, so we check the asm output: 21 ; RUN: llc -O0 -mtriple=x86_64-apple-darwin %s -o - -filetype=asm | FileCheck %s -check-prefix=ASM-CHECK 22 ; vla should have a register-indirect address at one point. 23 ; ASM-CHECK: DEBUG_VALUE: vla <- RCX 24 ; ASM-CHECK: DW_OP_breg2 25 26 define void @testVLAwithSize(i32 %s) nounwind uwtable ssp { 27 entry: 28 %s.addr = alloca i32, align 4 29 %saved_stack = alloca i8* 30 %i = alloca i32, align 4 31 store i32 %s, i32* %s.addr, align 4 32 call void @llvm.dbg.declare(metadata !{i32* %s.addr}, metadata !10), !dbg !11 33 %0 = load i32* %s.addr, align 4, !dbg !12 34 %1 = zext i32 %0 to i64, !dbg !12 35 %2 = call i8* @llvm.stacksave(), !dbg !12 36 store i8* %2, i8** %saved_stack, !dbg !12 37 %vla = alloca i32, i64 %1, align 16, !dbg !12 38 call void @llvm.dbg.declare(metadata !{i32* %vla}, metadata !14), !dbg !18 39 call void @llvm.dbg.declare(metadata !{i32* %i}, metadata !19), !dbg !20 40 store i32 0, i32* %i, align 4, !dbg !21 41 br label %for.cond, !dbg !21 42 43 for.cond: ; preds = %for.inc, %entry 44 %3 = load i32* %i, align 4, !dbg !21 45 %4 = load i32* %s.addr, align 4, !dbg !21 46 %cmp = icmp slt i32 %3, %4, !dbg !21 47 br i1 %cmp, label %for.body, label %for.end, !dbg !21 48 49 for.body: ; preds = %for.cond 50 %5 = load i32* %i, align 4, !dbg !23 51 %6 = load i32* %i, align 4, !dbg !23 52 %mul = mul nsw i32 %5, %6, !dbg !23 53 %7 = load i32* %i, align 4, !dbg !23 54 %idxprom = sext i32 %7 to i64, !dbg !23 55 %arrayidx = getelementptr inbounds i32* %vla, i64 %idxprom, !dbg !23 56 store i32 %mul, i32* %arrayidx, align 4, !dbg !23 57 br label %for.inc, !dbg !25 58 59 for.inc: ; preds = %for.body 60 %8 = load i32* %i, align 4, !dbg !26 61 %inc = add nsw i32 %8, 1, !dbg !26 62 store i32 %inc, i32* %i, align 4, !dbg !26 63 br label %for.cond, !dbg !26 64 65 for.end: ; preds = %for.cond 66 %9 = load i8** %saved_stack, !dbg !27 67 call void @llvm.stackrestore(i8* %9), !dbg !27 68 ret void, !dbg !27 69 } 70 71 declare void @llvm.dbg.declare(metadata, metadata) nounwind readnone 72 73 declare i8* @llvm.stacksave() nounwind 74 75 declare void @llvm.stackrestore(i8*) nounwind 76 77 !llvm.dbg.cu = !{!0} 78 !llvm.module.flags = !{!29} 79 80 !0 = metadata !{i32 786449, metadata !28, i32 12, metadata !"clang version 3.2 (trunk 156005) (llvm/trunk 156000)", i1 false, metadata !"", i32 0, metadata !1, metadata !1, metadata !3, metadata !1, metadata !1, metadata !""} ; [ DW_TAG_compile_unit ] 81 !1 = metadata !{} 82 !3 = metadata !{metadata !5} 83 !5 = metadata !{i32 786478, metadata !28, metadata !6, metadata !"testVLAwithSize", metadata !"testVLAwithSize", metadata !"", i32 1, metadata !7, i1 false, i1 true, i32 0, i32 0, null, i32 256, i1 false, void (i32)* @testVLAwithSize, null, null, metadata !1, i32 2} ; [ DW_TAG_subprogram ] 84 !6 = metadata !{i32 786473, metadata !28} ; [ DW_TAG_file_type ] 85 !7 = metadata !{i32 786453, i32 0, null, i32 0, i32 0, i64 0, i64 0, i64 0, i32 0, null, metadata !8, i32 0, null, null, null} ; [ DW_TAG_subroutine_type ] [line 0, size 0, align 0, offset 0] [from ] 86 !8 = metadata !{null, metadata !9} 87 !9 = metadata !{i32 786468, null, null, metadata !"int", i32 0, i64 32, i64 32, i64 0, i32 0, i32 5} ; [ DW_TAG_base_type ] 88 !10 = metadata !{i32 786689, metadata !5, metadata !"s", metadata !6, i32 16777217, metadata !9, i32 0, i32 0} ; [ DW_TAG_arg_variable ] 89 !11 = metadata !{i32 1, i32 26, metadata !5, null} 90 !12 = metadata !{i32 3, i32 13, metadata !13, null} 91 !13 = metadata !{i32 786443, metadata !28, metadata !5, i32 2, i32 1, i32 0} ; [ DW_TAG_lexical_block ] 92 !14 = metadata !{i32 786688, metadata !13, metadata !"vla", metadata !6, i32 3, metadata !15, i32 8192, i32 0, metadata !30} ; [ DW_TAG_auto_variable ] 93 !15 = metadata !{i32 786433, null, null, metadata !"", i32 0, i64 0, i64 32, i32 0, i32 0, metadata !9, metadata !16, i32 0, null, null, null} ; [ DW_TAG_array_type ] [line 0, size 0, align 32, offset 0] [from int] 94 !16 = metadata !{metadata !17} 95 !17 = metadata !{i32 786465, i64 0, i64 -1} ; [ DW_TAG_subrange_type ] 96 !18 = metadata !{i32 3, i32 7, metadata !13, null} 97 !19 = metadata !{i32 786688, metadata !13, metadata !"i", metadata !6, i32 4, metadata !9, i32 0, i32 0} ; [ DW_TAG_auto_variable ] 98 !20 = metadata !{i32 4, i32 7, metadata !13, null} 99 !21 = metadata !{i32 5, i32 8, metadata !22, null} 100 !22 = metadata !{i32 786443, metadata !28, metadata !13, i32 5, i32 3, i32 1} ; [ DW_TAG_lexical_block ] 101 !23 = metadata !{i32 6, i32 5, metadata !24, null} 102 !24 = metadata !{i32 786443, metadata !28, metadata !22, i32 5, i32 27, i32 2} ; [ DW_TAG_lexical_block ] 103 !25 = metadata !{i32 7, i32 3, metadata !24, null} 104 !26 = metadata !{i32 5, i32 22, metadata !22, null} 105 !27 = metadata !{i32 8, i32 1, metadata !13, null} 106 !28 = metadata !{metadata !"bar.c", metadata !"/Users/echristo/tmp"} 107 !29 = metadata !{i32 1, metadata !"Debug Info Version", i32 1} 108 !30 = metadata !{i64 2} 109