1; RUN: llc -mtriple x86_64-pc-linux -O0 < %s | FileCheck %s 2; RUN: llc --try-experimental-debuginfo-iterators -mtriple x86_64-pc-linux -O0 < %s | FileCheck %s 3 4; Make sure that the sequence of debug locations for function foo is correctly 5; generated. More specifically, .loc entries for lines 4,5,6,7 must appear in 6; the correct sequence. 7 8; $ clang -emit-llvm -S -g dbg-combine.c 9; 1. int foo() 10; 2. { 11; 3. int elems = 3; 12; 4. int array1[elems]; 13; 5. array1[0]=0; 14; 6. array1[1]=1; 15; 7. array1[2]=2; 16; 8. int array2[elems]; 17; 9. array2[0]=1; 18; 10. return array2[0]; 19; 11. } 20 21; CHECK: .loc 1 4 22; CHECK: .loc 1 5 23; CHECK: .loc 1 6 24; CHECK: .loc 1 7 25 26; ModuleID = 'dbg-combine.c' 27; Function Attrs: nounwind uwtable 28define i32 @foo() #0 !dbg !4 { 29entry: 30 %elems = alloca i32, align 4 31 %saved_stack = alloca ptr 32 %cleanup.dest.slot = alloca i32 33 call void @llvm.dbg.declare(metadata ptr %elems, metadata !12, metadata !13), !dbg !14 34 store i32 3, ptr %elems, align 4, !dbg !14 35 %0 = load i32, ptr %elems, align 4, !dbg !15 36 %1 = zext i32 %0 to i64, !dbg !16 37 %2 = call ptr @llvm.stacksave(), !dbg !16 38 store ptr %2, ptr %saved_stack, !dbg !16 39 %vla = alloca i32, i64 %1, align 16, !dbg !16 40 call void @llvm.dbg.declare(metadata ptr %vla, metadata !17, metadata !21), !dbg !22 41 store i32 0, ptr %vla, align 4, !dbg !24 42 %arrayidx1 = getelementptr inbounds i32, ptr %vla, i64 1, !dbg !25 43 store i32 1, ptr %arrayidx1, align 4, !dbg !26 44 %arrayidx2 = getelementptr inbounds i32, ptr %vla, i64 2, !dbg !27 45 store i32 2, ptr %arrayidx2, align 4, !dbg !28 46 %3 = load i32, ptr %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 ptr %vla3, metadata !31, metadata !21), !dbg !32 50 store i32 1, ptr %vla3, align 4, !dbg !34 51 %5 = load i32, ptr %vla3, align 4, !dbg !35 52 store i32 1, ptr %cleanup.dest.slot 53 %6 = load ptr, ptr %saved_stack, !dbg !36 54 call void @llvm.stackrestore(ptr %6), !dbg !36 55 ret i32 %5, !dbg !36 56} 57 58; Function Attrs: nounwind readnone 59declare void @llvm.dbg.declare(metadata, metadata, metadata) #1 60 61; Function Attrs: nounwind 62declare ptr @llvm.stacksave() #2 63 64; Function Attrs: nounwind 65declare void @llvm.stackrestore(ptr) #2 66 67attributes #0 = { nounwind uwtable "less-precise-fpmad"="false" "frame-pointer"="all" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "stack-protector-buffer-size"="8" "unsafe-fp-math"="false" "use-soft-float"="false" } 68attributes #1 = { nounwind readnone } 69attributes #2 = { nounwind } 70 71!llvm.dbg.cu = !{!0} 72!llvm.module.flags = !{!9, !10} 73!llvm.ident = !{!11} 74 75!0 = distinct !DICompileUnit(language: DW_LANG_C99, producer: "clang version 3.7.0 (trunk 227074)", isOptimized: false, emissionKind: FullDebug, file: !1, enums: !2, retainedTypes: !2, globals: !2, imports: !2) 76!1 = !DIFile(filename: "dbg-combine.c", directory: "/home/probinson/projects/scratch") 77!2 = !{} 78!4 = distinct !DISubprogram(name: "foo", line: 1, isLocal: false, isDefinition: true, isOptimized: false, unit: !0, scopeLine: 2, file: !1, scope: !5, type: !6, retainedNodes: !2) 79!5 = !DIFile(filename: "dbg-combine.c", directory: "/home/probinson/projects/scratch") 80!6 = !DISubroutineType(types: !7) 81!7 = !{!8} 82!8 = !DIBasicType(tag: DW_TAG_base_type, name: "int", size: 32, align: 32, encoding: DW_ATE_signed) 83!9 = !{i32 2, !"Dwarf Version", i32 4} 84!10 = !{i32 2, !"Debug Info Version", i32 3} 85!11 = !{!"clang version 3.7.0 (trunk 227074)"} 86!12 = !DILocalVariable(name: "elems", line: 3, scope: !4, file: !5, type: !8) 87!13 = !DIExpression() 88!14 = !DILocation(line: 3, column: 8, scope: !4) 89!15 = !DILocation(line: 4, column: 15, scope: !4) 90!16 = !DILocation(line: 4, column: 4, scope: !4) 91!17 = !DILocalVariable(name: "array1", line: 4, scope: !4, file: !5, type: !18) 92!18 = !DICompositeType(tag: DW_TAG_array_type, align: 32, baseType: !8, elements: !19) 93!19 = !{!20} 94!20 = !DISubrange(count: -1) 95!21 = !DIExpression(DW_OP_deref) 96!22 = !DILocation(line: 4, column: 8, scope: !4) 97!23 = !DILocation(line: 5, column: 4, scope: !4) 98!24 = !DILocation(line: 5, column: 13, scope: !4) 99!25 = !DILocation(line: 6, column: 4, scope: !4) 100!26 = !DILocation(line: 6, column: 13, scope: !4) 101!27 = !DILocation(line: 7, column: 4, scope: !4) 102!28 = !DILocation(line: 7, column: 13, scope: !4) 103!29 = !DILocation(line: 8, column: 15, scope: !4) 104!30 = !DILocation(line: 8, column: 4, scope: !4) 105!31 = !DILocalVariable(name: "array2", line: 8, scope: !4, file: !5, type: !18) 106!32 = !DILocation(line: 8, column: 8, scope: !4) 107!33 = !DILocation(line: 9, column: 4, scope: !4) 108!34 = !DILocation(line: 9, column: 13, scope: !4) 109!35 = !DILocation(line: 10, column: 11, scope: !4) 110!36 = !DILocation(line: 11, column: 1, scope: !4) 111