1; Test that the debug information is propagated correctly to the new instructions 2; RUN: opt < %s -passes=indvars -S | FileCheck %s 3 4define void @test_srem_urem(ptr %a) !dbg !5 { 5; CHECK-LABEL: define void @test_srem_urem( 6; CHECK: [[REM_UREM:%.*]] = urem i32 [[I_01:%.*]], 2, !dbg [[DBG10:![0-9]+]] 7; 8entry: 9 br label %for.body, !dbg !8 10 11for.body: ; preds = %for.body, %entry 12 %i.01 = phi i32 [ 0, %entry ], [ %inc, %for.body ], !dbg !9 13 %rem = srem i32 %i.01, 2, !dbg !10 14 %idxprom = sext i32 %rem to i64, !dbg !11 15 %arrayidx = getelementptr inbounds i32, ptr %a, i64 %idxprom, !dbg !12 16 store i32 %i.01, ptr %arrayidx, align 4, !dbg !13 17 %inc = add nsw i32 %i.01, 1, !dbg !14 18 %cmp = icmp slt i32 %inc, 64, !dbg !15 19 br i1 %cmp, label %for.body, label %for.end, !dbg !16 20 21for.end: ; preds = %for.body 22 ret void, !dbg !17 23} 24 25define void @test_sdiv_udiv(ptr %a) !dbg !18 { 26; CHECK-LABEL: define void @test_sdiv_udiv( 27; CHECK: [[DIV_UDIV:%.*]] = udiv i32 [[I_01:%.*]], 2, !dbg [[DBG21:![0-9]+]] 28; 29entry: 30 br label %for.body, !dbg !19 31 32for.body: ; preds = %for.body, %entry 33 %i.01 = phi i32 [ 0, %entry ], [ %inc, %for.body ], !dbg !20 34 %div = sdiv i32 %i.01, 2, !dbg !21 35 %idxprom = sext i32 %div to i64, !dbg !22 36 %arrayidx = getelementptr inbounds i32, ptr %a, i64 %idxprom, !dbg !23 37 store i32 %i.01, ptr %arrayidx, align 4, !dbg !24 38 %inc = add nsw i32 %i.01, 1, !dbg !25 39 %cmp = icmp slt i32 %inc, 64, !dbg !26 40 br i1 %cmp, label %for.body, label %for.end, !dbg !27 41 42for.end: ; preds = %for.body 43 ret void, !dbg !28 44} 45 46; Function Attrs: nounwind 47define i32 @test_rem_num_zero(i64 %arg1) #0 !dbg !29 { 48; CHECK-LABEL: define i32 @test_rem_num_zero( 49; CHECK: [[TMP0:%.*]] = icmp eq i64 [[T12:%.*]], %arg1 50; CHECK: [[IV_REM:%.*]] = select i1 [[TMP0]], i64 0, i64 [[T12]], !dbg [[DBG36:![0-9]+]] 51; 52bb: 53 %t = icmp sgt i64 %arg1, 0, !dbg !30 54 br i1 %t, label %bb4, label %bb54, !dbg !31 55 56bb4: ; preds = %bb 57 br label %bb5, !dbg !32 58 59bb5: ; preds = %bb49, %bb4 60 %t6 = phi i64 [ %t51, %bb49 ], [ 0, %bb4 ], !dbg !33 61 %t7 = phi i32 [ %t50, %bb49 ], [ 0, %bb4 ], !dbg !34 62 %t12 = add nsw i64 %t6, 1, !dbg !35 63 %t13 = srem i64 %t12, %arg1, !dbg !36 64 %t14 = icmp sgt i64 %arg1, 0, !dbg !37 65 br i1 %t14, label %bb15, label %bb49, !dbg !38 66 67bb15: ; preds = %bb5 68 br label %bb16, !dbg !39 69 70bb16: ; preds = %bb44, %bb15 71 %t17 = phi i64 [ %t46, %bb44 ], [ 0, %bb15 ], !dbg !40 72 %t18 = phi i32 [ %t45, %bb44 ], [ %t7, %bb15 ], !dbg !41 73 %t19 = icmp sgt i64 %arg1, 0, !dbg !42 74 br i1 %t19, label %bb20, label %bb44, !dbg !43 75 76bb20: ; preds = %bb16 77 br label %bb21, !dbg !44 78 79bb21: ; preds = %bb21, %bb20 80 %t25 = mul i64 %t13, %arg1, !dbg !45 81 %t42 = icmp slt i64 %t25, %arg1, !dbg !46 82 br i1 %t42, label %bb21, label %bb43, !dbg !47 83 84bb43: ; preds = %bb21 85 br label %bb44, !dbg !48 86 87bb44: ; preds = %bb43, %bb16 88 %t45 = phi i32 [ %t18, %bb16 ], [ 0, %bb43 ], !dbg !49 89 %t46 = add nsw i64 %t17, 1, !dbg !50 90 %t47 = icmp slt i64 %t46, %arg1, !dbg !51 91 br i1 %t47, label %bb16, label %bb48, !dbg !52 92 93bb48: ; preds = %bb44 94 br label %bb49, !dbg !53 95 96bb49: ; preds = %bb48, %bb5 97 %t50 = phi i32 [ %t7, %bb5 ], [ %t45, %bb48 ], !dbg !54 98 %t51 = add nsw i64 %t6, 1, !dbg !55 99 %t52 = icmp slt i64 %t51, %arg1, !dbg !56 100 br i1 %t52, label %bb5, label %bb53, !dbg !57 101 102bb53: ; preds = %bb49 103 br label %bb54, !dbg !58 104 105bb54: ; preds = %bb53, %bb 106 %t55 = phi i32 [ 0, %bb ], [ %t50, %bb53 ], !dbg !59 107 ret i32 %t55, !dbg !60 108} 109 110attributes #0 = { nounwind } 111 112!llvm.dbg.cu = !{!0} 113!llvm.debugify = !{!2, !3} 114!llvm.module.flags = !{!4} 115 116;. 117; CHECK: [[DBG10]] = !DILocation(line: 3, 118; CHECK: [[DBG21]] = !DILocation(line: 13, 119; CHECK: [[DBG36]] = !DILocation(line: 27, 120;. 121 122!0 = distinct !DICompileUnit(language: DW_LANG_C, file: !1, producer: "debugify", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug) 123!1 = !DIFile(filename: "indvars.ll", directory: "/") 124!2 = !{i32 51} 125!3 = !{i32 0} 126!4 = !{i32 2, !"Debug Info Version", i32 3} 127!5 = distinct !DISubprogram(name: "test_srem_urem", linkageName: "test_srem_urem", scope: null, file: !1, line: 1, type: !6, scopeLine: 1, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !0) 128!6 = !DISubroutineType(types: !7) 129!7 = !{} 130!8 = !DILocation(line: 1, column: 1, scope: !5) 131!9 = !DILocation(line: 2, column: 1, scope: !5) 132!10 = !DILocation(line: 3, column: 1, scope: !5) 133!11 = !DILocation(line: 4, column: 1, scope: !5) 134!12 = !DILocation(line: 5, column: 1, scope: !5) 135!13 = !DILocation(line: 6, column: 1, scope: !5) 136!14 = !DILocation(line: 7, column: 1, scope: !5) 137!15 = !DILocation(line: 8, column: 1, scope: !5) 138!16 = !DILocation(line: 9, column: 1, scope: !5) 139!17 = !DILocation(line: 10, column: 1, scope: !5) 140!18 = distinct !DISubprogram(name: "test_sdiv_udiv", linkageName: "test_sdiv_udiv", scope: null, file: !1, line: 11, type: !6, scopeLine: 11, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !0) 141!19 = !DILocation(line: 11, column: 1, scope: !18) 142!20 = !DILocation(line: 12, column: 1, scope: !18) 143!21 = !DILocation(line: 13, column: 1, scope: !18) 144!22 = !DILocation(line: 14, column: 1, scope: !18) 145!23 = !DILocation(line: 15, column: 1, scope: !18) 146!24 = !DILocation(line: 16, column: 1, scope: !18) 147!25 = !DILocation(line: 17, column: 1, scope: !18) 148!26 = !DILocation(line: 18, column: 1, scope: !18) 149!27 = !DILocation(line: 19, column: 1, scope: !18) 150!28 = !DILocation(line: 20, column: 1, scope: !18) 151!29 = distinct !DISubprogram(name: "test_rem_num_zero", linkageName: "test_rem_num_zero", scope: null, file: !1, line: 21, type: !6, scopeLine: 21, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !0) 152!30 = !DILocation(line: 21, column: 1, scope: !29) 153!31 = !DILocation(line: 22, column: 1, scope: !29) 154!32 = !DILocation(line: 23, column: 1, scope: !29) 155!33 = !DILocation(line: 24, column: 1, scope: !29) 156!34 = !DILocation(line: 25, column: 1, scope: !29) 157!35 = !DILocation(line: 26, column: 1, scope: !29) 158!36 = !DILocation(line: 27, column: 1, scope: !29) 159!37 = !DILocation(line: 28, column: 1, scope: !29) 160!38 = !DILocation(line: 29, column: 1, scope: !29) 161!39 = !DILocation(line: 30, column: 1, scope: !29) 162!40 = !DILocation(line: 31, column: 1, scope: !29) 163!41 = !DILocation(line: 32, column: 1, scope: !29) 164!42 = !DILocation(line: 33, column: 1, scope: !29) 165!43 = !DILocation(line: 34, column: 1, scope: !29) 166!44 = !DILocation(line: 35, column: 1, scope: !29) 167!45 = !DILocation(line: 36, column: 1, scope: !29) 168!46 = !DILocation(line: 37, column: 1, scope: !29) 169!47 = !DILocation(line: 38, column: 1, scope: !29) 170!48 = !DILocation(line: 39, column: 1, scope: !29) 171!49 = !DILocation(line: 40, column: 1, scope: !29) 172!50 = !DILocation(line: 41, column: 1, scope: !29) 173!51 = !DILocation(line: 42, column: 1, scope: !29) 174!52 = !DILocation(line: 43, column: 1, scope: !29) 175!53 = !DILocation(line: 44, column: 1, scope: !29) 176!54 = !DILocation(line: 45, column: 1, scope: !29) 177!55 = !DILocation(line: 46, column: 1, scope: !29) 178!56 = !DILocation(line: 47, column: 1, scope: !29) 179!57 = !DILocation(line: 48, column: 1, scope: !29) 180!58 = !DILocation(line: 49, column: 1, scope: !29) 181!59 = !DILocation(line: 50, column: 1, scope: !29) 182!60 = !DILocation(line: 51, column: 1, scope: !29) 183