|
| 1 | +; RUN: opt -passes='simple-loop-unswitch<nontrivial>' -S < %s | FileCheck %s |
| 2 | + |
| 3 | +define i32 @basic(i32 %N, i1 %cond, i32 %select_input) !dbg !5 { |
| 4 | +; CHECK-LABEL: define i32 @basic( |
| 5 | + |
| 6 | +; Check that SimpleLoopUnswitch's unswitchNontrivialInvariants() drops the |
| 7 | +; debug location of the hoisted terminator and doesn't give any debug location |
| 8 | +; to the new freeze, since it's inserted in a hoist block. |
| 9 | +; Also check that in unswitchNontrivialInvariants(), the new br instruction |
| 10 | +; inherits the debug location of the old terminator in the same block. |
| 11 | + |
| 12 | +; CHECK: entry: |
| 13 | +; CHECK-NEXT: [[COND_FR:%.*]] = freeze i1 [[COND:%.*]]{{$}} |
| 14 | +; CHECK-NEXT: br i1 [[COND_FR]], label %[[ENTRY_SPLIT_US:.*]], label %[[ENTRY_SPLIT:.*]]{{$}} |
| 15 | +; CHECK: for.body.us: |
| 16 | +; CHECK-NEXT: br label %0, !dbg [[DBG13:![0-9]+]] |
| 17 | + |
| 18 | +; Check that in turnSelectIntoBranch(), the new phi inherits the debug |
| 19 | +; location of the old select instruction replaced. |
| 20 | + |
| 21 | +; CHECK: 1: |
| 22 | +; CHECK-NEXT: [[UNSWITCHED_SELECT_US:%.*]] = phi i32 [ [[SELECT_INPUT:%.*]], %0 ], !dbg [[DBG13]] |
| 23 | + |
| 24 | +; Check that in BuildClonedLoopBlocks(), the new phi inherits the debug |
| 25 | +; location of the instruction at the insertion point and the new br |
| 26 | +; instruction inherits the debug location of the old terminator. |
| 27 | + |
| 28 | +; CHECK: for.body: |
| 29 | +; CHECK-NEXT: br label %2, !dbg [[DBG13]] |
| 30 | +; CHECK: for.cond.cleanup: |
| 31 | +; CHECK: [[DOTUS_PHI:%.*]] = phi i32 [ [[RES_LCSSA:%.*]], %[[FOR_COND_CLEANUP_SPLIT:.*]] ], [ [[RES_LCSSA_US:%.*]], %[[FOR_COND_CLEANUP_SPLIT_US:.*]] ], !dbg [[DBG17:![0-9]+]] |
| 32 | +entry: |
| 33 | + br label %for.cond, !dbg !8 |
| 34 | + |
| 35 | +for.cond: ; preds = %for.body, %entry |
| 36 | + %res = phi i32 [ 0, %entry ], [ %add, %for.body ], !dbg !9 |
| 37 | + %i = phi i32 [ 0, %entry ], [ %inc, %for.body ], !dbg !10 |
| 38 | + %cmp = icmp slt i32 %i, %N, !dbg !11 |
| 39 | + br i1 %cmp, label %for.body, label %for.cond.cleanup, !dbg !12 |
| 40 | + |
| 41 | +for.body: ; preds = %for.cond |
| 42 | + %cond1 = select i1 %cond, i32 %select_input, i32 42, !dbg !13 |
| 43 | + %add = add nuw nsw i32 %cond1, %res, !dbg !14 |
| 44 | + %inc = add nuw nsw i32 %i, 1, !dbg !15 |
| 45 | + br label %for.cond, !dbg !16 |
| 46 | + |
| 47 | +for.cond.cleanup: ; preds = %for.cond |
| 48 | + ret i32 %res, !dbg !17 |
| 49 | +} |
| 50 | + |
| 51 | +!llvm.dbg.cu = !{!0} |
| 52 | +!llvm.debugify = !{!2, !3} |
| 53 | +!llvm.module.flags = !{!4} |
| 54 | + |
| 55 | +; CHECK: [[DBG13]] = !DILocation(line: 6, |
| 56 | +; CHECK: [[DBG17]] = !DILocation(line: 10, |
| 57 | + |
| 58 | +!0 = distinct !DICompileUnit(language: DW_LANG_C, file: !1, producer: "debugify", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug) |
| 59 | +!1 = !DIFile(filename: "main.ll", directory: "/") |
| 60 | +!2 = !{i32 10} |
| 61 | +!3 = !{i32 0} |
| 62 | +!4 = !{i32 2, !"Debug Info Version", i32 3} |
| 63 | +!5 = distinct !DISubprogram(name: "basic", linkageName: "basic", scope: null, file: !1, line: 1, type: !6, scopeLine: 1, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !0) |
| 64 | +!6 = !DISubroutineType(types: !7) |
| 65 | +!7 = !{} |
| 66 | +!8 = !DILocation(line: 1, column: 1, scope: !5) |
| 67 | +!9 = !DILocation(line: 2, column: 1, scope: !5) |
| 68 | +!10 = !DILocation(line: 3, column: 1, scope: !5) |
| 69 | +!11 = !DILocation(line: 4, column: 1, scope: !5) |
| 70 | +!12 = !DILocation(line: 5, column: 1, scope: !5) |
| 71 | +!13 = !DILocation(line: 6, column: 1, scope: !5) |
| 72 | +!14 = !DILocation(line: 7, column: 1, scope: !5) |
| 73 | +!15 = !DILocation(line: 8, column: 1, scope: !5) |
| 74 | +!16 = !DILocation(line: 9, column: 1, scope: !5) |
| 75 | +!17 = !DILocation(line: 10, column: 1, scope: !5) |
0 commit comments