192 lines · plain
1; RUN: llc -start-after=codegenprepare -stop-before finalize-isel -o - %s \2; RUN: -experimental-debug-variable-locations=false \3; RUN: | FileCheck %s --check-prefixes=CHECK,DBGVALUE4; RUN: llc -start-after=codegenprepare -stop-before finalize-isel -o - %s \5; RUN: -experimental-debug-variable-locations=true \6; RUN: | FileCheck %s --check-prefixes=CHECK,INSTRREF7 8; This test case is a modified version of dbg_value_phi_isel1.ll9; where the llvm.dbg.value nodes in for.body has been moved.10 11; ModuleID = 'debug.c'12source_filename = "debug.c"13target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"14target triple = "x86_64-unknown-linux-gnu"15 16@end = dso_local local_unnamed_addr global i32 10, align 4, !dbg !017 18; Function Attrs: nounwind uwtable19define dso_local i32 @main() local_unnamed_addr #0 !dbg !11 {20entry:21 %arr = alloca [80 x i32], align 1622 call void @llvm.dbg.value(metadata i32 9, metadata !15, metadata !DIExpression()), !dbg !2623 call void @llvm.dbg.value(metadata i32 13, metadata !16, metadata !DIExpression()), !dbg !2724 call void @llvm.dbg.value(metadata i32 0, metadata !17, metadata !DIExpression()), !dbg !2825 %0 = load i32, ptr @end, align 4, !dbg !29, !tbaa !3126 %cmp20 = icmp sgt i32 %0, 0, !dbg !3527 br i1 %cmp20, label %for.body.lr.ph, label %for.cond.cleanup, !dbg !3628 29for.body.lr.ph: ; preds = %entry30 %1 = load i32, ptr @end, align 4, !tbaa !3131 br label %for.body, !dbg !3632 33for.cond.cleanup: ; preds = %for.body, %entry34; CHECK-LABEL: bb.{{.*}}.for.cond.cleanup:35; CHECK: [[REG1:%[0-9]+]]:gr32 = PHI36; INSTRREF-SAME: debug-instr-number 737; INSTRREF-NEXT: DBG_INSTR_REF {{.+}}, dbg-instr-ref(7, 0)38; DBGVALUE-NEXT: DBG_VALUE [[REG1]]39 %x.0.lcssa = phi i32 [ 9, %entry ], [ %add, %for.body ]40 call void @llvm.dbg.value(metadata i32 %x.0.lcssa, metadata !15, metadata !DIExpression()), !dbg !2641 call void @llvm.lifetime.start.p0(i64 320, ptr nonnull %arr) #3, !dbg !3742 call void @llvm.dbg.declare(metadata ptr %arr, metadata !19, metadata !DIExpression()), !dbg !3843 call void @llvm.dbg.value(metadata i32 0, metadata !24, metadata !DIExpression()), !dbg !3944 br label %for.body4, !dbg !4045 46for.body: ; preds = %for.body.lr.ph, %for.body47; CHECK-LABEL: bb.{{.*}}.for.body:48; CHECK: [[REG2:%[0-9]+]]:gr32 = PHI49; INSTRREF-SAME: debug-instr-number 450; CHECK-NEXT: [[REG3:%[0-9]+]]:gr32 = PHI51; INSTRREF-SAME: debug-instr-number 352; CHECK-NEXT: [[REG4:%[0-9]+]]:gr32 = PHI53; INSTRREF-SAME: debug-instr-number 654; INSTRREF-NEXT: DBG_INSTR_REF !16, {{.+}}, dbg-instr-ref(3, 0)55; DBGVALUE-NEXT: DBG_VALUE [[REG3]], $noreg, !1656; CHECK-NEXT: DBG_VALUE 555, $noreg, !1757; CHECK-NEXT: [[ADDREG:%[0-9]+]]:gr32 = nuw nsw ADD32rr58; INSTRREF-SAME: debug-instr-number 559; INSTRREF-NEXT: DBG_INSTR_REF !17, {{.+}}, dbg-instr-ref(4, 0)60; DBGVALUE-NEXT: DBG_VALUE [[REG2]], $noreg, !1761; CHECK: [[MULREG:%[0-9]+]]:gr32 = LEA64_32r62; INSTRREF-SAME: debug-instr-number 163; CHECK-NEXT: DBG_VALUE 777, $noreg, !1764;;; XXX: The following DBG_INSTR_REF should have stayed below the INC32r65; INSTRREF-NEXT: DBG_INSTR_REF !16, {{.+}}, dbg-instr-ref(1, 0)66; DBGVALUE-NEXT: DBG_VALUE [[MULREG]], $noreg, !1667; CHECK-NEXT: [[INCREG:%[0-9]+]]:gr32 = nuw nsw INC32r68; INSTRREF-SAME: debug-instr-number 269; INSTRREF-NEXT: DBG_INSTR_REF !17, {{.+}}, dbg-instr-ref(2, 0)70; INSTRREF-NEXT: DBG_INSTR_REF !15, {{.+}}, dbg-instr-ref(5, 0)71; DBGVALUE-NEXT: DBG_VALUE [[INCREG]], $noreg, !1772; DBGVALUE-NEXT: DBG_VALUE [[ADDREG]], $noreg, !1573; CHECK-NEXT: implicit-def $eflags,74; INSTRREF-NEXT: DBG_INSTR_REF {{.+}}, dbg-instr-ref(6, 0)75; DBGVALUE-NEXT: DBG_VALUE [[REG4]]76 %u.023 = phi i32 [ 0, %for.body.lr.ph ], [ %inc, %for.body ]77 %y.022 = phi i32 [ 13, %for.body.lr.ph ], [ %mul, %for.body ]78 %x.021 = phi i32 [ 9, %for.body.lr.ph ], [ %add, %for.body ]79 call void @llvm.dbg.value(metadata i32 %y.022, metadata !16, metadata !DIExpression()), !dbg !2780 ; This dbg.value has been manually added compared to dbg_value_phi_isel1.ll81 call void @llvm.dbg.value(metadata i32 555, metadata !17, metadata !DIExpression()), !dbg !2882 %add = add nuw nsw i32 %y.022, %x.021, !dbg !4183 ; This dbg.value has been manually moved compared to dbg_value_phi_isel1.ll84 call void @llvm.dbg.value(metadata i32 %u.023, metadata !17, metadata !DIExpression()), !dbg !2885 %mul = mul nsw i32 %y.022, 3, !dbg !4386 ; This dbg.value has been manually added compared to dbg_value_phi_isel1.ll87 call void @llvm.dbg.value(metadata i32 777, metadata !17, metadata !DIExpression()), !dbg !2888 %inc = add nuw nsw i32 %u.023, 1, !dbg !4489 call void @llvm.dbg.value(metadata i32 %inc, metadata !17, metadata !DIExpression()), !dbg !2890 call void @llvm.dbg.value(metadata i32 %mul, metadata !16, metadata !DIExpression()), !dbg !2791 call void @llvm.dbg.value(metadata i32 %add, metadata !15, metadata !DIExpression()), !dbg !2692 %cmp = icmp slt i32 %inc, %1, !dbg !3593 ; This dbg.value has been manually moved compared to dbg_value_phi_isel1.ll94 call void @llvm.dbg.value(metadata i32 %x.021, metadata !15, metadata !DIExpression()), !dbg !2695 br i1 %cmp, label %for.body, label %for.cond.cleanup, !dbg !36, !llvm.loop !4596 97for.cond.cleanup3: ; preds = %for.body498 call void @llvm.lifetime.end.p0(i64 320, ptr nonnull %arr) #3, !dbg !4799 ret i32 %x.0.lcssa, !dbg !48100 101for.body4: ; preds = %for.body4, %for.cond.cleanup102 %indvars.iv = phi i64 [ 0, %for.cond.cleanup ], [ %indvars.iv.next, %for.body4 ]103 call void @llvm.dbg.value(metadata i64 %indvars.iv, metadata !24, metadata !DIExpression()), !dbg !39104 %arrayidx = getelementptr inbounds [80 x i32], ptr %arr, i64 0, i64 %indvars.iv, !dbg !49105 %2 = trunc i64 %indvars.iv to i32, !dbg !52106 %3 = add i32 %2, 3, !dbg !52107 store volatile i32 %3, ptr %arrayidx, align 4, !dbg !52, !tbaa !31108 %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1, !dbg !53109 call void @llvm.dbg.value(metadata i32 undef, metadata !24, metadata !DIExpression(DW_OP_plus_uconst, 1, DW_OP_stack_value)), !dbg !39110 %exitcond = icmp eq i64 %indvars.iv.next, 64, !dbg !54111 br i1 %exitcond, label %for.cond.cleanup3, label %for.body4, !dbg !40, !llvm.loop !55112}113 114; Function Attrs: argmemonly nounwind115declare void @llvm.lifetime.start.p0(i64, ptr nocapture) #1116 117; Function Attrs: nounwind readnone speculatable118declare void @llvm.dbg.declare(metadata, metadata, metadata) #2119 120; Function Attrs: argmemonly nounwind121declare void @llvm.lifetime.end.p0(i64, ptr nocapture) #1122 123; Function Attrs: nounwind readnone speculatable124declare void @llvm.dbg.value(metadata, metadata, metadata) #2125 126attributes #0 = { nounwind uwtable }127attributes #1 = { argmemonly nounwind }128attributes #2 = { nounwind readnone speculatable }129attributes #3 = { nounwind }130 131!llvm.dbg.cu = !{!2}132!llvm.module.flags = !{!7, !8, !9}133!llvm.ident = !{!10}134 135!0 = !DIGlobalVariableExpression(var: !1, expr: !DIExpression())136!1 = distinct !DIGlobalVariable(name: "end", scope: !2, file: !3, line: 1, type: !6, isLocal: false, isDefinition: true)137!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)138!3 = !DIFile(filename: "debug.c", directory: "")139!4 = !{}140!5 = !{!0}141!6 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)142!7 = !{i32 2, !"Dwarf Version", i32 4}143!8 = !{i32 2, !"Debug Info Version", i32 3}144!9 = !{i32 1, !"wchar_size", i32 4}145!10 = !{!"clang version 7.0.0 (x)"}146!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)147!12 = !DISubroutineType(types: !13)148!13 = !{!6}149!14 = !{!15, !16, !17, !19, !24}150!15 = !DILocalVariable(name: "x", scope: !11, file: !3, line: 4, type: !6)151!16 = !DILocalVariable(name: "y", scope: !11, file: !3, line: 5, type: !6)152!17 = !DILocalVariable(name: "u", scope: !18, file: !3, line: 6, type: !6)153!18 = distinct !DILexicalBlock(scope: !11, file: !3, line: 6, column: 3)154!19 = !DILocalVariable(name: "arr", scope: !11, file: !3, line: 11, type: !20)155!20 = !DICompositeType(tag: DW_TAG_array_type, baseType: !21, size: 2560, elements: !22)156!21 = !DIDerivedType(tag: DW_TAG_volatile_type, baseType: !6)157!22 = !{!23}158!23 = !DISubrange(count: 80)159!24 = !DILocalVariable(name: "q", scope: !25, file: !3, line: 12, type: !6)160!25 = distinct !DILexicalBlock(scope: !11, file: !3, line: 12, column: 3)161!26 = !DILocation(line: 4, column: 7, scope: !11)162!27 = !DILocation(line: 5, column: 7, scope: !11)163!28 = !DILocation(line: 6, column: 12, scope: !18)164!29 = !DILocation(line: 6, column: 23, scope: !30)165!30 = distinct !DILexicalBlock(scope: !18, file: !3, line: 6, column: 3)166!31 = !{!32, !32, i64 0}167!32 = !{!"int", !33, i64 0}168!33 = !{!"omnipotent char", !34, i64 0}169!34 = !{!"Simple C/C++ TBAA"}170!35 = !DILocation(line: 6, column: 21, scope: !30)171!36 = !DILocation(line: 6, column: 3, scope: !18)172!37 = !DILocation(line: 11, column: 3, scope: !11)173!38 = !DILocation(line: 11, column: 16, scope: !11)174!39 = !DILocation(line: 12, column: 12, scope: !25)175!40 = !DILocation(line: 12, column: 3, scope: !25)176!41 = !DILocation(line: 7, column: 7, scope: !42)177!42 = distinct !DILexicalBlock(scope: !30, file: !3, line: 6, column: 33)178!43 = !DILocation(line: 8, column: 11, scope: !42)179!44 = !DILocation(line: 6, column: 28, scope: !30)180!45 = distinct !{!45, !36, !46}181!46 = !DILocation(line: 9, column: 3, scope: !18)182!47 = !DILocation(line: 17, column: 1, scope: !11)183!48 = !DILocation(line: 16, column: 3, scope: !11)184!49 = !DILocation(line: 13, column: 5, scope: !50)185!50 = distinct !DILexicalBlock(scope: !51, file: !3, line: 12, column: 32)186!51 = distinct !DILexicalBlock(scope: !25, file: !3, line: 12, column: 3)187!52 = !DILocation(line: 13, column: 12, scope: !50)188!53 = !DILocation(line: 12, column: 27, scope: !51)189!54 = !DILocation(line: 12, column: 21, scope: !51)190!55 = distinct !{!55, !40, !56}191!56 = !DILocation(line: 14, column: 3, scope: !25)192