1; RUN: opt -passes=jump-threading -S %s -o - | FileCheck %s 2define void @prepare_next_shadow() !dbg !7 { 3entry: 4 br label %for.cond, !dbg !9 5 6for.cond: ; preds = %for.inc, %entry 7 br label %shadow_to_ptr.exit, !dbg !10 8 9shadow_to_ptr.exit: ; preds = %for.cond 10 %shr.i = lshr i64 0, 12, !dbg !11 11 %cmp.i = icmp ult i64 %shr.i, undef, !dbg !12 12 br i1 %cmp.i, label %cleanup.i, label %if.end.i60, !dbg !13 13 14if.end.i60: ; preds = %shadow_to_ptr.exit 15 %sub.i = sub i64 %shr.i, undef, !dbg !14 16 %cmp3.i = icmp ugt i64 %sub.i, 32763, !dbg !15 17 %conv7.i = trunc i64 %sub.i to i32, !dbg !16 18 %spec.select.i = select i1 %cmp3.i, i32 -1, i32 %conv7.i, !dbg !17 19; Jump threading is going to fold the select in to the branch. Ensure debug 20; info is not lost, and is merged from the select and the branch. 21; CHECK-NOT: br i1 %cmp3.i, label %for.inc, label %ptr_to_shadow.exit 22; CHECK: br i1 %cmp3.i, label %for.inc, label %ptr_to_shadow.exit, !dbg [[DBG:![0-9]+]] 23; CHECK: [[DBG]] = !DILocation(line: 9, column: 1, scope: !{{.*}}) 24 25 br label %ptr_to_shadow.exit, !dbg !17 26 27cleanup.i: ; preds = %shadow_to_ptr.exit 28 br label %ptr_to_shadow.exit, !dbg !19 29 30ptr_to_shadow.exit: ; preds = %cleanup.i, %if.end.i60 31 %call1861 = phi i32 [ %spec.select.i, %if.end.i60 ], [ -1, %cleanup.i ], !dbg !20 32 %cmp19 = icmp slt i32 %call1861, 0, !dbg !21 33 br i1 %cmp19, label %for.inc, label %if.end22, !dbg !22 34 35if.end22: ; preds = %ptr_to_shadow.exit 36 unreachable, !dbg !23 37 38for.inc: ; preds = %ptr_to_shadow.exit 39 br label %for.cond, !dbg !24 40} 41 42!llvm.ident = !{!0} 43!llvm.dbg.cu = !{!1} 44!llvm.debugify = !{!4, !5} 45!llvm.module.flags = !{!6} 46 47!0 = !{!""} 48!1 = distinct !DICompileUnit(language: DW_LANG_C, file: !2, producer: "debugify", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, enums: !3) 49!2 = !DIFile(filename: "jump_threading.ll", directory: "/") 50!3 = !{} 51!4 = !{i32 16} 52!5 = !{i32 0} 53!6 = !{i32 2, !"Debug Info Version", i32 3} 54!7 = distinct !DISubprogram(name: "prepare_next_shadow", linkageName: "prepare_next_shadow", scope: null, file: !2, line: 1, type: !8, scopeLine: 1, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !1, retainedNodes: !3) 55!8 = !DISubroutineType(types: !3) 56!9 = !DILocation(line: 1, column: 1, scope: !7) 57!10 = !DILocation(line: 2, column: 1, scope: !7) 58!11 = !DILocation(line: 3, column: 1, scope: !7) 59!12 = !DILocation(line: 4, column: 1, scope: !7) 60!13 = !DILocation(line: 5, column: 1, scope: !7) 61!14 = !DILocation(line: 6, column: 1, scope: !7) 62!15 = !DILocation(line: 7, column: 1, scope: !7) 63!16 = !DILocation(line: 8, column: 1, scope: !7) 64!17 = !DILocation(line: 9, column: 1, scope: !7) 65!19 = !DILocation(line: 11, column: 1, scope: !7) 66!20 = !DILocation(line: 12, column: 1, scope: !7) 67!21 = !DILocation(line: 13, column: 1, scope: !7) 68!22 = !DILocation(line: 14, column: 1, scope: !7) 69!23 = !DILocation(line: 15, column: 1, scope: !7) 70!24 = !DILocation(line: 16, column: 1, scope: !7) 71