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