139 lines · plain
1; RUN: opt -passes=loop-unroll -unroll-runtime -unroll-runtime-epilog -S %s | FileCheck %s2 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, label %for.body.i, !dbg ![[LOOP_LOC:[0-9]+]]7; CHECK: lee1.exit.loopexit.unr-lcssa:8; CHECK: %lcmp.mod = icmp ne i32 %xtraiter, 0, !dbg ![[LOOP_LOC]]9; CHECK: br i1 %lcmp.mod, label %for.body.i.epil.preheader, label %lee1.exit.loopexit, !dbg ![[LOOP_LOC]]10; CHECK: for.body.i.epil.preheader:11; CHECK: br label %for.body.i.epil, !dbg ![[LOOP_LOC]]12; CHECK: for.body.i.epil:13;; Ensure that when we clone the div/add/add and its following dbg.values,14;; those dbg.values are remapped to the duplicated adds, not the originals.15; CHECK: %div.i.epil = sdiv i32 %t.08.i.epil, 2,16; CHECK-NEXT: %add.i.epil = add i32 %t.08.i.epil, %a,17; CHECK-NEXT: %add1.i.epil = add i32 %add.i.epil, %div.i.epil,18; CHECK-NEXT: #dbg_value(i32 %add1.i.epil,19; CHECK-NEXT: %inc.i.epil = add nuw i32 %i.09.i.epil, 1, !dbg !3620; CHECK-NEXT: #dbg_value(i32 %inc.i.epil,21; CHECK-NEXT: #dbg_value(i32 %inc.i.epil,22; CHECK-NEXT: #dbg_value(i32 %add1.i.epil,23 24; CHECK: lee1.exit.loopexit:25; CHECK: br label %lee1.exit, !dbg ![[EXIT_LOC:[0-9]+]]26 27; CHECK-DAG: ![[LOOP_LOC]] = !DILocation(line: 5, column: 3, scope: !{{.*}}, inlinedAt: !{{.*}})28; CHECK-DAG: ![[EXIT_LOC]] = !DILocation(line: 11, column: 12, scope: !{{.*}}, inlinedAt: !{{.*}})29 30; Function Attrs: nounwind readnone31define i32 @goo(i32 %a, i32 %b) local_unnamed_addr #0 !dbg !8 {32entry:33 tail call void @llvm.dbg.value(metadata i32 %a, i64 0, metadata !13, metadata !15), !dbg !1634 tail call void @llvm.dbg.value(metadata i32 %b, i64 0, metadata !14, metadata !15), !dbg !1735 tail call void @llvm.dbg.value(metadata i32 %a, i64 0, metadata !18, metadata !15), !dbg !2636 tail call void @llvm.dbg.value(metadata i32 %b, i64 0, metadata !21, metadata !15), !dbg !2837 tail call void @llvm.dbg.value(metadata i32 0, i64 0, metadata !22, metadata !15), !dbg !2938 tail call void @llvm.dbg.value(metadata i32 0, i64 0, metadata !23, metadata !15), !dbg !3039 tail call void @llvm.dbg.value(metadata i32 0, i64 0, metadata !23, metadata !15), !dbg !3040 tail call void @llvm.dbg.value(metadata i32 0, i64 0, metadata !22, metadata !15), !dbg !2941 %cmp7.i = icmp eq i32 %b, 0, !dbg !3142 br i1 %cmp7.i, label %lee1.exit, label %for.body.i.preheader, !dbg !3343 44for.body.i.preheader: ; preds = %entry45 br label %for.body.i, !dbg !3446 47for.body.i: ; preds = %for.body.i.preheader, %for.body.i48 %i.09.i = phi i32 [ %inc.i, %for.body.i ], [ 0, %for.body.i.preheader ]49 %t.08.i = phi i32 [ %add1.i, %for.body.i ], [ 0, %for.body.i.preheader ]50 %div.i = sdiv i32 %t.08.i, 2, !dbg !3451 %add.i = add i32 %t.08.i, %a, !dbg !3552 %add1.i = add i32 %add.i, %div.i, !dbg !3653 tail call void @llvm.dbg.value(metadata i32 %add1.i, i64 0, metadata !22, metadata !15), !dbg !2954 %inc.i = add nuw i32 %i.09.i, 1, !dbg !3755 tail call void @llvm.dbg.value(metadata i32 %inc.i, i64 0, metadata !23, metadata !15), !dbg !3056 tail call void @llvm.dbg.value(metadata i32 %inc.i, i64 0, metadata !23, metadata !15), !dbg !3057 tail call void @llvm.dbg.value(metadata i32 %add1.i, i64 0, metadata !22, metadata !15), !dbg !2958 %exitcond.i = icmp eq i32 %inc.i, %b, !dbg !3159 br i1 %exitcond.i, label %lee1.exit.loopexit, label %for.body.i, !dbg !33, !llvm.loop !3860 61lee1.exit.loopexit: ; preds = %for.body.i62 %add1.i.lcssa = phi i32 [ %add1.i, %for.body.i ]63 br label %lee1.exit, !dbg !4164 65lee1.exit: ; preds = %lee1.exit.loopexit, %entry66 %t.0.lcssa.i = phi i32 [ 0, %entry ], [ %add1.i.lcssa, %lee1.exit.loopexit ]67 tail call void @llvm.dbg.value(metadata i32 %a, i64 0, metadata !44, metadata !15), !dbg !4768 tail call void @llvm.dbg.value(metadata i32 %b, i64 0, metadata !45, metadata !15), !dbg !4869 %add.i4 = add nsw i32 %b, %a, !dbg !4170 %sub.i = sub nsw i32 %a, %b, !dbg !4971 %mul.i = mul nsw i32 %add.i4, %sub.i, !dbg !5072 %add = add nsw i32 %t.0.lcssa.i, %mul.i, !dbg !5173 ret i32 %add, !dbg !5274}75 76; Function Attrs: nounwind readnone77declare void @llvm.dbg.value(metadata, i64, metadata, metadata) #178 79attributes #0 = { nounwind readnone "correctly-rounded-divide-sqrt-fp-math"="false" "disable-tail-calls"="false" "less-precise-fpmad"="false" "frame-pointer"="all" "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,-fp-armv8,-fp16,-vfp4" "use-soft-float"="false" }80attributes #1 = { nounwind readnone }81 82!llvm.dbg.cu = !{!0}83!llvm.module.flags = !{!3, !4, !5, !6}84!llvm.ident = !{!7}85 86!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)87!1 = !DIFile(filename: "t.c", directory: "/prj/llvm-arm/scratch1/zhaoshiz/bugs/debug-symbol")88!2 = !{}89!3 = !{i32 2, !"Dwarf Version", i32 4}90!4 = !{i32 2, !"Debug Info Version", i32 3}91!5 = !{i32 1, !"wchar_size", i32 4}92!6 = !{i32 1, !"min_enum_size", i32 4}93!7 = !{!"Snapdragon LLVM ARM Compiler 4.0.5 (based on llvm.org 4.0+)"}94!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)95!9 = !DISubroutineType(types: !10)96!10 = !{!11, !11, !11}97!11 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)98!12 = !{!13, !14}99!13 = !DILocalVariable(name: "a", arg: 1, scope: !8, file: !1, line: 23, type: !11)100!14 = !DILocalVariable(name: "b", arg: 2, scope: !8, file: !1, line: 23, type: !11)101!15 = !DIExpression()102!16 = !DILocation(line: 23, column: 14, scope: !8)103!17 = !DILocation(line: 23, column: 21, scope: !8)104!18 = !DILocalVariable(name: "a", arg: 1, scope: !19, file: !1, line: 3, type: !11)105!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)106!20 = !{!18, !21, !22, !23}107!21 = !DILocalVariable(name: "b", arg: 2, scope: !19, file: !1, line: 3, type: !11)108!22 = !DILocalVariable(name: "t", scope: !19, file: !1, line: 4, type: !11)109!23 = !DILocalVariable(name: "i", scope: !24, file: !1, line: 5, type: !25)110!24 = distinct !DILexicalBlock(scope: !19, file: !1, line: 5, column: 3)111!25 = !DIBasicType(name: "unsigned int", size: 32, encoding: DW_ATE_unsigned)112!26 = !DILocation(line: 3, column: 22, scope: !19, inlinedAt: !27)113!27 = distinct !DILocation(line: 24, column: 27, scope: !8)114!28 = !DILocation(line: 3, column: 29, scope: !19, inlinedAt: !27)115!29 = !DILocation(line: 4, column: 7, scope: !19, inlinedAt: !27)116!30 = !DILocation(line: 5, column: 17, scope: !24, inlinedAt: !27)117!31 = !DILocation(line: 5, column: 23, scope: !32, inlinedAt: !27)118!32 = distinct !DILexicalBlock(scope: !24, file: !1, line: 5, column: 3)119!33 = !DILocation(line: 5, column: 3, scope: !24, inlinedAt: !27)120!34 = !DILocation(line: 6, column: 13, scope: !32, inlinedAt: !27)121!35 = !DILocation(line: 6, column: 11, scope: !32, inlinedAt: !27)122!36 = !DILocation(line: 6, column: 7, scope: !32, inlinedAt: !27)123!37 = !DILocation(line: 5, column: 28, scope: !32, inlinedAt: !27)124!38 = distinct !{!38, !39, !40}125!39 = !DILocation(line: 5, column: 3, scope: !24, inlinedAt: !27)126!40 = !DILocation(line: 6, column: 14, scope: !24, inlinedAt: !27)127!41 = !DILocation(line: 11, column: 12, scope: !42, inlinedAt: !46)128!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)129!43 = !{!44, !45}130!44 = !DILocalVariable(name: "a", arg: 1, scope: !42, file: !1, line: 10, type: !11)131!45 = !DILocalVariable(name: "b", arg: 2, scope: !42, file: !1, line: 10, type: !11)132!46 = distinct !DILocation(line: 24, column: 40, scope: !8)133!47 = !DILocation(line: 10, column: 22, scope: !42, inlinedAt: !46)134!48 = !DILocation(line: 10, column: 29, scope: !42, inlinedAt: !46)135!49 = !DILocation(line: 11, column: 20, scope: !42, inlinedAt: !46)136!50 = !DILocation(line: 11, column: 16, scope: !42, inlinedAt: !46)137!51 = !DILocation(line: 24, column: 38, scope: !8)138!52 = !DILocation(line: 24, column: 3, scope: !8)139