1 ; RUN: llc -start-after=codegenprepare -stop-before finalize-isel -o - %s | FileCheck %s
3 ; This test case is a modified version of dbg_value_phi_isel1.ll
4 ; where the llvm.dbg.value nodes in for.body has been moved.
7 source_filename = "debug.c"
8 target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
9 target triple = "x86_64-unknown-linux-gnu"
11 @end = dso_local local_unnamed_addr global i32 10, align 4, !dbg !0
13 ; Function Attrs: nounwind uwtable
14 define dso_local i32 @main() local_unnamed_addr #0 !dbg !11 {
16 %arr = alloca [80 x i32], align 16
17 call void @llvm.dbg.value(metadata i32 9, metadata !15, metadata !DIExpression()), !dbg !26
18 call void @llvm.dbg.value(metadata i32 13, metadata !16, metadata !DIExpression()), !dbg !27
19 call void @llvm.dbg.value(metadata i32 0, metadata !17, metadata !DIExpression()), !dbg !28
20 %0 = load i32, i32* @end, align 4, !dbg !29, !tbaa !31
21 %cmp20 = icmp sgt i32 %0, 0, !dbg !35
22 br i1 %cmp20, label %for.body.lr.ph, label %for.cond.cleanup, !dbg !36
24 for.body.lr.ph: ; preds = %entry
25 %1 = load i32, i32* @end, align 4, !tbaa !31
26 br label %for.body, !dbg !36
28 for.cond.cleanup: ; preds = %for.body, %entry
29 ; CHECK-LABEL: bb.{{.*}}.for.cond.cleanup:
30 ; CHECK: [[REG1:%[0-9]+]]:gr32 = PHI
31 ; CHECK-NEXT: DBG_VALUE [[REG1]]
32 %x.0.lcssa = phi i32 [ 9, %entry ], [ %add, %for.body ]
33 call void @llvm.dbg.value(metadata i32 %x.0.lcssa, metadata !15, metadata !DIExpression()), !dbg !26
34 %2 = bitcast [80 x i32]* %arr to i8*, !dbg !37
35 call void @llvm.lifetime.start.p0i8(i64 320, i8* nonnull %2) #3, !dbg !37
36 call void @llvm.dbg.declare(metadata [80 x i32]* %arr, metadata !19, metadata !DIExpression()), !dbg !38
37 call void @llvm.dbg.value(metadata i32 0, metadata !24, metadata !DIExpression()), !dbg !39
38 br label %for.body4, !dbg !40
40 for.body: ; preds = %for.body.lr.ph, %for.body
41 ; CHECK-LABEL: bb.{{.*}}.for.body:
42 ; CHECK: [[REG2:%[0-9]+]]:gr32 = PHI
43 ; CHECK-NEXT: [[REG3:%[0-9]+]]:gr32 = PHI
44 ; CHECK-NEXT: [[REG4:%[0-9]+]]:gr32 = PHI
45 ; CHECK-NEXT: DBG_VALUE [[REG3]], $noreg, !16
46 ; CHECK-NEXT: DBG_VALUE 555, $noreg, !17
47 ; CHECK-NEXT: [[ADDREG:%[0-9]+]]:gr32 = nuw nsw ADD32rr
48 ; CHECK-NEXT: DBG_VALUE [[REG2]], $noreg, !17
49 ; CHECK: [[MULREG:%[0-9]+]]:gr32 = LEA64_32r
50 ; CHECK-NEXT: DBG_VALUE 777, $noreg, !17
51 ; XXX: The following DBG_VALUE should have stayed below the INC32r
52 ; CHECK-NEXT: DBG_VALUE [[MULREG]], $noreg, !16
53 ; CHECK-NEXT: [[INCREG:%[0-9]+]]:gr32 = nuw nsw INC32r
54 ; CHECK-NEXT: DBG_VALUE [[INCREG]], $noreg, !17
55 ; CHECK-NEXT: DBG_VALUE [[ADDREG]], $noreg, !15
56 ; CHECK-NEXT: implicit-def $eflags,
57 ; CHECK-NEXT: DBG_VALUE [[REG4]]
58 %u.023 = phi i32 [ 0, %for.body.lr.ph ], [ %inc, %for.body ]
59 %y.022 = phi i32 [ 13, %for.body.lr.ph ], [ %mul, %for.body ]
60 %x.021 = phi i32 [ 9, %for.body.lr.ph ], [ %add, %for.body ]
61 call void @llvm.dbg.value(metadata i32 %y.022, metadata !16, metadata !DIExpression()), !dbg !27
62 ; This dbg.value has been manually added compared to dbg_value_phi_isel1.ll
63 call void @llvm.dbg.value(metadata i32 555, metadata !17, metadata !DIExpression()), !dbg !28
64 %add = add nuw nsw i32 %y.022, %x.021, !dbg !41
65 ; This dbg.value has been manually moved compared to dbg_value_phi_isel1.ll
66 call void @llvm.dbg.value(metadata i32 %u.023, metadata !17, metadata !DIExpression()), !dbg !28
67 %mul = mul nsw i32 %y.022, 3, !dbg !43
68 ; This dbg.value has been manually added compared to dbg_value_phi_isel1.ll
69 call void @llvm.dbg.value(metadata i32 777, metadata !17, metadata !DIExpression()), !dbg !28
70 %inc = add nuw nsw i32 %u.023, 1, !dbg !44
71 call void @llvm.dbg.value(metadata i32 %inc, metadata !17, metadata !DIExpression()), !dbg !28
72 call void @llvm.dbg.value(metadata i32 %mul, metadata !16, metadata !DIExpression()), !dbg !27
73 call void @llvm.dbg.value(metadata i32 %add, metadata !15, metadata !DIExpression()), !dbg !26
74 %cmp = icmp slt i32 %inc, %1, !dbg !35
75 ; This dbg.value has been manually moved compared to dbg_value_phi_isel1.ll
76 call void @llvm.dbg.value(metadata i32 %x.021, metadata !15, metadata !DIExpression()), !dbg !26
77 br i1 %cmp, label %for.body, label %for.cond.cleanup, !dbg !36, !llvm.loop !45
79 for.cond.cleanup3: ; preds = %for.body4
80 call void @llvm.lifetime.end.p0i8(i64 320, i8* nonnull %2) #3, !dbg !47
81 ret i32 %x.0.lcssa, !dbg !48
83 for.body4: ; preds = %for.body4, %for.cond.cleanup
84 %indvars.iv = phi i64 [ 0, %for.cond.cleanup ], [ %indvars.iv.next, %for.body4 ]
85 call void @llvm.dbg.value(metadata i64 %indvars.iv, metadata !24, metadata !DIExpression()), !dbg !39
86 %arrayidx = getelementptr inbounds [80 x i32], [80 x i32]* %arr, i64 0, i64 %indvars.iv, !dbg !49
87 %3 = trunc i64 %indvars.iv to i32, !dbg !52
88 %4 = add i32 %3, 3, !dbg !52
89 store volatile i32 %4, i32* %arrayidx, align 4, !dbg !52, !tbaa !31
90 %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1, !dbg !53
91 call void @llvm.dbg.value(metadata i32 undef, metadata !24, metadata !DIExpression(DW_OP_plus_uconst, 1, DW_OP_stack_value)), !dbg !39
92 %exitcond = icmp eq i64 %indvars.iv.next, 64, !dbg !54
93 br i1 %exitcond, label %for.cond.cleanup3, label %for.body4, !dbg !40, !llvm.loop !55
96 ; Function Attrs: argmemonly nounwind
97 declare void @llvm.lifetime.start.p0i8(i64, i8* nocapture) #1
99 ; Function Attrs: nounwind readnone speculatable
100 declare void @llvm.dbg.declare(metadata, metadata, metadata) #2
102 ; Function Attrs: argmemonly nounwind
103 declare void @llvm.lifetime.end.p0i8(i64, i8* nocapture) #1
105 ; Function Attrs: nounwind readnone speculatable
106 declare void @llvm.dbg.value(metadata, metadata, metadata) #2
108 attributes #0 = { nounwind uwtable }
109 attributes #1 = { argmemonly nounwind }
110 attributes #2 = { nounwind readnone speculatable }
111 attributes #3 = { nounwind }
114 !llvm.module.flags = !{!7, !8, !9}
117 !0 = !DIGlobalVariableExpression(var: !1, expr: !DIExpression())
118 !1 = distinct !DIGlobalVariable(name: "end", scope: !2, file: !3, line: 1, type: !6, isLocal: false, isDefinition: true)
119 !2 = distinct !DICompileUnit(language: DW_LANG_C99, file: !3, producer: "clang version 7.0.0 (x)", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, enums: !4, globals: !5)
120 !3 = !DIFile(filename: "debug.c", directory: "")
123 !6 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)
124 !7 = !{i32 2, !"Dwarf Version", i32 4}
125 !8 = !{i32 2, !"Debug Info Version", i32 3}
126 !9 = !{i32 1, !"wchar_size", i32 4}
127 !10 = !{!"clang version 7.0.0 (x)"}
128 !11 = distinct !DISubprogram(name: "main", scope: !3, file: !3, line: 3, type: !12, isLocal: false, isDefinition: true, scopeLine: 3, isOptimized: true, unit: !2, retainedNodes: !14)
129 !12 = !DISubroutineType(types: !13)
131 !14 = !{!15, !16, !17, !19, !24}
132 !15 = !DILocalVariable(name: "x", scope: !11, file: !3, line: 4, type: !6)
133 !16 = !DILocalVariable(name: "y", scope: !11, file: !3, line: 5, type: !6)
134 !17 = !DILocalVariable(name: "u", scope: !18, file: !3, line: 6, type: !6)
135 !18 = distinct !DILexicalBlock(scope: !11, file: !3, line: 6, column: 3)
136 !19 = !DILocalVariable(name: "arr", scope: !11, file: !3, line: 11, type: !20)
137 !20 = !DICompositeType(tag: DW_TAG_array_type, baseType: !21, size: 2560, elements: !22)
138 !21 = !DIDerivedType(tag: DW_TAG_volatile_type, baseType: !6)
140 !23 = !DISubrange(count: 80)
141 !24 = !DILocalVariable(name: "q", scope: !25, file: !3, line: 12, type: !6)
142 !25 = distinct !DILexicalBlock(scope: !11, file: !3, line: 12, column: 3)
143 !26 = !DILocation(line: 4, column: 7, scope: !11)
144 !27 = !DILocation(line: 5, column: 7, scope: !11)
145 !28 = !DILocation(line: 6, column: 12, scope: !18)
146 !29 = !DILocation(line: 6, column: 23, scope: !30)
147 !30 = distinct !DILexicalBlock(scope: !18, file: !3, line: 6, column: 3)
148 !31 = !{!32, !32, i64 0}
149 !32 = !{!"int", !33, i64 0}
150 !33 = !{!"omnipotent char", !34, i64 0}
151 !34 = !{!"Simple C/C++ TBAA"}
152 !35 = !DILocation(line: 6, column: 21, scope: !30)
153 !36 = !DILocation(line: 6, column: 3, scope: !18)
154 !37 = !DILocation(line: 11, column: 3, scope: !11)
155 !38 = !DILocation(line: 11, column: 16, scope: !11)
156 !39 = !DILocation(line: 12, column: 12, scope: !25)
157 !40 = !DILocation(line: 12, column: 3, scope: !25)
158 !41 = !DILocation(line: 7, column: 7, scope: !42)
159 !42 = distinct !DILexicalBlock(scope: !30, file: !3, line: 6, column: 33)
160 !43 = !DILocation(line: 8, column: 11, scope: !42)
161 !44 = !DILocation(line: 6, column: 28, scope: !30)
162 !45 = distinct !{!45, !36, !46}
163 !46 = !DILocation(line: 9, column: 3, scope: !18)
164 !47 = !DILocation(line: 17, column: 1, scope: !11)
165 !48 = !DILocation(line: 16, column: 3, scope: !11)
166 !49 = !DILocation(line: 13, column: 5, scope: !50)
167 !50 = distinct !DILexicalBlock(scope: !51, file: !3, line: 12, column: 32)
168 !51 = distinct !DILexicalBlock(scope: !25, file: !3, line: 12, column: 3)
169 !52 = !DILocation(line: 13, column: 12, scope: !50)
170 !53 = !DILocation(line: 12, column: 27, scope: !51)
171 !54 = !DILocation(line: 12, column: 21, scope: !51)
172 !55 = distinct !{!55, !40, !56}
173 !56 = !DILocation(line: 14, column: 3, scope: !25)