1 ; RUN: opt -loop-unroll -unroll-runtime -unroll-runtime-epilog -S %s | FileCheck %s 2 3 ; Test that epilogue is tagged with the same debug information as original loop body rather than original loop exit. 4 5 ; CHECK: for.body.i: 6 ; CHECK: br i1 {{.*}}, label %lee1.exit.loopexit.unr-lcssa.loopexit, label %for.body.i, !dbg ![[LOOP_LOC:[0-9]+]] 7 ; CHECK: lee1.exit.loopexit.unr-lcssa.loopexit: 8 ; CHECK: br label %lee1.exit.loopexit.unr-lcssa, !dbg ![[LOOP_LOC]] 9 ; CHECK: lee1.exit.loopexit.unr-lcssa: 10 ; CHECK: %lcmp.mod = icmp ne i32 %xtraiter, 0, !dbg ![[LOOP_LOC]] 11 ; CHECK: br i1 %lcmp.mod, label %for.body.i.epil.preheader, label %lee1.exit.loopexit, !dbg ![[LOOP_LOC]] 12 ; CHECK: for.body.i.epil.preheader: 13 ; CHECK: br label %for.body.i.epil, !dbg ![[LOOP_LOC]] 14 ; CHECK: lee1.exit.loopexit: 15 ; CHECK: br label %lee1.exit, !dbg ![[EXIT_LOC:[0-9]+]] 16 17 ; CHECK-DAG: ![[LOOP_LOC]] = !DILocation(line: 5, column: 3, scope: !{{.*}}, inlinedAt: !{{.*}}) 18 ; CHECK-DAG: ![[EXIT_LOC]] = !DILocation(line: 11, column: 12, scope: !{{.*}}, inlinedAt: !{{.*}}) 19 20 ; Function Attrs: nounwind readnone 21 define i32 @goo(i32 %a, i32 %b) local_unnamed_addr #0 !dbg !8 { 22 entry: 23 tail call void @llvm.dbg.value(metadata i32 %a, i64 0, metadata !13, metadata !15), !dbg !16 24 tail call void @llvm.dbg.value(metadata i32 %b, i64 0, metadata !14, metadata !15), !dbg !17 25 tail call void @llvm.dbg.value(metadata i32 %a, i64 0, metadata !18, metadata !15), !dbg !26 26 tail call void @llvm.dbg.value(metadata i32 %b, i64 0, metadata !21, metadata !15), !dbg !28 27 tail call void @llvm.dbg.value(metadata i32 0, i64 0, metadata !22, metadata !15), !dbg !29 28 tail call void @llvm.dbg.value(metadata i32 0, i64 0, metadata !23, metadata !15), !dbg !30 29 tail call void @llvm.dbg.value(metadata i32 0, i64 0, metadata !23, metadata !15), !dbg !30 30 tail call void @llvm.dbg.value(metadata i32 0, i64 0, metadata !22, metadata !15), !dbg !29 31 %cmp7.i = icmp eq i32 %b, 0, !dbg !31 32 br i1 %cmp7.i, label %lee1.exit, label %for.body.i.preheader, !dbg !33 33 34 for.body.i.preheader: ; preds = %entry 35 br label %for.body.i, !dbg !34 36 37 for.body.i: ; preds = %for.body.i.preheader, %for.body.i 38 %i.09.i = phi i32 [ %inc.i, %for.body.i ], [ 0, %for.body.i.preheader ] 39 %t.08.i = phi i32 [ %add1.i, %for.body.i ], [ 0, %for.body.i.preheader ] 40 %div.i = sdiv i32 %t.08.i, 2, !dbg !34 41 %add.i = add i32 %t.08.i, %a, !dbg !35 42 %add1.i = add i32 %add.i, %div.i, !dbg !36 43 tail call void @llvm.dbg.value(metadata i32 %add1.i, i64 0, metadata !22, metadata !15), !dbg !29 44 %inc.i = add nuw i32 %i.09.i, 1, !dbg !37 45 tail call void @llvm.dbg.value(metadata i32 %inc.i, i64 0, metadata !23, metadata !15), !dbg !30 46 tail call void @llvm.dbg.value(metadata i32 %inc.i, i64 0, metadata !23, metadata !15), !dbg !30 47 tail call void @llvm.dbg.value(metadata i32 %add1.i, i64 0, metadata !22, metadata !15), !dbg !29 48 %exitcond.i = icmp eq i32 %inc.i, %b, !dbg !31 49 br i1 %exitcond.i, label %lee1.exit.loopexit, label %for.body.i, !dbg !33, !llvm.loop !38 50 51 lee1.exit.loopexit: ; preds = %for.body.i 52 %add1.i.lcssa = phi i32 [ %add1.i, %for.body.i ] 53 br label %lee1.exit, !dbg !41 54 55 lee1.exit: ; preds = %lee1.exit.loopexit, %entry 56 %t.0.lcssa.i = phi i32 [ 0, %entry ], [ %add1.i.lcssa, %lee1.exit.loopexit ] 57 tail call void @llvm.dbg.value(metadata i32 %a, i64 0, metadata !44, metadata !15), !dbg !47 58 tail call void @llvm.dbg.value(metadata i32 %b, i64 0, metadata !45, metadata !15), !dbg !48 59 %add.i4 = add nsw i32 %b, %a, !dbg !41 60 %sub.i = sub nsw i32 %a, %b, !dbg !49 61 %mul.i = mul nsw i32 %add.i4, %sub.i, !dbg !50 62 %add = add nsw i32 %t.0.lcssa.i, %mul.i, !dbg !51 63 ret i32 %add, !dbg !52 64 } 65 66 ; Function Attrs: nounwind readnone 67 declare void @llvm.dbg.value(metadata, i64, metadata, metadata) #1 68 69 attributes #0 = { nounwind readnone "correctly-rounded-divide-sqrt-fp-math"="false" "disable-tail-calls"="false" "less-precise-fpmad"="false" "no-frame-pointer-elim"="true" "no-frame-pointer-elim-non-leaf" "no-infs-fp-math"="false" "no-jump-tables"="false" "no-nans-fp-math"="false" "no-signed-zeros-fp-math"="false" "no-trapping-math"="false" "stack-protector-buffer-size"="8" "target-cpu"="arm7tdmi" "target-features"="+neon,+strict-align,+vfp3,-crypto,-d16,-fp-armv8,-fp-only-sp,-fp16,-vfp4" "unsafe-fp-math"="false" "use-soft-float"="false" } 70 attributes #1 = { nounwind readnone } 71 72 !llvm.dbg.cu = !{!0} 73 !llvm.module.flags = !{!3, !4, !5, !6} 74 !llvm.ident = !{!7} 75 76 !0 = distinct !DICompileUnit(language: DW_LANG_C99, file: !1, producer: "Snapdragon LLVM ARM Compiler 4.0.5 (based on llvm.org 4.0+)", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, enums: !2) 77 !1 = !DIFile(filename: "t.c", directory: "/prj/llvm-arm/scratch1/zhaoshiz/bugs/debug-symbol") 78 !2 = !{} 79 !3 = !{i32 2, !"Dwarf Version", i32 4} 80 !4 = !{i32 2, !"Debug Info Version", i32 3} 81 !5 = !{i32 1, !"wchar_size", i32 4} 82 !6 = !{i32 1, !"min_enum_size", i32 4} 83 !7 = !{!"Snapdragon LLVM ARM Compiler 4.0.5 (based on llvm.org 4.0+)"} 84 !8 = distinct !DISubprogram(name: "goo", scope: !1, file: !1, line: 23, type: !9, isLocal: false, isDefinition: true, scopeLine: 23, flags: DIFlagPrototyped, isOptimized: true, unit: !0, retainedNodes: !12) 85 !9 = !DISubroutineType(types: !10) 86 !10 = !{!11, !11, !11} 87 !11 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed) 88 !12 = !{!13, !14} 89 !13 = !DILocalVariable(name: "a", arg: 1, scope: !8, file: !1, line: 23, type: !11) 90 !14 = !DILocalVariable(name: "b", arg: 2, scope: !8, file: !1, line: 23, type: !11) 91 !15 = !DIExpression() 92 !16 = !DILocation(line: 23, column: 14, scope: !8) 93 !17 = !DILocation(line: 23, column: 21, scope: !8) 94 !18 = !DILocalVariable(name: "a", arg: 1, scope: !19, file: !1, line: 3, type: !11) 95 !19 = distinct !DISubprogram(name: "lee1", scope: !1, file: !1, line: 3, type: !9, isLocal: true, isDefinition: true, scopeLine: 3, flags: DIFlagPrototyped, isOptimized: true, unit: !0, retainedNodes: !20) 96 !20 = !{!18, !21, !22, !23} 97 !21 = !DILocalVariable(name: "b", arg: 2, scope: !19, file: !1, line: 3, type: !11) 98 !22 = !DILocalVariable(name: "t", scope: !19, file: !1, line: 4, type: !11) 99 !23 = !DILocalVariable(name: "i", scope: !24, file: !1, line: 5, type: !25) 100 !24 = distinct !DILexicalBlock(scope: !19, file: !1, line: 5, column: 3) 101 !25 = !DIBasicType(name: "unsigned int", size: 32, encoding: DW_ATE_unsigned) 102 !26 = !DILocation(line: 3, column: 22, scope: !19, inlinedAt: !27) 103 !27 = distinct !DILocation(line: 24, column: 27, scope: !8) 104 !28 = !DILocation(line: 3, column: 29, scope: !19, inlinedAt: !27) 105 !29 = !DILocation(line: 4, column: 7, scope: !19, inlinedAt: !27) 106 !30 = !DILocation(line: 5, column: 17, scope: !24, inlinedAt: !27) 107 !31 = !DILocation(line: 5, column: 23, scope: !32, inlinedAt: !27) 108 !32 = distinct !DILexicalBlock(scope: !24, file: !1, line: 5, column: 3) 109 !33 = !DILocation(line: 5, column: 3, scope: !24, inlinedAt: !27) 110 !34 = !DILocation(line: 6, column: 13, scope: !32, inlinedAt: !27) 111 !35 = !DILocation(line: 6, column: 11, scope: !32, inlinedAt: !27) 112 !36 = !DILocation(line: 6, column: 7, scope: !32, inlinedAt: !27) 113 !37 = !DILocation(line: 5, column: 28, scope: !32, inlinedAt: !27) 114 !38 = distinct !{!38, !39, !40} 115 !39 = !DILocation(line: 5, column: 3, scope: !24) 116 !40 = !DILocation(line: 6, column: 14, scope: !24) 117 !41 = !DILocation(line: 11, column: 12, scope: !42, inlinedAt: !46) 118 !42 = distinct !DISubprogram(name: "lee2", scope: !1, file: !1, line: 10, type: !9, isLocal: true, isDefinition: true, scopeLine: 10, flags: DIFlagPrototyped, isOptimized: true, unit: !0, retainedNodes: !43) 119 !43 = !{!44, !45} 120 !44 = !DILocalVariable(name: "a", arg: 1, scope: !42, file: !1, line: 10, type: !11) 121 !45 = !DILocalVariable(name: "b", arg: 2, scope: !42, file: !1, line: 10, type: !11) 122 !46 = distinct !DILocation(line: 24, column: 40, scope: !8) 123 !47 = !DILocation(line: 10, column: 22, scope: !42, inlinedAt: !46) 124 !48 = !DILocation(line: 10, column: 29, scope: !42, inlinedAt: !46) 125 !49 = !DILocation(line: 11, column: 20, scope: !42, inlinedAt: !46) 126 !50 = !DILocation(line: 11, column: 16, scope: !42, inlinedAt: !46) 127 !51 = !DILocation(line: 24, column: 38, scope: !8) 128 !52 = !DILocation(line: 24, column: 3, scope: !8) 129