|
| 1 | +; RUN: llc -mtriple x86_64-pc-linux -O0 < %s | FileCheck %s |
| 2 | + |
| 3 | +; Make sure that the sequence of debug locations for function foo is correctly |
| 4 | +; generated. More specifically, .loc entries for lines 4,5,6,7 must appear in |
| 5 | +; the correct sequence. |
| 6 | + |
| 7 | +; $ clang -emit-llvm -S -g dbg-combine.c |
| 8 | +; 1. int foo() |
| 9 | +; 2. { |
| 10 | +; 3. int elems = 3; |
| 11 | +; 4. int array1[elems]; |
| 12 | +; 5. array1[0]=0; |
| 13 | +; 6. array1[1]=1; |
| 14 | +; 7. array1[2]=2; |
| 15 | +; 8. int array2[elems]; |
| 16 | +; 9. array2[0]=1; |
| 17 | +; 10. return array2[0]; |
| 18 | +; 11. } |
| 19 | + |
| 20 | +; CHECK: .loc 1 4 |
| 21 | +; CHECK: .loc 1 5 |
| 22 | +; CHECK: .loc 1 6 |
| 23 | +; CHECK: .loc 1 7 |
| 24 | + |
| 25 | +; ModuleID = 'dbg-combine.c' |
| 26 | +; Function Attrs: nounwind uwtable |
| 27 | +define i32 @foo() #0 { |
| 28 | +entry: |
| 29 | + %elems = alloca i32, align 4 |
| 30 | + %saved_stack = alloca i8* |
| 31 | + %cleanup.dest.slot = alloca i32 |
| 32 | + call void @llvm.dbg.declare(metadata i32* %elems, metadata !12, metadata !13), !dbg !14 |
| 33 | + store i32 3, i32* %elems, align 4, !dbg !14 |
| 34 | + %0 = load i32* %elems, align 4, !dbg !15 |
| 35 | + %1 = zext i32 %0 to i64, !dbg !16 |
| 36 | + %2 = call i8* @llvm.stacksave(), !dbg !16 |
| 37 | + store i8* %2, i8** %saved_stack, !dbg !16 |
| 38 | + %vla = alloca i32, i64 %1, align 16, !dbg !16 |
| 39 | + call void @llvm.dbg.declare(metadata i32* %vla, metadata !17, metadata !21), !dbg !22 |
| 40 | + %arrayidx = getelementptr inbounds i32* %vla, i64 0, !dbg !23 |
| 41 | + store i32 0, i32* %arrayidx, align 4, !dbg !24 |
| 42 | + %arrayidx1 = getelementptr inbounds i32* %vla, i64 1, !dbg !25 |
| 43 | + store i32 1, i32* %arrayidx1, align 4, !dbg !26 |
| 44 | + %arrayidx2 = getelementptr inbounds i32* %vla, i64 2, !dbg !27 |
| 45 | + store i32 2, i32* %arrayidx2, align 4, !dbg !28 |
| 46 | + %3 = load i32* %elems, align 4, !dbg !29 |
| 47 | + %4 = zext i32 %3 to i64, !dbg !30 |
| 48 | + %vla3 = alloca i32, i64 %4, align 16, !dbg !30 |
| 49 | + call void @llvm.dbg.declare(metadata i32* %vla3, metadata !31, metadata !21), !dbg !32 |
| 50 | + %arrayidx4 = getelementptr inbounds i32* %vla3, i64 0, !dbg !33 |
| 51 | + store i32 1, i32* %arrayidx4, align 4, !dbg !34 |
| 52 | + %arrayidx5 = getelementptr inbounds i32* %vla3, i64 0, !dbg !35 |
| 53 | + %5 = load i32* %arrayidx5, align 4, !dbg !35 |
| 54 | + store i32 1, i32* %cleanup.dest.slot |
| 55 | + %6 = load i8** %saved_stack, !dbg !36 |
| 56 | + call void @llvm.stackrestore(i8* %6), !dbg !36 |
| 57 | + ret i32 %5, !dbg !36 |
| 58 | +} |
| 59 | + |
| 60 | +; Function Attrs: nounwind readnone |
| 61 | +declare void @llvm.dbg.declare(metadata, metadata, metadata) #1 |
| 62 | + |
| 63 | +; Function Attrs: nounwind |
| 64 | +declare i8* @llvm.stacksave() #2 |
| 65 | + |
| 66 | +; Function Attrs: nounwind |
| 67 | +declare void @llvm.stackrestore(i8*) #2 |
| 68 | + |
| 69 | +attributes #0 = { nounwind uwtable "less-precise-fpmad"="false" "no-frame-pointer-elim"="true" "no-frame-pointer-elim-non-leaf" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "stack-protector-buffer-size"="8" "unsafe-fp-math"="false" "use-soft-float"="false" } |
| 70 | +attributes #1 = { nounwind readnone } |
| 71 | +attributes #2 = { nounwind } |
| 72 | + |
| 73 | +!llvm.dbg.cu = !{!0} |
| 74 | +!llvm.module.flags = !{!9, !10} |
| 75 | +!llvm.ident = !{!11} |
| 76 | + |
| 77 | +!0 = !{!"0x11\0012\00clang version 3.7.0 (trunk 227074)\000\00\000\00\001", !1, !2, !2, !3, !2, !2} ; [ DW_TAG_compile_unit ] [/home/probinson/projects/scratch/dbg-combine.c] [DW_LANG_C99] |
| 78 | +!1 = !{!"dbg-combine.c", !"/home/probinson/projects/scratch"} |
| 79 | +!2 = !{} |
| 80 | +!3 = !{!4} |
| 81 | +!4 = !{!"0x2e\00foo\00foo\00\001\000\001\000\000\000\000\002", !1, !5, !6, null, i32 ()* @foo, null, null, !2} ; [ DW_TAG_subprogram ] [line 1] [def] [scope 2] [foo] |
| 82 | +!5 = !{!"0x29", !1} ; [ DW_TAG_file_type ] [/home/probinson/projects/scratch/dbg-combine.c] |
| 83 | +!6 = !{!"0x15\00\000\000\000\000\000\000", null, null, null, !7, null, null, null} ; [ DW_TAG_subroutine_type ] [line 0, size 0, align 0, offset 0] [from ] |
| 84 | +!7 = !{!8} |
| 85 | +!8 = !{!"0x24\00int\000\0032\0032\000\000\005", null, null} ; [ DW_TAG_base_type ] [int] [line 0, size 32, align 32, offset 0, enc DW_ATE_signed] |
| 86 | +!9 = !{i32 2, !"Dwarf Version", i32 4} |
| 87 | +!10 = !{i32 2, !"Debug Info Version", i32 2} |
| 88 | +!11 = !{!"clang version 3.7.0 (trunk 227074)"} |
| 89 | +!12 = !{!"0x100\00elems\003\000", !4, !5, !8} ; [ DW_TAG_auto_variable ] [elems] [line 3] |
| 90 | +!13 = !{!"0x102"} ; [ DW_TAG_expression ] |
| 91 | +!14 = !MDLocation(line: 3, column: 8, scope: !4) |
| 92 | +!15 = !MDLocation(line: 4, column: 15, scope: !4) |
| 93 | +!16 = !MDLocation(line: 4, column: 4, scope: !4) |
| 94 | +!17 = !{!"0x100\00array1\004\000", !4, !5, !18} ; [ DW_TAG_auto_variable ] [array1] [line 4] |
| 95 | +!18 = !{!"0x1\00\000\000\0032\000\000\000", null, null, !8, !19, null, null, null} ; [ DW_TAG_array_type ] [line 0, size 0, align 32, offset 0] [from int] |
| 96 | +!19 = !{!20} |
| 97 | +!20 = !{!"0x21\000\00-1"} ; [ DW_TAG_subrange_type ] [unbounded] |
| 98 | +!21 = !{!"0x102\006"} ; [ DW_TAG_expression ] [DW_OP_deref] |
| 99 | +!22 = !MDLocation(line: 4, column: 8, scope: !4) |
| 100 | +!23 = !MDLocation(line: 5, column: 4, scope: !4) |
| 101 | +!24 = !MDLocation(line: 5, column: 13, scope: !4) |
| 102 | +!25 = !MDLocation(line: 6, column: 4, scope: !4) |
| 103 | +!26 = !MDLocation(line: 6, column: 13, scope: !4) |
| 104 | +!27 = !MDLocation(line: 7, column: 4, scope: !4) |
| 105 | +!28 = !MDLocation(line: 7, column: 13, scope: !4) |
| 106 | +!29 = !MDLocation(line: 8, column: 15, scope: !4) |
| 107 | +!30 = !MDLocation(line: 8, column: 4, scope: !4) |
| 108 | +!31 = !{!"0x100\00array2\008\000", !4, !5, !18} ; [ DW_TAG_auto_variable ] [array2] [line 8] |
| 109 | +!32 = !MDLocation(line: 8, column: 8, scope: !4) |
| 110 | +!33 = !MDLocation(line: 9, column: 4, scope: !4) |
| 111 | +!34 = !MDLocation(line: 9, column: 13, scope: !4) |
| 112 | +!35 = !MDLocation(line: 10, column: 11, scope: !4) |
| 113 | +!36 = !MDLocation(line: 11, column: 1, scope: !4) |
0 commit comments