1; RUN: opt < %s -passes=gvn-sink -S | FileCheck %s 2 3; Test that GVNSink correctly merges the debug locations of sinked instruction 4 5define zeroext i1 @test18(i32 %flag, i32 %blksA, i32 %blksB, i32 %nblks) !dbg !5 { 6; CHECK: if.end: 7; CHECK-NEXT: [[CMP2_SINK:%.*]] = phi i1 [ %cmp2, %if.then2 ], [ %cmp, %if.then ], [ %cmp3, %if.then3 ] 8; CHECK-NEXT: [[FROMBOOL4:%.*]] = zext i1 [[CMP2_SINK]] to i8, !dbg [[DBG17:![0-9]+]] 9; 10entry: 11 switch i32 %flag, label %if.then3 [ 12 i32 0, label %if.then 13 i32 1, label %if.then2 14 ], !dbg !8 15 16if.then: ; preds = %entry 17 %cmp = icmp uge i32 %blksA, %nblks, !dbg !9 18 %frombool1 = zext i1 %cmp to i8, !dbg !10 19 br label %if.end, !dbg !11 20 21if.then2: ; preds = %entry 22 %add = add i32 %nblks, %blksB, !dbg !12 23 %cmp2 = icmp ule i32 %add, %blksA, !dbg !13 24 %frombool3 = zext i1 %cmp2 to i8, !dbg !14 25 br label %if.end, !dbg !15 26 27if.then3: ; preds = %entry 28 %add2 = add i32 %nblks, %blksA, !dbg !16 29 %cmp3 = icmp ule i32 %add2, %blksA, !dbg !17 30 %frombool4 = zext i1 %cmp3 to i8, !dbg !18 31 br label %if.end, !dbg !19 32 33if.end: ; preds = %if.then3, %if.then2, %if.then 34 %obeys.0 = phi i8 [ %frombool1, %if.then ], [ %frombool3, %if.then2 ], [ %frombool4, %if.then3 ], !dbg !20 35 %tobool4 = icmp ne i8 %obeys.0, 0, !dbg !21 36 ret i1 %tobool4, !dbg !22 37} 38 39define zeroext i1 @test_pr30244(i1 zeroext %flag, i1 zeroext %flag2, i32 %blksA, i32 %blksB, i32 %nblks) !dbg !23 { 40; CHECK: if.end.gvnsink.split: 41; CHECK-NEXT: [[CMP2_SINK:%.*]] = phi i1 [ %cmp2, %if.then2 ], [ %cmp, %if.then ] 42; CHECK-NEXT: [[FROMBOOL1:%.*]] = zext i1 [[CMP2_SINK]] to i8, !dbg [[DBG29:![0-9]+]] 43; 44entry: 45 %p = alloca i8, align 1, !dbg !24 46 br i1 %flag, label %if.then, label %if.else, !dbg !25 47 48if.then: ; preds = %entry 49 %cmp = icmp uge i32 %blksA, %nblks, !dbg !26 50 %frombool1 = zext i1 %cmp to i8, !dbg !27 51 store i8 %frombool1, ptr %p, align 1, !dbg !28 52 br label %if.end, !dbg !29 53 54if.else: ; preds = %entry 55 br i1 %flag2, label %if.then2, label %if.end, !dbg !30 56 57if.then2: ; preds = %if.else 58 %add = add i32 %nblks, %blksB, !dbg !31 59 %cmp2 = icmp ule i32 %add, %blksA, !dbg !32 60 %frombool3 = zext i1 %cmp2 to i8, !dbg !33 61 store i8 %frombool3, ptr %p, align 1, !dbg !34 62 br label %if.end, !dbg !35 63 64if.end: ; preds = %if.then2, %if.else, %if.then 65 ret i1 true, !dbg !36 66} 67 68!llvm.dbg.cu = !{!0} 69!llvm.debugify = !{!2, !3} 70!llvm.module.flags = !{!4} 71 72!0 = distinct !DICompileUnit(language: DW_LANG_C, file: !1, producer: "debugify", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug) 73!1 = !DIFile(filename: "sink-common-code.ll", directory: "/") 74!2 = !{i32 28} 75!3 = !{i32 0} 76!4 = !{i32 2, !"Debug Info Version", i32 3} 77!5 = distinct !DISubprogram(name: "test18", linkageName: "test18", scope: null, file: !1, line: 1, type: !6, scopeLine: 1, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !0) 78!6 = !DISubroutineType(types: !7) 79!7 = !{} 80!8 = !DILocation(line: 1, column: 1, scope: !5) 81!9 = !DILocation(line: 2, column: 1, scope: !5) 82!10 = !DILocation(line: 3, column: 1, scope: !5) 83!11 = !DILocation(line: 4, column: 1, scope: !5) 84!12 = !DILocation(line: 5, column: 1, scope: !5) 85!13 = !DILocation(line: 6, column: 1, scope: !5) 86!14 = !DILocation(line: 7, column: 1, scope: !5) 87!15 = !DILocation(line: 8, column: 1, scope: !5) 88!16 = !DILocation(line: 9, column: 1, scope: !5) 89!17 = !DILocation(line: 10, column: 1, scope: !5) 90!18 = !DILocation(line: 11, column: 1, scope: !5) 91!19 = !DILocation(line: 12, column: 1, scope: !5) 92!20 = !DILocation(line: 13, column: 1, scope: !5) 93!21 = !DILocation(line: 14, column: 1, scope: !5) 94!22 = !DILocation(line: 15, column: 1, scope: !5) 95!23 = distinct !DISubprogram(name: "test_pr30244", linkageName: "test_pr30244", scope: null, file: !1, line: 16, type: !6, scopeLine: 16, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !0) 96!24 = !DILocation(line: 16, column: 1, scope: !23) 97!25 = !DILocation(line: 17, column: 1, scope: !23) 98!26 = !DILocation(line: 18, column: 1, scope: !23) 99!27 = !DILocation(line: 19, column: 1, scope: !23) 100!28 = !DILocation(line: 20, column: 1, scope: !23) 101!29 = !DILocation(line: 21, column: 1, scope: !23) 102!30 = !DILocation(line: 22, column: 1, scope: !23) 103!31 = !DILocation(line: 23, column: 1, scope: !23) 104!32 = !DILocation(line: 24, column: 1, scope: !23) 105!33 = !DILocation(line: 25, column: 1, scope: !23) 106!34 = !DILocation(line: 26, column: 1, scope: !23) 107!35 = !DILocation(line: 27, column: 1, scope: !23) 108!36 = !DILocation(line: 28, column: 1, scope: !23) 109;. 110; CHECK: [[DBG17]] = !DILocation(line: 0 111; CHECK: [[DBG29]] = !DILocation(line: 0 112;. 113