llvm.org GIT mirror llvm / 46b810c
[Unroll][DebugInfo] Propagate loop body's debug location to epilog preheader NewExit and epilog PreHeader should has the same debug loc as the original loop body, instead of original loop exit. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@321465 91177308-0d34-0410-b5e6-96231b3b80d8 Zhaoshi Zheng 1 year, 9 months ago
3 changed file(s) with 138 addition(s) and 3 deletion(s). Raw diff Collapse all Expand all
647647 SmallVector Preds(predecessors(LatchExit));
648648 NewExit = SplitBlockPredecessors(LatchExit, Preds, ".unr-lcssa",
649649 DT, LI, PreserveLCSSA);
650 // NewExit gets its DebugLoc from LatchExit, which is not part of the
651 // original Loop.
652 // Fix this by setting Loop's DebugLoc to NewExit.
653 auto *NewExitTerminator = NewExit->getTerminator();
654 NewExitTerminator->setDebugLoc(Header->getTerminator()->getDebugLoc());
650655 // Split NewExit to insert epilog remainder loop.
651 EpilogPreHeader = SplitBlock(NewExit, NewExit->getTerminator(), DT, LI);
656 EpilogPreHeader = SplitBlock(NewExit, NewExitTerminator, DT, LI);
652657 EpilogPreHeader->setName(Header->getName() + ".epil.preheader");
653658 } else {
654659 // If prolog remainder
0 ; RUN: opt -loop-unroll -unroll-runtime -unroll-runtime-epilog -S %s | FileCheck %s
1
2 ; Test that epilogue is tagged with the same debug information as original loop body rather than original loop exit.
3
4 ; CHECK: for.body.i:
5 ; CHECK: br i1 {{.*}}, label %lee1.exit.loopexit.unr-lcssa.loopexit, label %for.body.i, !dbg ![[LOOP_LOC:[0-9]+]]
6 ; CHECK: lee1.exit.loopexit.unr-lcssa.loopexit:
7 ; CHECK: br label %lee1.exit.loopexit.unr-lcssa, !dbg ![[LOOP_LOC]]
8 ; CHECK: lee1.exit.loopexit.unr-lcssa:
9 ; CHECK: %lcmp.mod = icmp ne i32 %xtraiter, 0, !dbg ![[LOOP_LOC]]
10 ; CHECK: br i1 %lcmp.mod, label %for.body.i.epil.preheader, label %lee1.exit.loopexit, !dbg ![[LOOP_LOC]]
11 ; CHECK: for.body.i.epil.preheader:
12 ; CHECK: br label %for.body.i.epil, !dbg ![[LOOP_LOC]]
13 ; CHECK: lee1.exit.loopexit:
14 ; CHECK: br label %lee1.exit, !dbg ![[EXIT_LOC:[0-9]+]]
15
16 ; CHECK-DAG: ![[LOOP_LOC]] = !DILocation(line: 5, column: 3, scope: !{{.*}}, inlinedAt: !{{.*}})
17 ; CHECK-DAG: ![[EXIT_LOC]] = !DILocation(line: 11, column: 12, scope: !{{.*}}, inlinedAt: !{{.*}})
18
19 ; Function Attrs: nounwind readnone
20 define i32 @goo(i32 %a, i32 %b) local_unnamed_addr #0 !dbg !8 {
21 entry:
22 tail call void @llvm.dbg.value(metadata i32 %a, i64 0, metadata !13, metadata !15), !dbg !16
23 tail call void @llvm.dbg.value(metadata i32 %b, i64 0, metadata !14, metadata !15), !dbg !17
24 tail call void @llvm.dbg.value(metadata i32 %a, i64 0, metadata !18, metadata !15), !dbg !26
25 tail call void @llvm.dbg.value(metadata i32 %b, i64 0, metadata !21, metadata !15), !dbg !28
26 tail call void @llvm.dbg.value(metadata i32 0, i64 0, metadata !22, metadata !15), !dbg !29
27 tail call void @llvm.dbg.value(metadata i32 0, i64 0, metadata !23, metadata !15), !dbg !30
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 !22, metadata !15), !dbg !29
30 %cmp7.i = icmp eq i32 %b, 0, !dbg !31
31 br i1 %cmp7.i, label %lee1.exit, label %for.body.i.preheader, !dbg !33
32
33 for.body.i.preheader: ; preds = %entry
34 br label %for.body.i, !dbg !34
35
36 for.body.i: ; preds = %for.body.i.preheader, %for.body.i
37 %i.09.i = phi i32 [ %inc.i, %for.body.i ], [ 0, %for.body.i.preheader ]
38 %t.08.i = phi i32 [ %add1.i, %for.body.i ], [ 0, %for.body.i.preheader ]
39 %div.i = sdiv i32 %t.08.i, 2, !dbg !34
40 %add.i = add i32 %t.08.i, %a, !dbg !35
41 %add1.i = add i32 %add.i, %div.i, !dbg !36
42 tail call void @llvm.dbg.value(metadata i32 %add1.i, i64 0, metadata !22, metadata !15), !dbg !29
43 %inc.i = add nuw i32 %i.09.i, 1, !dbg !37
44 tail call void @llvm.dbg.value(metadata i32 %inc.i, i64 0, metadata !23, metadata !15), !dbg !30
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 %add1.i, i64 0, metadata !22, metadata !15), !dbg !29
47 %exitcond.i = icmp eq i32 %inc.i, %b, !dbg !31
48 br i1 %exitcond.i, label %lee1.exit.loopexit, label %for.body.i, !dbg !33, !llvm.loop !38
49
50 lee1.exit.loopexit: ; preds = %for.body.i
51 %add1.i.lcssa = phi i32 [ %add1.i, %for.body.i ]
52 br label %lee1.exit, !dbg !41
53
54 lee1.exit: ; preds = %lee1.exit.loopexit, %entry
55 %t.0.lcssa.i = phi i32 [ 0, %entry ], [ %add1.i.lcssa, %lee1.exit.loopexit ]
56 tail call void @llvm.dbg.value(metadata i32 %a, i64 0, metadata !44, metadata !15), !dbg !47
57 tail call void @llvm.dbg.value(metadata i32 %b, i64 0, metadata !45, metadata !15), !dbg !48
58 %add.i4 = add nsw i32 %b, %a, !dbg !41
59 %sub.i = sub nsw i32 %a, %b, !dbg !49
60 %mul.i = mul nsw i32 %add.i4, %sub.i, !dbg !50
61 %add = add nsw i32 %t.0.lcssa.i, %mul.i, !dbg !51
62 ret i32 %add, !dbg !52
63 }
64
65 ; Function Attrs: nounwind readnone
66 declare void @llvm.dbg.value(metadata, i64, metadata, metadata) #1
67
68 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" }
69 attributes #1 = { nounwind readnone }
70
71 !llvm.dbg.cu = !{!0}
72 !llvm.module.flags = !{!3, !4, !5, !6}
73 !llvm.ident = !{!7}
74
75 !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)
76 !1 = !DIFile(filename: "t.c", directory: "/prj/llvm-arm/scratch1/zhaoshiz/bugs/debug-symbol")
77 !2 = !{}
78 !3 = !{i32 2, !"Dwarf Version", i32 4}
79 !4 = !{i32 2, !"Debug Info Version", i32 3}
80 !5 = !{i32 1, !"wchar_size", i32 4}
81 !6 = !{i32 1, !"min_enum_size", i32 4}
82 !7 = !{!"Snapdragon LLVM ARM Compiler 4.0.5 (based on llvm.org 4.0+)"}
83 !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, variables: !12)
84 !9 = !DISubroutineType(types: !10)
85 !10 = !{!11, !11, !11}
86 !11 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)
87 !12 = !{!13, !14}
88 !13 = !DILocalVariable(name: "a", arg: 1, scope: !8, file: !1, line: 23, type: !11)
89 !14 = !DILocalVariable(name: "b", arg: 2, scope: !8, file: !1, line: 23, type: !11)
90 !15 = !DIExpression()
91 !16 = !DILocation(line: 23, column: 14, scope: !8)
92 !17 = !DILocation(line: 23, column: 21, scope: !8)
93 !18 = !DILocalVariable(name: "a", arg: 1, scope: !19, file: !1, line: 3, type: !11)
94 !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, variables: !20)
95 !20 = !{!18, !21, !22, !23}
96 !21 = !DILocalVariable(name: "b", arg: 2, scope: !19, file: !1, line: 3, type: !11)
97 !22 = !DILocalVariable(name: "t", scope: !19, file: !1, line: 4, type: !11)
98 !23 = !DILocalVariable(name: "i", scope: !24, file: !1, line: 5, type: !25)
99 !24 = distinct !DILexicalBlock(scope: !19, file: !1, line: 5, column: 3)
100 !25 = !DIBasicType(name: "unsigned int", size: 32, encoding: DW_ATE_unsigned)
101 !26 = !DILocation(line: 3, column: 22, scope: !19, inlinedAt: !27)
102 !27 = distinct !DILocation(line: 24, column: 27, scope: !8)
103 !28 = !DILocation(line: 3, column: 29, scope: !19, inlinedAt: !27)
104 !29 = !DILocation(line: 4, column: 7, scope: !19, inlinedAt: !27)
105 !30 = !DILocation(line: 5, column: 17, scope: !24, inlinedAt: !27)
106 !31 = !DILocation(line: 5, column: 23, scope: !32, inlinedAt: !27)
107 !32 = distinct !DILexicalBlock(scope: !24, file: !1, line: 5, column: 3)
108 !33 = !DILocation(line: 5, column: 3, scope: !24, inlinedAt: !27)
109 !34 = !DILocation(line: 6, column: 13, scope: !32, inlinedAt: !27)
110 !35 = !DILocation(line: 6, column: 11, scope: !32, inlinedAt: !27)
111 !36 = !DILocation(line: 6, column: 7, scope: !32, inlinedAt: !27)
112 !37 = !DILocation(line: 5, column: 28, scope: !32, inlinedAt: !27)
113 !38 = distinct !{!38, !39, !40}
114 !39 = !DILocation(line: 5, column: 3, scope: !24)
115 !40 = !DILocation(line: 6, column: 14, scope: !24)
116 !41 = !DILocation(line: 11, column: 12, scope: !42, inlinedAt: !46)
117 !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, variables: !43)
118 !43 = !{!44, !45}
119 !44 = !DILocalVariable(name: "a", arg: 1, scope: !42, file: !1, line: 10, type: !11)
120 !45 = !DILocalVariable(name: "b", arg: 2, scope: !42, file: !1, line: 10, type: !11)
121 !46 = distinct !DILocation(line: 24, column: 40, scope: !8)
122 !47 = !DILocation(line: 10, column: 22, scope: !42, inlinedAt: !46)
123 !48 = !DILocation(line: 10, column: 29, scope: !42, inlinedAt: !46)
124 !49 = !DILocation(line: 11, column: 20, scope: !42, inlinedAt: !46)
125 !50 = !DILocation(line: 11, column: 16, scope: !42, inlinedAt: !46)
126 !51 = !DILocation(line: 24, column: 38, scope: !8)
127 !52 = !DILocation(line: 24, column: 3, scope: !8)
1212 ; EPILOG: br i1 %niter.ncmp.1, label %for.end.loopexit.unr-lcssa.loopexit, label %for.body, !dbg [[BODY_LOC:![0-9]+]]
1313 ; EPILOG-NOT: br i1 %niter.ncmp.2, label %for.end.loopexit{{.*}}, label %for.body
1414 ; EPILOG: for.body.epil.preheader:
15 ; EPILOG: br label %for.body.epil, !dbg [[EXIT_LOC:![0-9]+]]
15 ; EPILOG: br label %for.body.epil, !dbg [[BODY_LOC]]
1616 ; EPILOG: for.body.epil:
17 ; EPILOG: br label %for.end.loopexit.epilog-lcssa, !dbg [[BODY_LOC:![0-9]+]]
17 ; EPILOG: br label %for.end.loopexit.epilog-lcssa, !dbg [[BODY_LOC]]
18 ; EPILOG: for.end.loopexit:
19 ; EPILOG: br label %for.end, !dbg [[EXIT_LOC:![0-9]+]]
1820
1921 ; EPILOG-DAG: [[PH_LOC]] = !DILocation(line: 101, column: 1, scope: !{{.*}})
2022 ; EPILOG-DAG: [[BODY_LOC]] = !DILocation(line: 102, column: 1, scope: !{{.*}})