1; Test that the debug information is propagated correctly to the new instructions 2; RUN: opt < %s -passes=indvars -S | FileCheck %s 3 4; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none) 5declare i32 @llvm.uadd.sat.i32(i32, i32) #0 6 7; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none) 8declare { i32, i1 } @llvm.uadd.with.overflow.i32(i32, i32) #0 9 10define void @f_uadd(ptr %a) !dbg !5 { 11; CHECK-LABEL: define void @f_uadd( 12; CHECK: [[TMP0:%.*]] = add nuw nsw i32 [[I_04:%.*]], 1, !dbg [[DBG14:![0-9]+]] 13; 14entry: 15 br label %for.body, !dbg !8 16 17for.cond.cleanup: ; preds = %cont 18 ret void, !dbg !9 19 20for.body: ; preds = %cont, %entry 21 %i.04 = phi i32 [ 0, %entry ], [ %2, %cont ], !dbg !10 22 %idxprom = sext i32 %i.04 to i64, !dbg !11 23 %arrayidx = getelementptr inbounds i8, ptr %a, i64 %idxprom, !dbg !12 24 store i8 0, ptr %arrayidx, align 1, !dbg !13 25 %0 = tail call { i32, i1 } @llvm.uadd.with.overflow.i32(i32 %i.04, i32 1), !dbg !14 26 %1 = extractvalue { i32, i1 } %0, 1, !dbg !15 27 br i1 %1, label %trap, label %cont, !dbg !16, !nosanitize !7 28 29trap: ; preds = %for.body 30 tail call void @llvm.trap(), !dbg !17, !nosanitize !7 31 unreachable, !dbg !18, !nosanitize !7 32 33cont: ; preds = %for.body 34 %2 = extractvalue { i32, i1 } %0, 0, !dbg !19 35 %cmp = icmp slt i32 %2, 16, !dbg !20 36 br i1 %cmp, label %for.body, label %for.cond.cleanup, !dbg !21 37} 38 39define void @uadd_sat(ptr %p) !dbg !22 { 40; CHECK-LABEL: define void @uadd_sat( 41; CHECK: [[SAT1:%.*]] = add nuw nsw i32 [[I:%.*]], 1, !dbg [[DBG23:![0-9]+]] 42; 43entry: 44 br label %loop, !dbg !23 45 46loop: ; preds = %loop, %entry 47 %i = phi i32 [ 0, %entry ], [ %i.inc, %loop ], !dbg !24 48 %sat = call i32 @llvm.uadd.sat.i32(i32 %i, i32 1), !dbg !25 49 store volatile i32 %sat, ptr %p, align 4, !dbg !26 50 %i.inc = add nuw nsw i32 %i, 1, !dbg !27 51 %cmp = icmp ne i32 %i.inc, 100, !dbg !28 52 br i1 %cmp, label %loop, label %end, !dbg !29 53 54end: ; preds = %loop 55 ret void, !dbg !30 56} 57 58; Function Attrs: cold noreturn nounwind memory(inaccessiblemem: write) 59declare void @llvm.trap() #1 60 61attributes #0 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) } 62attributes #1 = { cold noreturn nounwind memory(inaccessiblemem: write) } 63 64!llvm.dbg.cu = !{!0} 65!llvm.debugify = !{!2, !3} 66!llvm.module.flags = !{!4} 67 68;. 69; CHECK: [[DBG14]] = !DILocation(line: 12, 70; CHECK: [[DBG23]] = !DILocation(line: 17, 71;. 72 73!0 = distinct !DICompileUnit(language: DW_LANG_C, file: !1, producer: "debugify", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug) 74!1 = !DIFile(filename: "eliminatesat.ll", directory: "/") 75!2 = !{i32 22} 76!3 = !{i32 0} 77!4 = !{i32 2, !"Debug Info Version", i32 3} 78!5 = distinct !DISubprogram(name: "f_uadd", linkageName: "f_uadd", scope: null, file: !1, line: 1, type: !6, scopeLine: 1, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !0) 79!6 = !DISubroutineType(types: !7) 80!7 = !{} 81!8 = !DILocation(line: 1, column: 1, scope: !5) 82!9 = !DILocation(line: 2, column: 1, scope: !5) 83!10 = !DILocation(line: 3, column: 1, scope: !5) 84!11 = !DILocation(line: 4, column: 1, scope: !5) 85!12 = !DILocation(line: 5, column: 1, scope: !5) 86!13 = !DILocation(line: 6, column: 1, scope: !5) 87!14 = !DILocation(line: 7, column: 1, scope: !5) 88!15 = !DILocation(line: 8, column: 1, scope: !5) 89!16 = !DILocation(line: 9, column: 1, scope: !5) 90!17 = !DILocation(line: 10, column: 1, scope: !5) 91!18 = !DILocation(line: 11, column: 1, scope: !5) 92!19 = !DILocation(line: 12, column: 1, scope: !5) 93!20 = !DILocation(line: 13, column: 1, scope: !5) 94!21 = !DILocation(line: 14, column: 1, scope: !5) 95!22 = distinct !DISubprogram(name: "uadd_sat", linkageName: "uadd_sat", scope: null, file: !1, line: 15, type: !6, scopeLine: 15, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !0) 96!23 = !DILocation(line: 15, column: 1, scope: !22) 97!24 = !DILocation(line: 16, column: 1, scope: !22) 98!25 = !DILocation(line: 17, column: 1, scope: !22) 99!26 = !DILocation(line: 18, column: 1, scope: !22) 100!27 = !DILocation(line: 19, column: 1, scope: !22) 101!28 = !DILocation(line: 20, column: 1, scope: !22) 102!29 = !DILocation(line: 21, column: 1, scope: !22) 103!30 = !DILocation(line: 22, column: 1, scope: !22) 104